diff --git a/lib/markdown2.py b/lib/markdown2.py index 82c496f4..efb0b5ac 100755 --- a/lib/markdown2.py +++ b/lib/markdown2.py @@ -162,6 +162,7 @@ class MarkdownError(Exception): def markdown_path(path, encoding="utf-8", html4tags=False, tab_width=DEFAULT_TAB_WIDTH, safe_mode=None, extras=None, link_patterns=None, + footnote_title=None, footnote_return_symbol=None, use_file_vars=False): fp = codecs.open(path, 'r', encoding) text = fp.read() @@ -169,15 +170,20 @@ def markdown_path(path, encoding="utf-8", return Markdown(html4tags=html4tags, tab_width=tab_width, safe_mode=safe_mode, extras=extras, link_patterns=link_patterns, + footnote_title=footnote_title, + footnote_return_symbol=footnote_return_symbol, use_file_vars=use_file_vars).convert(text) def markdown(text, html4tags=False, tab_width=DEFAULT_TAB_WIDTH, safe_mode=None, extras=None, link_patterns=None, + footnote_title=None, footnote_return_symbol=None, use_file_vars=False): return Markdown(html4tags=html4tags, tab_width=tab_width, safe_mode=safe_mode, extras=extras, link_patterns=link_patterns, + footnote_title=footnote_title, + footnote_return_symbol=footnote_return_symbol, use_file_vars=use_file_vars).convert(text) @@ -203,7 +209,9 @@ class Markdown(object): _ws_only_line_re = re.compile(r"^[ \t]+$", re.M) def __init__(self, html4tags=False, tab_width=4, safe_mode=None, - extras=None, link_patterns=None, use_file_vars=False): + extras=None, link_patterns=None, + footnote_title=None, footnote_return_symbol=None, + use_file_vars=False): if html4tags: self.empty_element_suffix = ">" else: @@ -233,6 +241,8 @@ def __init__(self, html4tags=False, tab_width=4, safe_mode=None, self._instance_extras = self.extras.copy() self.link_patterns = link_patterns + self.footnote_title = footnote_title + self.footnote_return_symbol = footnote_return_symbol self.use_file_vars = use_file_vars self._outdent_re = re.compile(r'^(\t|[ ]{1,%d})' % tab_width, re.M) @@ -2037,15 +2047,31 @@ def _add_footnotes(self, text): '
This is a para with a footnote.1
+ +This is another para with a footnote2 in it. Actually it has two3 of +them. No, three4.
+ + diff --git a/test/tm-cases/footnotes_custom.opts b/test/tm-cases/footnotes_custom.opts new file mode 100644 index 00000000..7b2b5e24 --- /dev/null +++ b/test/tm-cases/footnotes_custom.opts @@ -0,0 +1,3 @@ +{"extras": ["footnotes"], + "footnote_title" : "Yo Dawg, I heard you came from %d." +} diff --git a/test/tm-cases/footnotes_custom.text b/test/tm-cases/footnotes_custom.text new file mode 100644 index 00000000..7d6e7163 --- /dev/null +++ b/test/tm-cases/footnotes_custom.text @@ -0,0 +1,18 @@ +This is a para with a footnote.[^1] + +This is another para with a footnote[^2] in it. Actually it has two[^3] of +them. No, three[^4]. + + +[^1]: Here is the body of the first footnote. + +[^2]: And of the second footnote. + + This one has multiple paragraphs. + +[^3]: + Here is a footnote body that starts on next line. + +[^4]: quickie "that looks like a link ref if not careful" + +