def make_target_footnote(self, refuri, refs, notes):
if refuri in notes: # duplicate?
footnote = notes[refuri]
assert len(footnote['names']) == 1
footnote_name = footnote['names'][0]
else: # original
footnote = nodes.footnote()
footnote_id = self.document.set_id(footnote)
# Use uppercase letters and a colon; they can't be
# produced inside names by the parser.
footnote_name = 'TARGET_NOTE: ' + footnote_id
footnote['auto'] = 1
footnote['names'] = [footnote_name]
footnote_paragraph = nodes.paragraph()
footnote_paragraph += nodes.reference('', refuri, refuri=refuri)
footnote += footnote_paragraph
self.document.note_autofootnote(footnote)
self.document.note_explicit_target(footnote, footnote)
for ref in refs:
if isinstance(ref, nodes.target):
continue
refnode = nodes.footnote_reference(refname=footnote_name, auto=1)
refnode['classes'] += self.classes
self.document.note_autofootnote_ref(refnode)
self.document.note_footnote_ref(refnode)
index = ref.parent.index(ref) + 1
reflist = [refnode]
if not utils.get_trim_footnote_ref_space(self.document.settings):
if self.classes:
reflist.insert(0, nodes.inline(text=' ', Classes=self.classes))
else:
reflist.insert(0, nodes.Text(' '))
ref.parent.insert(index, reflist)
return footnote
references.py 文件源码
python
阅读 37
收藏 0
点赞 0
评论 0
评论列表
文章目录