Opened 18 months ago
Last modified 18 months ago
#14228 new enhancement
Support for reusing footnote by name
Reported by: | Mingye Wang | Owned by: | Ryan J Ollos |
---|---|---|---|
Priority: | normal | Component: | FootNoteMacro |
Severity: | normal | Keywords: | |
Cc: | Trac Release: |
Description
The current [[FootNote(1)]]
reference is fragile to insertion of new footnotes, as numbers can change. It might make sense to, well, allow people to refer to footnotes by name.
The new proposed interface takes the form [[FootNote(name=...)]]
on reference, and [[FootNote(name=..., content)]]
on definition. The new "keyword" argument idea is to preserve possible extensibility when we want to set a group
, like in #8676.
And since we are doing multiple arguments, some splitting will be necessary. Just keep the note content at the end for now, so no fancy argument parser will be needed. The parsing is probably like:
KWARGS = ["name", "group"] if content: kwargs = {k: None for k in KWARGS} while True: old_content = content try: part, content = content.split(',', maxsplit=1) except ValueError: part = content content = '' try: key, value = part.trim().split('=', maxsplit=1) if key in kwargs: kwargs[key] = value else: raise ValueError("no such kw, must be talking about something else...") except ValueError: content = old_content break # go on do stuff with kwargs.
For keeping track of the footnotes, hmm, make a new context._footnote_names = {}
mapping strings to indices.