Skip to content

Commit

Permalink
[Footnote extension] Add a way to customize the backlink title (Pytho…
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgesumle authored and waylan committed Dec 22, 2017
1 parent 1edbb9d commit bc5a9bb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 6 additions & 0 deletions docs/extensions/footnotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,9 @@ The following options are provided to configure the output:
* **`BACKLINK_TEXT`**:
The text string that links from the footnote definition back to the position
in the document. Defaults to `↩`.

* **`BACKLINK_TITLE`**:
The text string for the `title` HTML attribute of the footnote definition link.
`%d` will be replaced by the footnote number. Defaults to `Jump back to
footnote %d in the text`

9 changes: 7 additions & 2 deletions markdown/extensions/footnotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ def __init__(self, *args, **kwargs):
"BACKLINK_TEXT":
["↩",
"The text string that links from the footnote "
"to the reader's place."]
"to the reader's place."],
"BACKLINK_TITLE":
["Jump back to footnote %d in the text",
"The text string used for the title HTML attribute "
"of the backlink. %d will be replaced by the "
"footnote number."]
}
super(FootnoteExtension, self).__init__(*args, **kwargs)

Expand Down Expand Up @@ -192,7 +197,7 @@ def makeFootnotesDiv(self, root):
backlink.set("class", "footnote-backref")
backlink.set(
"title",
"Jump back to footnote %d in the text" %
self.getConfig("BACKLINK_TITLE") %
(self.footnotes.index(id)+1)
)
backlink.text = FN_BACKLINK_TEXT
Expand Down

0 comments on commit bc5a9bb

Please sign in to comment.