aboutsummaryrefslogtreecommitdiffstats
path: root/markdown
diff options
context:
space:
mode:
authorWaylan Limberg <waylan@gmail.com>2013-02-08 10:54:40 -0500
committerWaylan Limberg <waylan@gmail.com>2013-02-08 10:54:40 -0500
commit41cc055580d63ffb7eb2bbb6c88e121727d91d06 (patch)
treeaa70239496cfd7320e465f3588f6f4aac02413a5 /markdown
parent28deb9b08f1cdc688a9463f569f6f23305890816 (diff)
downloadmarkdown-41cc055580d63ffb7eb2bbb6c88e121727d91d06.tar.gz
markdown-41cc055580d63ffb7eb2bbb6c88e121727d91d06.tar.bz2
markdown-41cc055580d63ffb7eb2bbb6c88e121727d91d06.zip
Footnote ids contain dashes when outputing HTML5.
Previously they contained colons - and they still do for HTML4 and XHTML. Fixes #180.
Diffstat (limited to 'markdown')
-rw-r--r--markdown/__init__.py2
-rw-r--r--markdown/extensions/footnotes.py12
2 files changed, 8 insertions, 6 deletions
diff --git a/markdown/__init__.py b/markdown/__init__.py
index c485513..aceaf60 100644
--- a/markdown/__init__.py
+++ b/markdown/__init__.py
@@ -132,9 +132,9 @@ class Markdown:
self.references = {}
self.htmlStash = util.HtmlStash()
+ self.set_output_format(kwargs.get('output_format', 'xhtml1'))
self.registerExtensions(extensions=kwargs.get('extensions', []),
configs=kwargs.get('extension_configs', {}))
- self.set_output_format(kwargs.get('output_format', 'xhtml1'))
self.reset()
def build_parser(self):
diff --git a/markdown/extensions/footnotes.py b/markdown/extensions/footnotes.py
index 064679b..0a0ddea 100644
--- a/markdown/extensions/footnotes.py
+++ b/markdown/extensions/footnotes.py
@@ -62,6 +62,9 @@ class FootnoteExtension(markdown.Extension):
md.registerExtension(self)
self.parser = md.parser
self.md = md
+ self.sep = ':'
+ if self.md.output_format in ['html5', 'xhtml5']:
+ self.sep = '-'
# Insert a preprocessor before ReferencePreprocessor
md.preprocessors.add("footnote", FootnotePreprocessor(self),
"<reference")
@@ -106,16 +109,16 @@ class FootnoteExtension(markdown.Extension):
def makeFootnoteId(self, id):
""" Return footnote link id. """
if self.getConfig("UNIQUE_IDS"):
- return 'fn:%d-%s' % (self.unique_prefix, id)
+ return 'fn%s%d-%s' % (self.sep, self.unique_prefix, id)
else:
- return 'fn:%s' % id
+ return 'fn%s%s' % (self.sep, id)
def makeFootnoteRefId(self, id):
""" Return footnote back-link id. """
if self.getConfig("UNIQUE_IDS"):
- return 'fnref:%d-%s' % (self.unique_prefix, id)
+ return 'fnref%s%d-%s' % (self.sep, self.unique_prefix, id)
else:
- return 'fnref:%s' % id
+ return 'fnref%s%s' % (self.sep, id)
def makeFootnotesDiv(self, root):
""" Return div of footnotes as et Element. """
@@ -171,7 +174,6 @@ class FootnotePreprocessor(markdown.preprocessors.Preprocessor):
"""
newlines = []
i = 0
- #import pdb; pdb.set_trace() #for i, line in enumerate(lines):
while True:
m = DEF_RE.match(lines[i])
if m: