def apply(self, **kwargs):
for ref in self.document.traverse(nodes.reference):
# Skip inter-document links
if 'refname' in ref:
if self.document.nameids.get(ref['refname']):
continue
# Convert remaining non-external links to intra-document references
refuri = ref['refuri'] if 'refuri' in ref else None
if not refuri or not '://' in refuri:
# Get the raw text (strip ``s and _)
rawtext = re.sub('^`(.*)`_?$', '\\1', ref.rawsource)
# Create xref node
xref = addnodes.pending_xref(
rawtext, reftype='ref', refdomain='std',
refexplicit=(refuri is not None))
# Rewrite section links
if not refuri:
refuri = ref['name']
# Fill target information
xref['reftarget'] = refuri.lower()
xref['refwarn'] = True
xref['refdoc'] = self.document.settings.env.docname
# Add ref text
xref += nodes.inline(rawtext, ref['name'],
classes=ref['classes'])
# Replace the old node
ref.replace_self(xref)
#==============================================================================
评论列表
文章目录