def run(self):
env = self.state.document.settings.env
targetid = "tag-%d" % env.new_serialno('tag')
targetnode = nodes.target('', '', ids=[targetid])
# The tags fetched from the custom directive are one piece of text
# sitting in self.content[0]
taggs = self.content[0].split(", ")
links = []
for tagg in taggs:
# Create Sphinx doc refs of format :ref:`Tagname<Tagname>`
link = ":ref:`" + tagg + "<" + tagg + ">`"
links.append(link)
# Put links back in a single comma-separated string together
linkjoin = ", ".join(links)
# Replace content[0] with hyperlinks to display in admonition
self.content[0] = linkjoin
ad = Admonition(self.name, [_('Tags')], self.options,
self.content, self.lineno, self.content_offset,
self.block_text, self.state, self.state_machine)
return [targetnode] + ad.run()
评论列表
文章目录