From 41cc055580d63ffb7eb2bbb6c88e121727d91d06 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Fri, 8 Feb 2013 10:54:40 -0500 Subject: Footnote ids contain dashes when outputing HTML5. Previously they contained colons - and they still do for HTML4 and XHTML. Fixes #180. --- docs/release-2.3.txt | 6 ++++++ markdown/__init__.py | 2 +- markdown/extensions/footnotes.py | 12 +++++++----- 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), "