Modify

Opened 11 months ago

Last modified 11 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.

Attachments (0)

Change History (1)

comment:1 Changed 11 months ago by figaro

Type: defectenhancement

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain Ryan J Ollos.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.