From bc5a9bb02ae5d171d42978078344050034edc106 Mon Sep 17 00:00:00 2001 From: Jorge Maldonado Ventura Date: Sat, 23 Dec 2017 00:00:07 +0100 Subject: [Footnote extension] Add a way to customize the backlink title (#616) Fixes #610. --- docs/extensions/footnotes.md | 6 ++++++ markdown/extensions/footnotes.py | 9 +++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/docs/extensions/footnotes.md b/docs/extensions/footnotes.md index c94c2c4..aaff184 100644 --- a/docs/extensions/footnotes.md +++ b/docs/extensions/footnotes.md @@ -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` + diff --git a/markdown/extensions/footnotes.py b/markdown/extensions/footnotes.py index 7edf813..620cf0b 100644 --- a/markdown/extensions/footnotes.py +++ b/markdown/extensions/footnotes.py @@ -49,7 +49,12 @@ class FootnoteExtension(Extension): "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) @@ -192,7 +197,7 @@ class FootnoteExtension(Extension): 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 -- cgit v1.2.3