aboutsummaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--docs/release-2.3.txt6
-rw-r--r--markdown/__init__.py2
-rw-r--r--markdown/extensions/footnotes.py12
3 files changed, 14 insertions, 6 deletions
diff --git a/docs/release-2.3.txt b/docs/release-2.3.txt
index 3255f74..9c53d12 100644
--- a/docs/release-2.3.txt
+++ b/docs/release-2.3.txt
@@ -23,6 +23,12 @@ The whitelesited schemes are: 'http', 'https', 'ftp', 'ftps', 'mailto',
'news'. Schemeless urls are also permitted, but are checked in other ways -
as they have been for some time.
+* The ids assigned to footnotes now contain a dash (`-`) rather than a colon
+(`:`) when `output_format` it set to "html5" or "xhtml5". If you are making
+reference to those ids in your JavaScript or CSS and using the HTML5 output,
+you will need to update your code accordingly. No changes are necessary if
+you are outputing XHTML (the default) or HTML4.
+
What's New in Python-Markdown 2.3
---------------------------------
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: