diff --git a/INSTALL.md b/INSTALL.md index 6e6ab8c7..42e0c7ab 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1,9 +1,8 @@ -Installing Python-Markdown +Installing ZMArkdown ========================== As an Admin/Root user on your system do: - pip install markdown + pip install zmarkdown Or for more specific instructions, view the documentation in `docs/install.txt` -or on the website at . diff --git a/MANIFEST.in b/MANIFEST.in index 95a3ce28..5577d38f 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,5 @@ recursive-include bin * -recursive-include markdown *.py +recursive-include zmarkdown *.py recursive-include docs * recursive-include tests *.txt *.html *.cfg *.py include setup.py diff --git a/makefile b/makefile index 3945db6f..d2981e2f 100644 --- a/makefile +++ b/makefile @@ -38,14 +38,14 @@ clean: rm -f MANIFEST rm -f test-output.html rm -f *.pyc - rm -f markdown/*.pyc - rm -f markdown/extensions/*.pyc + rm -f zmarkdown/*.pyc + rm -f zmarkdown/extensions/*.pyc rm -f *.bak - rm -f markdown/*.bak - rm -f markdown/extensions/*.bak + rm -f zmarkdown/*.bak + rm -f zmarkdown/extensions/*.bak rm -f *.swp - rm -f markdown/*.swp - rm -f markdown/extensions/*.swp + rm -f zmarkdown/*.swp + rm -f zmarkdown/extensions/*.swp rm -rf build rm -rf dist rm -rf tmp diff --git a/setup.py b/setup.py index 0195c123..1cb9baeb 100755 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ def get_version(): " Get version & version_info without importing markdown.__init__ " - path = os.path.join(os.path.dirname(__file__), 'markdown') + path = os.path.join(os.path.dirname(__file__), 'zmarkdown') fp, pathname, desc = imp.find_module('__version__', [path]) try: v = imp.load_module('__version__', fp, pathname, desc) @@ -25,7 +25,6 @@ def get_version(): 'beta': '4 - Beta', 'rc': '4 - Beta', 'final': '5 - Production/Stable', - 'zds': '5 - Production/Stable' } if version_info[3] == 'alpha' and version_info[4] == 0: @@ -34,38 +33,20 @@ def get_version(): DEVSTATUS = dev_status_map[version_info[3]] long_description = ''' -This is a Python implementation of John Gruber's Markdown_. -It is almost completely compliant with the reference implementation, -though there are a few known issues. See Features_ for information -on what exactly is supported and what is not. Additional features are -supported by the `Available Extensions`_. - -.. _Markdown: http://daringfireball.net/projects/markdown/ -.. _Features: https://pythonhosted.org/Markdown/index.html#Features -.. _`Available Extensions`: https://pythonhosted.org/Markdown/extensions/index.html - -Support -======= - -You may ask for help and discuss various other issues on the -`mailing list`_ and report bugs on the `bug tracker`_. - -.. _`mailing list`: http://lists.sourceforge.net/lists/listinfo/python-markdown-discuss -.. _`bug tracker`: http://github.com/waylan/Python-Markdown/issues +Small fork of Python-Markdown suitable for zestedesavoir.com needs ''' setup(name='Markdown', version=version, - url='https://pythonhosted.org/Markdown/', - download_url='http://pypi.python.org/packages/source/M/Markdown/Markdown-%s.tar.gz' % version, + url='https://github.com/zestedesavoir/Python-ZMarkdown', description='Python implementation of Markdown.', long_description=long_description, - author='Manfred Stienstra, Yuri takhteyev and Waylan limberg', - author_email='waylan.limberg [at] icloud.com', - maintainer='Waylan Limberg', - maintainer_email='waylan.limberg [at] icloud.com', + author='Manfred Stienstra, Yuri takhteyev, Waylan limberg and zeste de savoir members', + author_email='christophe.gabard [at] gmail.com', + maintainer='Christophe Gabard', + maintainer_email='christophe.gabard [at] gmail.com', license='BSD License', - packages=['markdown', 'markdown.extensions'], + packages=['zmarkdown', 'zmarkdown.extensions'], classifiers=['Development Status :: %s' % DEVSTATUS, 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', diff --git a/tests/__init__.py b/tests/__init__.py index 6ab6da33..24f82f04 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,5 +1,5 @@ import os -import markdown +import zmarkdown import codecs import difflib try: @@ -11,7 +11,7 @@ e.args = (msg,) + e.args[1:] raise -from .plugins import Markdown, MarkdownSyntaxError +from .plugins import ZMarkdown, ZMarkdownSyntaxError try: import tidylib except ImportError: @@ -112,7 +112,7 @@ def __call__(self, file, config): # Normalize line endings # (on windows, git may have altered line endings). expected_output = f.read().replace("\r\n", "\n") - output = markdown.markdown(input, **config.get_args(file)) + output = zmarkdown.zmarkdown(input, **config.get_args(file)) expected_output = expected_output.strip() output = output.strip() if tidylib and config.get(cfg_section, 'normalize'): @@ -133,7 +133,7 @@ def __call__(self, file, config): lineterm="\n" )] if diff: - raise MarkdownSyntaxError( + raise ZMarkdownSyntaxError( 'Output from "%s" failed to match expected ' 'output.\n\n%s' % (input_file, ''.join(diff)) ) @@ -165,8 +165,8 @@ def generate(file, config): if not os.path.isfile(output_file) or \ os.path.getmtime(output_file) < os.path.getmtime(input_file): print('Generating:', file) - markdown.markdownFromFile(input=input_file, output=output_file, - encoding='utf-8', **config.get_args(file)) + zmarkdown.zmarkdownFromFile(input=input_file, output=output_file, + encoding='utf-8', **config.get_args(file)) else: print('Already up-to-date:', file) @@ -184,4 +184,4 @@ def generate_all(): def run(): - nose.main(addplugins=[Markdown()]) + nose.main(addplugins=[ZMarkdown()]) diff --git a/tests/extensions/extra/test.cfg b/tests/extensions/extra/test.cfg index 5e463692..457aa969 100644 --- a/tests/extensions/extra/test.cfg +++ b/tests/extensions/extra/test.cfg @@ -1,23 +1,23 @@ DEFAULT: extensions: - - markdown.extensions.footnotes + - zmarkdown.extensions.footnotes abbr: extensions: - - markdown.extensions.abbr + - zmarkdown.extensions.abbr footnotes: extensions: - - markdown.extensions.footnotes + - zmarkdown.extensions.footnotes tables: extensions: - - markdown.extensions.tables + - zmarkdown.extensions.tables extra_config: extensions: - - markdown.extensions.footnotes + - zmarkdown.extensions.footnotes extension_configs: - markdown.extensions.footnotes: + zmarkdown.extensions.footnotes: PLACE_MARKER: ~~~placemarker~~~ unique_prefix: zds diff --git a/tests/extensions/test.cfg b/tests/extensions/test.cfg index da25b392..6ff8d568 100644 --- a/tests/extensions/test.cfg +++ b/tests/extensions/test.cfg @@ -1,13 +1,13 @@ codehilite: extensions: - - markdown.extensions.codehilite + - zmarkdown.extensions.codehilite # This passes or not based on version of pygments. skip: True fenced_code: extensions: - - markdown.extensions.fenced_code + - zmarkdown.extensions.fenced_code github_flavored: extensions: - - markdown.extensions.fenced_code + - zmarkdown.extensions.fenced_code diff --git a/tests/plugins.py b/tests/plugins.py index 01484dd8..841a7b4d 100644 --- a/tests/plugins.py +++ b/tests/plugins.py @@ -5,15 +5,15 @@ import six -class MarkdownSyntaxError(Exception): +class ZMarkdownSyntaxError(Exception): pass -class Markdown(ErrorClassPlugin): +class ZMarkdown(ErrorClassPlugin): """ Add MarkdownSyntaxError and ensure proper formatting. """ mdsyntax = ErrorClass( - MarkdownSyntaxError, - label='MarkdownSyntaxError', + ZMarkdownSyntaxError, + label='ZMarkdownSyntaxError', isfailure=True ) enabled = True diff --git a/tests/test_apis.py b/tests/test_apis.py index d69f6814..f98f840f 100644 --- a/tests/test_apis.py +++ b/tests/test_apis.py @@ -11,7 +11,7 @@ import unittest import sys import types -import markdown +import zmarkdown import warnings PY3 = sys.version_info[0] == 3 @@ -22,7 +22,7 @@ class TestMarkdownBasics(unittest.TestCase): def setUp(self): """ Create instance of Markdown. """ - self.md = markdown.Markdown() + self.md = zmarkdown.ZMarkdown() def testBlankInput(self): """ Test blank input. """ @@ -38,16 +38,16 @@ def testSimpleInput(self): def testInstanceExtension(self): """ Test Extension loading with a class instance. """ - from markdown.extensions.footnotes import FootnoteExtension - markdown.Markdown(extensions=[FootnoteExtension()]) + from zmarkdown.extensions.footnotes import FootnoteExtension + zmarkdown.ZMarkdown(extensions=[FootnoteExtension()]) def testNamedExtension(self): """ Test Extension loading with Name (`path.to.module`). """ - markdown.Markdown(extensions=['markdown.extensions.footnotes']) + zmarkdown.ZMarkdown(extensions=['zmarkdown.extensions.footnotes']) def TestNamedExtensionWithClass(self): """ Test Extension loading with class name (`path.to.module:Class`). """ - markdown.Markdown(extensions=['markdown.extensions.footnotes:FootnoteExtension']) + zmarkdown.ZMarkdown(extensions=['zmarkdown.extensions.footnotes:FootnoteExtension']) class TestBlockParser(unittest.TestCase): @@ -55,15 +55,15 @@ class TestBlockParser(unittest.TestCase): def setUp(self): """ Create instance of BlockParser. """ - self.parser = markdown.Markdown().parser + self.parser = zmarkdown.ZMarkdown().parser def testParseChunk(self): """ Test BlockParser.parseChunk. """ - root = markdown.util.etree.Element("div") + root = zmarkdown.util.etree.Element("div") text = 'foo' self.parser.parseChunk(root, text) self.assertEqual( - markdown.serializers.to_html_string(root), + zmarkdown.serializers.to_html_string(root), "

foo

" ) @@ -71,10 +71,10 @@ def testParseDocument(self): """ Test BlockParser.parseDocument. """ lines = ['#foo', '', 'bar', '', ' baz'] tree = self.parser.parseDocument(lines) - self.assertTrue(isinstance(tree, markdown.util.etree.ElementTree)) - self.assertTrue(markdown.util.etree.iselement(tree.getroot())) + self.assertTrue(isinstance(tree, zmarkdown.util.etree.ElementTree)) + self.assertTrue(zmarkdown.util.etree.iselement(tree.getroot())) self.assertEqual( - markdown.serializers.to_html_string(tree.getroot()), + zmarkdown.serializers.to_html_string(tree.getroot()), "

foo

bar

baz\n
" ) @@ -83,7 +83,7 @@ class TestBlockParserState(unittest.TestCase): """ Tests of the State class for BlockParser. """ def setUp(self): - self.state = markdown.blockparser.State() + self.state = zmarkdown.blockparser.State() def testBlankState(self): """ Test State when empty. """ @@ -121,7 +121,7 @@ class TestHtmlStash(unittest.TestCase): """ Test Markdown's HtmlStash. """ def setUp(self): - self.stash = markdown.util.HtmlStash() + self.stash = zmarkdown.util.HtmlStash() self.placeholder = self.stash.store('foo') def testSimpleStore(self): @@ -156,19 +156,19 @@ def testReset(self): def testUnsafeHtmlInSafeMode(self): """ Test that unsafe HTML gets escaped in safe_mode. """ - output = markdown.markdown('foo', extensions=[self.build_extension()]) + output = zmarkdown.zmarkdown('foo', extensions=[self.build_extension()]) self.assertEqual(output, '

<script>print("evil")</script>

') def build_extension(self): """ Build an extention that addes unsafe html to Stash in same_mode. """ - class Unsafe(markdown.treeprocessors.Treeprocessor): + class Unsafe(zmarkdown.treeprocessors.Treeprocessor): def run(self, root): el = root.find('p') - el.text = self.markdown.htmlStash.store('', safe=False) + el.text = self.zmarkdown.htmlStash.store('', safe=False) return root - class StoreUnsafeHtml(markdown.extensions.Extension): - def extendMarkdown(self, md, md_globals): + class StoreUnsafeHtml(zmarkdown.extensions.Extension): + def extendZMarkdown(self, md, md_globals): md.treeprocessors.add('unsafe', Unsafe(md), '_end') return StoreUnsafeHtml() @@ -178,7 +178,7 @@ class TestOrderedDict(unittest.TestCase): """ Test OrderedDict storage class. """ def setUp(self): - self.odict = markdown.odict.OrderedDict() + self.odict = zmarkdown.odict.OrderedDict() self.odict['first'] = 'This' self.odict['third'] = 'a' self.odict['fourth'] = 'self' @@ -337,28 +337,28 @@ def testNonUnicodeSource(self): """ Test falure on non-unicode source text. """ if sys.version_info < (3, 0): source = "foo".encode('utf-16') - self.assertRaises(UnicodeDecodeError, markdown.markdown, source) + self.assertRaises(UnicodeDecodeError, zmarkdown.zmarkdown, source) def testLoadExtensionFailure(self): """ Test failure of an extension to load. """ self.assertRaises( ImportError, - markdown.Markdown, extensions=['non_existant_ext'] + zmarkdown.ZMarkdown, extensions=['non_existant_ext'] ) def testLoadBadExtension(self): """ Test loading of an Extension with no makeExtension function. """ - self.assertRaises(AttributeError, markdown.Markdown, extensions=['markdown.util']) + self.assertRaises(AttributeError, zmarkdown.ZMarkdown, extensions=['zmarkdown.util']) def testNonExtension(self): """ Test loading a non Extension object as an extension. """ - self.assertRaises(TypeError, markdown.Markdown, extensions=[object]) + self.assertRaises(TypeError, zmarkdown.ZMarkdown, extensions=[object]) def testBaseExtention(self): """ Test that the base Extension class will raise NotImplemented. """ self.assertRaises( NotImplementedError, - markdown.Markdown, extensions=[markdown.extensions.Extension()] + zmarkdown.ZMarkdown, extensions=[zmarkdown.extensions.Extension()] ) def testMdxExtention(self): @@ -366,21 +366,21 @@ def testMdxExtention(self): _create_fake_extension(name='fake', use_old_style=True) self.assertRaises( DeprecationWarning, - markdown.Markdown, extensions=['fake'] + zmarkdown.ZMarkdown, extensions=['fake'] ) def testShortNameExtention(self): """ Test that using a short name raises a DeprecationWarning. """ self.assertRaises( DeprecationWarning, - markdown.Markdown, extensions=['footnotes'] + zmarkdown.ZMarkdown, extensions=['footnotes'] ) def testStringConfigExtention(self): """ Test that passing configs to an Extension in the name raises a DeprecationWarning. """ self.assertRaises( DeprecationWarning, - markdown.Markdown, extensions=['markdown.extension.footnotes(PLACE_MARKER=FOO)'] + zmarkdown.ZMarkdown, extensions=['zmarkdown.extension.footnotes(PLACE_MARKER=FOO)'] ) @@ -399,7 +399,7 @@ def makeExtension(*args, **kwargs): if is_wrong_type: return object else: - return markdown.extensions.Extension(*args, **kwargs) + return zmarkdown.extensions.Extension(*args, **kwargs) if has_factory_func: ext_mod.makeExtension = makeExtension @@ -422,33 +422,33 @@ class testETreeComments(unittest.TestCase): def setUp(self): # Create comment node - self.comment = markdown.util.etree.Comment('foo') - if hasattr(markdown.util.etree, 'test_comment'): - self.test_comment = markdown.util.etree.test_comment + self.comment = zmarkdown.util.etree.Comment('foo') + if hasattr(zmarkdown.util.etree, 'test_comment'): + self.test_comment = zmarkdown.util.etree.test_comment else: - self.test_comment = markdown.util.etree.Comment + self.test_comment = zmarkdown.util.etree.Comment def testCommentIsComment(self): """ Test that an ElementTree Comment passes the `is Comment` test. """ - self.assertTrue(self.comment.tag is markdown.util.etree.test_comment) + self.assertTrue(self.comment.tag is zmarkdown.util.etree.test_comment) def testCommentIsBlockLevel(self): """ Test that an ElementTree Comment is recognized as BlockLevel. """ - self.assertFalse(markdown.util.isBlockLevel(self.comment.tag)) + self.assertFalse(zmarkdown.util.isBlockLevel(self.comment.tag)) def testCommentSerialization(self): """ Test that an ElementTree Comment serializes properly. """ self.assertEqual( - markdown.serializers.to_html_string(self.comment), + zmarkdown.serializers.to_html_string(self.comment), '' ) def testCommentPrettify(self): """ Test that an ElementTree Comment is prettified properly. """ - pretty = markdown.treeprocessors.PrettifyTreeprocessor() + pretty = zmarkdown.treeprocessors.PrettifyTreeprocessor() pretty.run(self.comment) self.assertEqual( - markdown.serializers.to_html_string(self.comment), + zmarkdown.serializers.to_html_string(self.comment), '\n' ) @@ -456,12 +456,12 @@ def testCommentPrettify(self): class testElementTailTests(unittest.TestCase): """ Element Tail Tests """ def setUp(self): - self.pretty = markdown.treeprocessors.PrettifyTreeprocessor() + self.pretty = zmarkdown.treeprocessors.PrettifyTreeprocessor() def testBrTailNoNewline(self): """ Test that last
in tree has a new line tail """ - root = markdown.util.etree.Element('root') - br = markdown.util.etree.SubElement(root, 'br') + root = zmarkdown.util.etree.Element('root') + br = zmarkdown.util.etree.SubElement(root, 'br') self.assertEqual(br.tail, None) self.pretty.run(root) self.assertEqual(br.tail, "\n") @@ -472,24 +472,24 @@ class testSerializers(unittest.TestCase): def testHtml(self): """ Test HTML serialization. """ - el = markdown.util.etree.Element('div') - p = markdown.util.etree.SubElement(el, 'p') + el = zmarkdown.util.etree.Element('div') + p = zmarkdown.util.etree.SubElement(el, 'p') p.text = 'foo' - markdown.util.etree.SubElement(el, 'hr') + zmarkdown.util.etree.SubElement(el, 'hr') self.assertEqual( - markdown.serializers.to_html_string(el), + zmarkdown.serializers.to_html_string(el), '

foo


' ) def testMixedCaseTags(self): """" Test preservation of tag case. """ - el = markdown.util.etree.Element('MixedCase') + el = zmarkdown.util.etree.Element('MixedCase') el.text = 'not valid ' - em = markdown.util.etree.SubElement(el, 'EMPHASIS') + em = zmarkdown.util.etree.SubElement(el, 'EMPHASIS') em.text = 'html' - markdown.util.etree.SubElement(el, 'HR') + zmarkdown.util.etree.SubElement(el, 'HR') self.assertEqual( - markdown.serializers.to_html_string(el), + zmarkdown.serializers.to_html_string(el), 'not valid html
' ) @@ -498,48 +498,48 @@ class testAtomicString(unittest.TestCase): """ Test that AtomicStrings are honored (not parsed). """ def setUp(self): - md = markdown.Markdown() + md = zmarkdown.ZMarkdown() self.inlineprocessor = md.treeprocessors['inline'] def testString(self): """ Test that a regular string is parsed. """ - tree = markdown.util.etree.Element('div') - p = markdown.util.etree.SubElement(tree, 'p') + tree = zmarkdown.util.etree.Element('div') + p = zmarkdown.util.etree.SubElement(tree, 'p') p.text = 'some *text*' new = self.inlineprocessor.run(tree) self.assertEqual( - markdown.serializers.to_html_string(new), + zmarkdown.serializers.to_html_string(new), '

some text

' ) def testSimpleAtomicString(self): """ Test that a simple AtomicString is not parsed. """ - tree = markdown.util.etree.Element('div') - p = markdown.util.etree.SubElement(tree, 'p') - p.text = markdown.util.AtomicString('some *text*') + tree = zmarkdown.util.etree.Element('div') + p = zmarkdown.util.etree.SubElement(tree, 'p') + p.text = zmarkdown.util.AtomicString('some *text*') new = self.inlineprocessor.run(tree) self.assertEqual( - markdown.serializers.to_html_string(new), + zmarkdown.serializers.to_html_string(new), '

some *text*

' ) def testNestedAtomicString(self): """ Test that a nested AtomicString is not parsed. """ - tree = markdown.util.etree.Element('div') - p = markdown.util.etree.SubElement(tree, 'p') - p.text = markdown.util.AtomicString('*some* ') - span1 = markdown.util.etree.SubElement(p, 'span') - span1.text = markdown.util.AtomicString('*more* ') - span2 = markdown.util.etree.SubElement(span1, 'span') - span2.text = markdown.util.AtomicString('*text* ') - span3 = markdown.util.etree.SubElement(span2, 'span') - span3.text = markdown.util.AtomicString('*here*') - span3.tail = markdown.util.AtomicString(' *to*') - span2.tail = markdown.util.AtomicString(' *test*') - span1.tail = markdown.util.AtomicString(' *with*') + tree = zmarkdown.util.etree.Element('div') + p = zmarkdown.util.etree.SubElement(tree, 'p') + p.text = zmarkdown.util.AtomicString('*some* ') + span1 = zmarkdown.util.etree.SubElement(p, 'span') + span1.text = zmarkdown.util.AtomicString('*more* ') + span2 = zmarkdown.util.etree.SubElement(span1, 'span') + span2.text = zmarkdown.util.AtomicString('*text* ') + span3 = zmarkdown.util.etree.SubElement(span2, 'span') + span3.text = zmarkdown.util.AtomicString('*here*') + span3.tail = zmarkdown.util.AtomicString(' *to*') + span2.tail = zmarkdown.util.AtomicString(' *test*') + span1.tail = zmarkdown.util.AtomicString(' *with*') new = self.inlineprocessor.run(tree) self.assertEqual( - markdown.serializers.to_html_string(new), + zmarkdown.serializers.to_html_string(new), '

*some* *more* *text* *here* ' '*to* *test* *with*

' ) @@ -547,7 +547,7 @@ def testNestedAtomicString(self): class TestConfigParsing(unittest.TestCase): def assertParses(self, value, result): - self.assertTrue(markdown.util.parseBoolValue(value, False) is result) + self.assertTrue(zmarkdown.util.parseBoolValue(value, False) is result) def testBooleansParsing(self): self.assertParses(True, True) @@ -558,8 +558,8 @@ def testBooleansParsing(self): self.assertParses('none', False) def testPreserveNone(self): - self.assertTrue(markdown.util.parseBoolValue('None', preserve_none=True) is None) - self.assertTrue(markdown.util.parseBoolValue(None, preserve_none=True) is None) + self.assertTrue(zmarkdown.util.parseBoolValue('None', preserve_none=True) is None) + self.assertTrue(zmarkdown.util.parseBoolValue(None, preserve_none=True) is None) def testInvalidBooleansParsing(self): - self.assertRaises(ValueError, markdown.util.parseBoolValue, 'novalue') + self.assertRaises(ValueError, zmarkdown.util.parseBoolValue, 'novalue') diff --git a/tests/test_extensions.py b/tests/test_extensions.py index 9c8f25f0..0f459bf8 100644 --- a/tests/test_extensions.py +++ b/tests/test_extensions.py @@ -9,14 +9,14 @@ from __future__ import unicode_literals import unittest -import markdown +import zmarkdown class TestExtensionClass(unittest.TestCase): """ Test markdown.extensions.Extension. """ def setUp(self): - class TestExtension(markdown.extensions.Extension): + class TestExtension(zmarkdown.extensions.Extension): config = { 'foo': ['bar', 'Description of foo'], 'bar': ['baz', 'Description of bar'] @@ -61,7 +61,7 @@ class TestAbbr(unittest.TestCase): """ Test abbr extension. """ def setUp(self): - self.md = markdown.Markdown(extensions=['markdown.extensions.abbr']) + self.md = zmarkdown.ZMarkdown(extensions=['zmarkdown.extensions.abbr']) def testSimpleAbbr(self): """ Test Abbreviations. """ @@ -98,7 +98,7 @@ def setUp(self): def testBasicCodeHilite(self): text = '\t# A Code Comment' - md = markdown.Markdown(extensions=['markdown.extensions.codehilite']) + md = zmarkdown.ZMarkdown(extensions=['zmarkdown.extensions.codehilite']) if self.has_pygments: # Pygments can use random lexer here as we did not specify the language self.assertTrue(md.convert(text).startswith('
'))
@@ -111,8 +111,8 @@ def testBasicCodeHilite(self):
 
     def testLinenumsTrue(self):
         text = '\t# A Code Comment'
-        md = markdown.Markdown(
-            extensions=[markdown.extensions.codehilite.CodeHiliteExtension(linenums=True)])
+        md = zmarkdown.ZMarkdown(
+            extensions=[zmarkdown.extensions.codehilite.CodeHiliteExtension(linenums=True)])
         if self.has_pygments:
             # Different versions of pygments output slightly different markup.
             # So we use 'startwith' and test just enough to confirm that
@@ -131,8 +131,8 @@ def testLinenumsTrue(self):
 
     def testLinenumsFalse(self):
         text = '\t#!Python\n\t# A Code Comment'
-        md = markdown.Markdown(
-            extensions=[markdown.extensions.codehilite.CodeHiliteExtension(linenums=False)])
+        md = zmarkdown.ZMarkdown(
+            extensions=[zmarkdown.extensions.codehilite.CodeHiliteExtension(linenums=False)])
         if self.has_pygments:
             self.assertEqual(
                 md.convert(text),
@@ -150,8 +150,8 @@ def testLinenumsFalse(self):
 
     def testLinenumsNone(self):
         text = '\t# A Code Comment'
-        md = markdown.Markdown(
-            extensions=[markdown.extensions.codehilite.CodeHiliteExtension(linenums=None)])
+        md = zmarkdown.ZMarkdown(
+            extensions=[zmarkdown.extensions.codehilite.CodeHiliteExtension(linenums=None)])
         if self.has_pygments:
             # Pygments can use random lexer here as we did not specify the language
             self.assertTrue(md.convert(text).startswith('
'))
@@ -164,8 +164,8 @@ def testLinenumsNone(self):
 
     def testLinenumsNoneWithShebang(self):
         text = '\t#!Python\n\t# A Code Comment'
-        md = markdown.Markdown(
-            extensions=[markdown.extensions.codehilite.CodeHiliteExtension(linenums=None)])
+        md = zmarkdown.ZMarkdown(
+            extensions=[zmarkdown.extensions.codehilite.CodeHiliteExtension(linenums=None)])
         if self.has_pygments:
             # Differant versions of pygments output slightly different markup.
             # So we use 'startwith' and test just enough to confirm that
@@ -184,8 +184,8 @@ def testLinenumsNoneWithShebang(self):
 
     def testLinenumsNoneWithColon(self):
         text = '\t:::Python\n\t# A Code Comment'
-        md = markdown.Markdown(
-            extensions=[markdown.extensions.codehilite.CodeHiliteExtension(linenums=None)]
+        md = zmarkdown.ZMarkdown(
+            extensions=[zmarkdown.extensions.codehilite.CodeHiliteExtension(linenums=None)]
         )
         if self.has_pygments:
             self.assertEqual(
@@ -208,7 +208,7 @@ def testHighlightLinesWithColon(self):
         text1 = "\t:::Python hl_lines='2'\n\t#line 1\n\t#line 2\n\t#line 3"
 
         for text in (text0, text1):
-            md = markdown.Markdown(extensions=['markdown.extensions.codehilite'])
+            md = zmarkdown.ZMarkdown(extensions=['zmarkdown.extensions.codehilite'])
             if self.has_pygments:
                 self.assertEqual(
                     md.convert(text),
@@ -230,8 +230,8 @@ def testHighlightLinesWithColon(self):
 
     def testUsePygmentsFalse(self):
         text = '\t:::Python\n\t# A Code Comment'
-        md = markdown.Markdown(
-            extensions=[markdown.extensions.codehilite.CodeHiliteExtension(use_pygments=False)]
+        md = zmarkdown.ZMarkdown(
+            extensions=[zmarkdown.extensions.codehilite.CodeHiliteExtension(use_pygments=False)]
         )
         self.assertEqual(
             md.convert(text),
@@ -244,7 +244,7 @@ class TestFencedCode(unittest.TestCase):
     """ Test fenced_code extension. """
 
     def setUp(self):
-        self.md = markdown.Markdown(extensions=['markdown.extensions.fenced_code'])
+        self.md = zmarkdown.ZMarkdown(extensions=['zmarkdown.extensions.fenced_code'])
         self.has_pygments = True
         try:
             import pygments  # noqa
@@ -321,10 +321,10 @@ def testFencedCodeWithHighlightLines(self):
 line 2
 line 3
 ```'''
-        md = markdown.Markdown(
+        md = zmarkdown.ZMarkdown(
             extensions=[
-                markdown.extensions.codehilite.CodeHiliteExtension(linenums=None, guess_lang=False),
-                'markdown.extensions.fenced_code'
+                zmarkdown.extensions.codehilite.CodeHiliteExtension(linenums=None, guess_lang=False),
+                'zmarkdown.extensions.fenced_code'
             ]
         )
 
@@ -362,10 +362,10 @@ def testFencedLanguageAndHighlightLines(self):
 #line 3
 ~~~'''
         for text in (text0, text1):
-            md = markdown.Markdown(
+            md = zmarkdown.ZMarkdown(
                 extensions=[
-                    markdown.extensions.codehilite.CodeHiliteExtension(linenums=None, guess_lang=False),
-                    'markdown.extensions.fenced_code'
+                    zmarkdown.extensions.codehilite.CodeHiliteExtension(linenums=None, guess_lang=False),
+                    'zmarkdown.extensions.fenced_code'
                 ]
             )
             if self.has_pygments:
diff --git a/tests/test_zds.py b/tests/test_zds.py
index dc42e82d..20aeb23e 100644
--- a/tests/test_zds.py
+++ b/tests/test_zds.py
@@ -1,18 +1,18 @@
 # -*- encoding: utf-8 -*-
 from __future__ import unicode_literals
 import unittest
-import markdown
-from markdown.extensions.header_dec import DownHeaderExtension
-from markdown.extensions.zds import ZdsExtension
-from markdown.extensions.ping import PingExtension
-from markdown.extensions.french_typography import FrenchTypographyExtension
-from markdown.extensions.title_anchor import TitleAnchorExtension
+import zmarkdown
+from zmarkdown.extensions.header_dec import DownHeaderExtension
+from zmarkdown.extensions.zds import ZdsExtension
+from zmarkdown.extensions.ping import PingExtension
+from zmarkdown.extensions.french_typography import FrenchTypographyExtension
+from zmarkdown.extensions.title_anchor import TitleAnchorExtension
 
 
 class TestZDSExtensionClass(unittest.TestCase):
     def test_inline_mode(self):
         zds_ext = ZdsExtension(inline=True, emoticons={":D": "image.png"})
-        md = markdown.Markdown(extensions=[zds_ext])
+        md = zmarkdown.ZMarkdown(extensions=[zds_ext])
 
         # Basic conversion
         self.assertEqual(
@@ -21,7 +21,7 @@ def test_inline_mode(self):
                 'inline avec un lien

') zds_ext = ZdsExtension(inline=True, emoticons={":D": "image.png"}) - md = markdown.Markdown(extensions=[zds_ext]) + md = zmarkdown.ZMarkdown(extensions=[zds_ext]) # Complex elements should not be allowed self.assertEqual( md.convert('> ![Image](http://test.com/image.png)'), @@ -30,7 +30,7 @@ def test_inline_mode(self): def test_img_in_block(self): zds_ext = ZdsExtension(emoticons={":D": "image.png"}) - md = markdown.Markdown(extensions=[zds_ext]) + md = zmarkdown.ZMarkdown(extensions=[zds_ext]) self.assertEqual( md.convert('[[secret]]\n| ![Image utilisateur](http://www.glovedgirl.fr/Avatars/avatar-6.jpg)'), @@ -45,7 +45,7 @@ def ping_url(user=None): return '/membres/voir/{}/'.format(user) zds_ext = ZdsExtension(ping_url=ping_url) - md = markdown.Markdown(extensions=[zds_ext]) + md = zmarkdown.ZMarkdown(extensions=[zds_ext]) text = 'I want to ping @[Clem] and @[Zozor].' self.assertEqual( '

I want to ping @Clem and @[Zozor].

', @@ -54,7 +54,7 @@ def ping_url(user=None): self.assertEqual({"Clem"}, md.metadata["ping"]) def test_header_dec(self): - md = markdown.Markdown() + md = zmarkdown.ZMarkdown() text_ref = ('# Title 1\n' '## Title 2\n' '### Title 3\n' @@ -77,7 +77,7 @@ def test_header_dec(self): '
# Title 7
\n' '

Title 1b

\n' '

Title 2b

') - md = markdown.Markdown(extensions=[DownHeaderExtension(offset=1)]) + md = zmarkdown.ZMarkdown(extensions=[DownHeaderExtension(offset=1)]) self.assertEqual( md.convert(text_ref), '

Title 1

\n' @@ -89,7 +89,7 @@ def test_header_dec(self): '
## Title 7
\n' '

Title 1b

\n' '

Title 2b

') - md = markdown.Markdown(extensions=[DownHeaderExtension(offset=2)]) + md = zmarkdown.ZMarkdown(extensions=[DownHeaderExtension(offset=2)]) self.assertEqual( md.convert(text_ref), '

Title 1

\n' @@ -104,7 +104,7 @@ def test_header_dec(self): def test_typography(self): zds_ext = ZdsExtension(emoticons={":D": "image.png"}) - md = markdown.Markdown(extensions=[zds_ext]) + md = zmarkdown.ZMarkdown(extensions=[zds_ext]) self.assertEqual( """

Petit « essai » un peu plus << complet 'sur la typo' >""" @@ -137,7 +137,7 @@ class TestPing(unittest.TestCase): def testNoPing(self): """ No ping. """ - md = markdown.Markdown(extensions=[PingExtension()]) + md = zmarkdown.ZMarkdown(extensions=[PingExtension()]) text = 'I want to ping @[Clem].' self.assertEqual( '

I want to ping @[Clem].

', @@ -152,7 +152,7 @@ def ping_url(user=None): if user == 'Clem': return '/membres/voir/{}/'.format(user) - md = markdown.Markdown(extensions=[PingExtension(ping_url=ping_url)]) + md = zmarkdown.ZMarkdown(extensions=[PingExtension(ping_url=ping_url)]) text = 'I want to ping @[Clem] and @[Zozor].' self.assertEqual( '

I want to ping @Clem and @[Zozor].

', @@ -167,7 +167,7 @@ def ping_url(user=None): if user == 'Clem' or user == 'A member': return '/membres/voir/{}/'.format(user) - md = markdown.Markdown(extensions=[PingExtension(ping_url=ping_url)]) + md = zmarkdown.ZMarkdown(extensions=[PingExtension(ping_url=ping_url)]) text = 'I want to ping @[Clem], @[Zozor] and @[A member].' self.assertEqual( '

I want to ping @Clem, ' @@ -183,7 +183,7 @@ def ping_url(user=None): if user == 'Clem' or user == 'A member': return '/membres/voir/{}/'.format(user) - md = markdown.Markdown(extensions=[PingExtension(ping_url=ping_url)]) + md = zmarkdown.ZMarkdown(extensions=[PingExtension(ping_url=ping_url)]) text = 'I want to ping @Clem, @[Zozor] and @[A member].' self.assertEqual( '

I want to ping @Clem, ' @@ -199,7 +199,7 @@ def ping_url(user=None): if user == 'Clem' or user == 'A member': return '/membres/voir/{}/'.format(user) - md = markdown.Markdown(extensions=[PingExtension(ping_url=ping_url)]) + md = zmarkdown.ZMarkdown(extensions=[PingExtension(ping_url=ping_url)]) text = 'I want to@Clem, @[Zozor] and@[A member].' self.assertEqual('

' + text + '

', md.convert(text)) self.assertEqual(set(), md.metadata["ping"]) @@ -207,7 +207,7 @@ def ping_url(user=None): class TestTypography(unittest.TestCase): def setUp(self): - self.md = markdown.Markdown(extensions=[FrenchTypographyExtension()]) + self.md = zmarkdown.ZMarkdown(extensions=[FrenchTypographyExtension()]) def simple_comparison(self, src, result): self.assertEqual( @@ -287,7 +287,7 @@ def test_title_anchor(self): "> # Title 1\n\n" 'l\n') - md = markdown.Markdown(extensions=[]) + md = zmarkdown.ZMarkdown(extensions=[]) self.assertEqual( md.convert(text_ref), '

Title 1

\n' @@ -317,7 +317,7 @@ def test_title_anchor(self): '\n' '

l

') - md = markdown.Markdown(extensions=[TitleAnchorExtension()]) + md = zmarkdown.ZMarkdown(extensions=[TitleAnchorExtension()]) self.assertEqual( md.convert(text_ref), '

Title 1

\n' @@ -347,7 +347,7 @@ def test_title_anchor(self): '\n' '

l

') - md = markdown.Markdown(extensions=[TitleAnchorExtension(root_only=False)]) + md = zmarkdown.ZMarkdown(extensions=[TitleAnchorExtension(root_only=False)]) self.assertEqual( md.convert(text_ref), '

Title 1

\n' @@ -377,7 +377,7 @@ def test_title_anchor(self): '\n' '

l

') - md = markdown.Markdown(extensions=[TitleAnchorExtension(starting_title=2, ending_title=5)]) + md = zmarkdown.ZMarkdown(extensions=[TitleAnchorExtension(starting_title=2, ending_title=5)]) self.assertEqual( md.convert(text_ref), '

Title 1

\n' @@ -407,7 +407,7 @@ def test_title_anchor(self): '\n' '

l

') - md = markdown.Markdown(extensions=[TitleAnchorExtension(marker_key="zds")]) + md = zmarkdown.ZMarkdown(extensions=[TitleAnchorExtension(marker_key="zds")]) self.assertEqual( md.convert(text_ref), '

Title 1

\n' @@ -437,7 +437,7 @@ def test_title_anchor(self): '\n' '

l

') - md = markdown.Markdown(extensions=[TitleAnchorExtension(link_position="before")]) + md = zmarkdown.ZMarkdown(extensions=[TitleAnchorExtension(link_position="before")]) self.assertEqual( md.convert(text_ref), '

Title 1

\n' @@ -467,7 +467,7 @@ def test_title_anchor(self): '\n' '

l

') - md = markdown.Markdown(extensions=[TitleAnchorExtension(link_position="after")]) + md = zmarkdown.ZMarkdown(extensions=[TitleAnchorExtension(link_position="after")]) self.assertEqual( md.convert(text_ref), '

Title 1

\n' @@ -524,7 +524,7 @@ def test_toc(self): 'k\n' "> # Title 1\n\n" 'l\n') - md = markdown.Markdown(extensions=[TitleAnchorExtension(marker_key="zds", link_position="before")]) + md = zmarkdown.ZMarkdown(extensions=[TitleAnchorExtension(marker_key="zds", link_position="before")]) self.assertEqual( md.convert(text_ref), '

Title 1

\n' diff --git a/tests/zds/extensions/test.cfg b/tests/zds/extensions/test.cfg index 2288ca7f..f71d1890 100644 --- a/tests/zds/extensions/test.cfg +++ b/tests/zds/extensions/test.cfg @@ -1,53 +1,53 @@ video: extensions: - - markdown.extensions.video + - zmarkdown.extensions.video extension_configs: - markdown.extensions.video: + zmarkdown.extensions.video: js_support: True video_extra: extensions: - - markdown.extensions.video + - zmarkdown.extensions.video extension_configs: - markdown.extensions.video: + zmarkdown.extensions.video: js_support: False youtube_width: "100%" youtube_height: "100%" align: extensions: - - markdown.extensions.align + - zmarkdown.extensions.align urlize: extensions: - - markdown.extensions.urlize + - zmarkdown.extensions.urlize kbd: extensions: - - markdown.extensions.kbd + - zmarkdown.extensions.kbd mathjax: extensions: - - markdown.extensions.mathjax + - zmarkdown.extensions.mathjax delext: extensions: - - markdown.extensions.delext + - zmarkdown.extensions.delext subsuperscript: extensions: - - markdown.extensions.subsuperscript + - zmarkdown.extensions.subsuperscript comments: extensions: - - markdown.extensions.fenced_code - - markdown.extensions.comments + - zmarkdown.extensions.fenced_code + - zmarkdown.extensions.comments customblock: extensions: - - markdown.extensions.customblock + - zmarkdown.extensions.customblock extension_configs: - markdown.extensions.customblock: + zmarkdown.extensions.customblock: classes: { "s(ecret)?": "spoiler", "i(nformation)?": "information ico-after", @@ -58,22 +58,22 @@ customblock: comments_config: extensions: - - markdown.extensions.fenced_code - - markdown.extensions.comments + - zmarkdown.extensions.fenced_code + - zmarkdown.extensions.comments extension_configs: - markdown.extensions.comments: + zmarkdown.extensions.comments: start_tag: "%DEBUT%" end_tag: "%FIN%" grid_tables: extensions: - - markdown.extensions.grid_tables + - zmarkdown.extensions.grid_tables emoticons: extensions: - - markdown.extensions.emoticons + - zmarkdown.extensions.emoticons extension_configs: - markdown.extensions.emoticons: + zmarkdown.extensions.emoticons: emoticons: {':''(': /static/smileys/pleure.png, ':(': /static/smileys/triste.png, ':)': /static/smileys/smile.png, ':-(': /static/smileys/triste.png, ':-)': /static/smileys/smile.png, ':-D': /static/smileys/heureux.png, ':-O': /static/smileys/huh.png, ':-P': /static/smileys/langue.png, ':-o': /static/smileys/huh.png, @@ -90,18 +90,18 @@ emoticons: smart_legend: extensions: - - markdown.extensions.tables - - markdown.extensions.grid_tables - - markdown.extensions.video - - markdown.extensions.fenced_code - - markdown.extensions.mathjax - - markdown.extensions.smart_legend - - markdown.extensions.emoticons - - markdown.extensions.footnotes + - zmarkdown.extensions.tables + - zmarkdown.extensions.grid_tables + - zmarkdown.extensions.video + - zmarkdown.extensions.fenced_code + - zmarkdown.extensions.mathjax + - zmarkdown.extensions.smart_legend + - zmarkdown.extensions.emoticons + - zmarkdown.extensions.footnotes extension_configs: - markdown.extensions.video: + zmarkdown.extensions.video: js_support: True - markdown.extensions.emoticons: + zmarkdown.extensions.emoticons: emoticons: {':''(': /static/smileys/pleure.png, ':(': /static/smileys/triste.png, ':)': /static/smileys/smile.png, ':-(': /static/smileys/triste.png, ':-)': /static/smileys/smile.png, ':-D': /static/smileys/heureux.png, ':-O': /static/smileys/huh.png, ':-P': /static/smileys/langue.png, ':-o': /static/smileys/huh.png, @@ -114,4 +114,4 @@ smart_legend: ':soleil:': /static/smileys/soleil.png, ':waw:': /static/smileys/waw.png, ':zorro:': /static/smileys/zorro.png, ":\xB0": /static/smileys/siffle.png, ;): /static/smileys/clin.png, ;-): /static/smileys/clin.png, '>_<': /static/smileys/pinch.png, O_o: /static/smileys/blink.gif, '^(;,;)^': /static/smileys/cthulhu.png, - ^^: /static/smileys/hihi.png, o_O: /static/smileys/blink.gif} \ No newline at end of file + ^^: /static/smileys/hihi.png, o_O: /static/smileys/blink.gif} diff --git a/tests/zds/test.cfg b/tests/zds/test.cfg index a350ad11..bf9d06fe 100644 --- a/tests/zds/test.cfg +++ b/tests/zds/test.cfg @@ -1,8 +1,8 @@ DEFAULT: extensions: - - markdown.extensions.zds + - zmarkdown.extensions.zds extension_configs: - markdown.extensions.zds: + zmarkdown.extensions.zds: inline: False js_support: False enable_titles: True diff --git a/tox.ini b/tox.ini index 95a16ef2..75f2fc06 100644 --- a/tox.ini +++ b/tox.ini @@ -9,12 +9,12 @@ download_cache = False [testenv] deps = -rtest-requirements.txt -commands = coverage run --source=markdown {toxinidir}/run-tests.py {posargs} +commands = coverage run --source=zmarkdown {toxinidir}/run-tests.py {posargs} coverage report --show-missing [testenv:flake8] deps = flake8 -commands = flake8 {toxinidir}/markdown {toxinidir}/tests {toxinidir}/setup.py {toxinidir}/run-tests.py +commands = flake8 {toxinidir}/zmarkdown {toxinidir}/tests {toxinidir}/setup.py {toxinidir}/run-tests.py [testenv:checkspelling] deps = diff --git a/markdown/__init__.py b/zmarkdown/__init__.py similarity index 86% rename from markdown/__init__.py rename to zmarkdown/__init__.py index 590378ed..5d16029d 100644 --- a/markdown/__init__.py +++ b/zmarkdown/__init__.py @@ -1,33 +1,7 @@ """ -Python Markdown +Python ZMarkdown =============== -Python Markdown converts Markdown to HTML and can be used as a library or -called from the command line. - -## Basic usage as a module: - - import markdown - html = markdown.markdown(your_text_string) - -See for more -information and instructions on how to extend the functionality of -Python Markdown. Read that before you try modifying this file. - -## Authors and License - -Started by [Manfred Stienstra](http://www.dwerg.net/). Continued and -maintained by [Yuri Takhteyev](http://www.freewisdom.org), [Waylan -Limberg](http://achinghead.com/) and [Artem Yunusov](http://blog.splyer.com). - -Contact: markdown@freewisdom.org - -Copyright 2007-2013 The Python Markdown Project (v. 1.7 and later) -Copyright 200? Django Software Foundation (OrderedDict implementation) -Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b) -Copyright 2004 Manfred Stienstra (the original version) - -License: BSD (see LICENSE for details). """ from __future__ import absolute_import @@ -45,12 +19,12 @@ from .extensions import Extension from .serializers import to_html_string -__all__ = ['Markdown', 'markdown'] +__all__ = ['ZMarkdown', 'zmarkdown'] -logger = logging.getLogger('MARKDOWN') +logger = logging.getLogger('ZMARKDOWN') -class Markdown(object): +class ZMarkdown(object): """Convert Markdown to HTML.""" doc_tag = "div" # Element used to wrap document - later removed @@ -121,11 +95,11 @@ def registerExtensions(self, extensions, configs): if isinstance(ext, util.string_type): ext = self.build_extension(ext, configs.get(ext, {})) if isinstance(ext, Extension): - ext.extendMarkdown(self, globals()) + ext.extendZMarkdown(self, globals()) logger.debug('Successfully loaded extension "%s.%s".', ext.__class__.__module__, ext.__class__.__name__) elif ext is not None: - raise TypeError('Extension "%s.%s" must be of type: "markdown.Extension"' + raise TypeError('Extension "%s.%s" must be of type: "zmarkdown.Extension"' % (ext.__class__.__module__, ext.__class__.__name__)) return self @@ -152,7 +126,7 @@ def build_extension(self, ext_name, configs): 'pass an instance of the extension class to ' 'Markdown or use the "extension_configs" keyword. ' 'The current behavior will raise an error in version 2.7. ' - 'See the Release Notes for Python-Markdown version ' + 'See the Release Notes for ZMarkdown version ' '2.6 for more info.', DeprecationWarning) # Get class name (if provided): `path.to.module:ClassName` @@ -174,7 +148,7 @@ def build_extension(self, ext_name, configs): raise ImportError except ImportError: # Preppend `markdown.extensions.` to name - module_name = '.'.join(['markdown.extensions', ext_name]) + module_name = '.'.join(['zmarkdown.extensions', ext_name]) try: module = importlib.import_module(module_name) logger.debug('Successfuly imported extension module "%s".', module_name) @@ -184,7 +158,7 @@ def build_extension(self, ext_name, configs): 'notation (eg: "%s" instead of "%s"). The ' 'current behavior will raise an error in version ' '2.7. See the Release Notes for ' - 'Python-Markdown version 2.6 for more info.' % + 'ZMarkdown version 2.6 for more info.' % (module_name, ext_name), DeprecationWarning) except ImportError: @@ -193,13 +167,13 @@ def build_extension(self, ext_name, configs): try: module = importlib.import_module(module_name_old_style) logger.debug('Successfuly imported extension module "%s".', module_name_old_style) - warnings.warn('Markdown\'s behavior of prepending "mdx_" ' + warnings.warn('ZMarkdown\'s behavior of prepending "mdx_" ' 'to an extension name is deprecated. ' 'Use the full path to the ' 'extension with Python\'s dot notation ' '(eg: "%s" instead of "%s"). The current ' 'behavior will raise an error in version 2.7. ' - 'See the Release Notes for Python-Markdown ' + 'See the Release Notes for EMarkdown ' 'version 2.6 for more info.' % (module_name_old_style, ext_name), DeprecationWarning) @@ -273,7 +247,7 @@ def convert(self, source): source = util.text_type(source) except UnicodeDecodeError as e: # pragma: no cover # Customise error message while maintaining original trackback - e.reason += '. -- Note: Markdown only accepts unicode input!' + e.reason += '. -- Note: ZMarkdown only accepts unicode input!' raise # Split into lines and run the line preprocessors. @@ -303,7 +277,7 @@ def convert(self, source): output = '' else: # We have a serious problem - raise ValueError('Markdown failed to strip top-level ' + raise ValueError('ZMarkdown failed to strip top-level ' 'tags. Document=%r' % output.strip()) # Run the text post-processors @@ -315,10 +289,10 @@ def convert(self, source): # EXPORTED FUNCTIONS # ============================================================================= # -# Those are the only function we really mean to export: markdown() +# Those are the only function we really mean to export: zmarkdown() -def markdown(text, *args, **kwargs): +def zmarkdown(text, *args, **kwargs): """Convert a markdown string to HTML and return HTML as a unicode string. This is a shortcut function for `Markdown` class to cover the most @@ -333,5 +307,5 @@ def markdown(text, *args, **kwargs): Returns: An HTML document as a string. """ - md = Markdown(*args, **kwargs) + md = ZMarkdown(*args, **kwargs) return md.convert(text) diff --git a/markdown/__version__.py b/zmarkdown/__version__.py similarity index 80% rename from markdown/__version__.py rename to zmarkdown/__version__.py index df8d74ef..cdb19be6 100644 --- a/markdown/__version__.py +++ b/zmarkdown/__version__.py @@ -5,13 +5,13 @@ # (major, minor, micro, alpha/beta/rc/final, #) # (1, 1, 2, 'alpha', 0) => "1.1.2.dev" # (1, 2, 0, 'beta', 2) => "1.2b2" -version_info = (2, 6, 0, 'zds', 17) +version_info = (1, 0, 0, 'final', 0) def _get_version(): " Returns a PEP 386-compliant version number from version_info. " assert len(version_info) == 5 - assert version_info[3] in ('alpha', 'beta', 'rc', 'final', 'zds') + assert version_info[3] in ('alpha', 'beta', 'rc', 'final') parts = 2 if version_info[2] == 0 else 3 main = '.'.join(map(str, version_info[:parts])) @@ -21,7 +21,7 @@ def _get_version(): # TODO: maybe append some sort of git info here?? sub = '.dev' elif version_info[3] != 'final': - mapping = {'alpha': 'a', 'beta': 'b', 'rc': 'c', 'zds': 'post'} + mapping = {'alpha': 'a', 'beta': 'b', 'rc': 'c'} sub = mapping[version_info[3]] + str(version_info[4]) return str(main + sub) diff --git a/markdown/blockparser.py b/zmarkdown/blockparser.py similarity index 95% rename from markdown/blockparser.py rename to zmarkdown/blockparser.py index 257edf01..ae8d3822 100644 --- a/markdown/blockparser.py +++ b/zmarkdown/blockparser.py @@ -45,10 +45,10 @@ class BlockParser: looping through them and creating an ElementTree object. """ - def __init__(self, markdown): + def __init__(self, zmarkdown): self.blockprocessors = odict.OrderedDict() self.state = State() - self.markdown = markdown + self.zmarkdown = zmarkdown def parseDocument(self, lines): """ Parse a markdown document into an ElementTree. @@ -61,7 +61,7 @@ def parseDocument(self, lines): """ # Create a ElementTree from the lines - self.root = util.etree.Element(self.markdown.doc_tag) + self.root = util.etree.Element(self.zmarkdown.doc_tag) self.parseChunk(self.root, '\n'.join(lines)) return util.etree.ElementTree(self.root) @@ -77,7 +77,7 @@ def parseChunk(self, parent, text): Nothing is returned. """ - if self.markdown.inline: + if self.zmarkdown.inline: self.blockprocessors["paragraph"].run(parent, [text]) else: self.parseBlocks(parent, text.split('\n\n')) diff --git a/markdown/blockprocessors.py b/zmarkdown/blockprocessors.py similarity index 99% rename from markdown/blockprocessors.py rename to zmarkdown/blockprocessors.py index dadc1656..85f4d088 100644 --- a/markdown/blockprocessors.py +++ b/zmarkdown/blockprocessors.py @@ -19,7 +19,7 @@ from . import util from .blockparser import BlockParser -logger = logging.getLogger('MARKDOWN') +logger = logging.getLogger('ZMARKDOWN') def build_block_parser(md_instance): @@ -52,7 +52,7 @@ class BlockProcessor: def __init__(self, parser): self.parser = parser - self.tab_length = parser.markdown.tab_length + self.tab_length = parser.zmarkdown.tab_length def lastChild(self, parent): """ Return the last child of an etree element. """ @@ -162,7 +162,7 @@ def run(self, parent, blocks): if tm: lines.pop(0) t = tm.group(2) or tm.group(3) or tm.group(4) - self.parser.markdown.references[idd] = (link, t) + self.parser.zmarkdown.references[idd] = (link, t) else: new_text.append(line) blocks.insert(0, "\n".join(new_text[:-1])) diff --git a/markdown/extensions/__init__.py b/zmarkdown/extensions/__init__.py similarity index 95% rename from markdown/extensions/__init__.py rename to zmarkdown/extensions/__init__.py index 0b90d55e..14c933fc 100644 --- a/markdown/extensions/__init__.py +++ b/zmarkdown/extensions/__init__.py @@ -55,7 +55,7 @@ def setConfigs(self, items): for key, value in items: self.setConfig(key, value) - def extendMarkdown(self, md, md_globals): + def extendZMarkdown(self, md, md_globals): """ Add the various proccesors and patterns to the Markdown Instance. @@ -69,6 +69,6 @@ def extendMarkdown(self, md, md_globals): """ raise NotImplementedError( - 'Extension "%s.%s" must define an "extendMarkdown"' + 'Extension "%s.%s" must define an "extendZMarkdown"' 'method.' % (self.__class__.__module__, self.__class__.__name__) ) diff --git a/markdown/extensions/abbr.py b/zmarkdown/extensions/abbr.py similarity index 93% rename from markdown/extensions/abbr.py rename to zmarkdown/extensions/abbr.py index c9fc9ae8..f4d50846 100644 --- a/markdown/extensions/abbr.py +++ b/zmarkdown/extensions/abbr.py @@ -19,7 +19,7 @@ from __future__ import absolute_import from __future__ import unicode_literals from . import Extension -from markdown.blockprocessors import BlockProcessor +from zmarkdown.blockprocessors import BlockProcessor from ..inlinepatterns import Pattern from ..util import etree, AtomicString import re @@ -31,7 +31,7 @@ class AbbrExtension(Extension): """ Abbreviation Extension for Python-Markdown. """ - def extendMarkdown(self, md, md_globals): + def extendZMarkdown(self, md, md_globals): """ Insert AbbrPreprocessor before ReferencePreprocessor. """ md.parser.blockprocessors.add('abbr', AbbrBlockprocessor(md), 'reference') diff --git a/markdown/extensions/codehilite.py b/zmarkdown/extensions/codehilite.py similarity index 97% rename from markdown/extensions/codehilite.py rename to zmarkdown/extensions/codehilite.py index 4f4b9f06..8e04805b 100644 --- a/markdown/extensions/codehilite.py +++ b/zmarkdown/extensions/codehilite.py @@ -240,10 +240,10 @@ def run(self, root): css_class=self.config['css_class'], style=self.config['pygments_style'], noclasses=self.config['noclasses'], - tab_length=self.markdown.tab_length, + tab_length=self.zmarkdown.tab_length, use_pygments=self.config['use_pygments']) - placeholder = self.markdown.htmlStash.store(code.hilite(), - safe=True) + placeholder = self.zmarkdown.htmlStash.store(code.hilite(), + safe=True) # Clear codeblock in etree instance block.clear() # Change to p element which will later @@ -279,7 +279,7 @@ def __init__(self, *args, **kwargs): super(CodeHiliteExtension, self).__init__(*args, **kwargs) - def extendMarkdown(self, md, md_globals): + def extendZMarkdown(self, md, md_globals): """ Add HilitePostprocessor to Markdown instance. """ hiliter = HiliteTreeprocessor(md) hiliter.config = self.getConfigs() diff --git a/markdown/extensions/comments.py b/zmarkdown/extensions/comments.py similarity index 90% rename from markdown/extensions/comments.py rename to zmarkdown/extensions/comments.py index 1c0c5735..4828104e 100644 --- a/markdown/extensions/comments.py +++ b/zmarkdown/extensions/comments.py @@ -1,6 +1,6 @@ import re -from markdown.blockprocessors import BlockProcessor -from markdown.extensions import Extension +from zmarkdown.blockprocessors import BlockProcessor +from zmarkdown.extensions import Extension class CommentsExtension(Extension): @@ -9,7 +9,7 @@ def __init__(self, *args, **kwargs): "end_tag": ["COMMENTS-->", ""]} Extension.__init__(self, *args, **kwargs) - def extendMarkdown(self, md, md_globals): + def extendZMarkdown(self, md, md_globals): md.registerExtension(self) md.parser.blockprocessors.add("comments", CommentsBlockProcessor(md, self.getConfig("start_tag"), diff --git a/markdown/extensions/customblock.py b/zmarkdown/extensions/customblock.py similarity index 92% rename from markdown/extensions/customblock.py rename to zmarkdown/extensions/customblock.py index a451d99d..0a8e141f 100644 --- a/markdown/extensions/customblock.py +++ b/zmarkdown/extensions/customblock.py @@ -1,7 +1,7 @@ from __future__ import unicode_literals -from markdown import Extension -from markdown.blockprocessors import BlockProcessor -from markdown.util import etree +from zmarkdown import Extension +from zmarkdown.blockprocessors import BlockProcessor +from zmarkdown.util import etree import re @@ -14,7 +14,7 @@ def __init__(self, *args, **kwargs): } Extension.__init__(self, *args, **kwargs) - def extendMarkdown(self, md, md_globals): + def extendZMarkdown(self, md, md_globals): """ Add CustomBlock to Markdown instance. """ md.registerExtension(self) diff --git a/markdown/extensions/delext.py b/zmarkdown/extensions/delext.py similarity index 74% rename from markdown/extensions/delext.py rename to zmarkdown/extensions/delext.py index f0b6ca5c..859ee0b6 100755 --- a/markdown/extensions/delext.py +++ b/zmarkdown/extensions/delext.py @@ -2,8 +2,8 @@ # Inspired by https://github.com/aleray/mdx_del_ins/blob/master/mdx_del_ins.py -from markdown.extensions import Extension -from markdown.inlinepatterns import SimpleTagPattern +from zmarkdown.extensions import Extension +from zmarkdown.inlinepatterns import SimpleTagPattern DEL_RE = r"(\~\~)(.+?)(\~\~)" @@ -11,7 +11,7 @@ class DelExtension(Extension): """Adds del extension to Markdown class.""" - def extendMarkdown(self, md, md_globals): + def extendZMarkdown(self, md, md_globals): """Modifies inline patterns.""" md.inlinePatterns.add('del', SimpleTagPattern(DEL_RE, 'del'), '#{1,%d})(?P
.*?)#*(\n|$)' % (6 - self.getConfig("offset"))) md.treeprocessors.add('downheader', DownHeaderProcessor(self.getConfig("offset")), '_end') -class DownHeaderProcessor(markdown.treeprocessors.Treeprocessor): +class DownHeaderProcessor(zmarkdown.treeprocessors.Treeprocessor): def __init__(self, offset=1): - markdown.treeprocessors.Treeprocessor.__init__(self) + zmarkdown.treeprocessors.Treeprocessor.__init__(self) self.offset = offset def run(self, node): diff --git a/markdown/extensions/kbd.py b/zmarkdown/extensions/kbd.py similarity index 73% rename from markdown/extensions/kbd.py rename to zmarkdown/extensions/kbd.py index a233f289..4af7bc8a 100755 --- a/markdown/extensions/kbd.py +++ b/zmarkdown/extensions/kbd.py @@ -1,7 +1,7 @@ #! /usr/bin/env python -from markdown.extensions import Extension -from markdown.inlinepatterns import SimpleTagPattern +from zmarkdown.extensions import Extension +from zmarkdown.inlinepatterns import SimpleTagPattern # Small extension to parse ||Touche|| in Kbd html tag @@ -11,7 +11,7 @@ class KbdExtension(Extension): """Adds kdb extension to Markdown class.""" - def extendMarkdown(self, md, md_globals): + def extendZMarkdown(self, md, md_globals): """Modifies inline patterns.""" md.inlinePatterns.add('kbd', SimpleTagPattern(KBD_RE, 'kbd'), 'reference') diff --git a/markdown/extensions/ping.py b/zmarkdown/extensions/ping.py similarity index 80% rename from markdown/extensions/ping.py rename to zmarkdown/extensions/ping.py index d9f54f27..88de1e05 100644 --- a/markdown/extensions/ping.py +++ b/zmarkdown/extensions/ping.py @@ -1,5 +1,5 @@ -import markdown -from markdown.inlinepatterns import Pattern +import zmarkdown +from zmarkdown.inlinepatterns import Pattern PING_RE = (r'(?.*)" @@ -86,7 +86,7 @@ class SmartLegendExtension(Extension): def __init__(self, *args, **kwargs): Extension.__init__(self, *args, **kwargs) - def extendMarkdown(self, md, md_globals): + def extendZMarkdown(self, md, md_globals): md.registerExtension(self) md.parser.blockprocessors.add('auto-figure', AutoFigureProcessor(md), '_begin') md.parser.blockprocessors['quote'] = InnerProcessor(md, "Source", md.parser.blockprocessors['quote']) diff --git a/markdown/extensions/subsuperscript.py b/zmarkdown/extensions/subsuperscript.py similarity index 91% rename from markdown/extensions/subsuperscript.py rename to zmarkdown/extensions/subsuperscript.py index 752ec4d8..aeccb61e 100755 --- a/markdown/extensions/subsuperscript.py +++ b/zmarkdown/extensions/subsuperscript.py @@ -1,6 +1,6 @@ # Inspired by https://github.com/sgraber/markdown.subscript/blob/master/subscript.py -from markdown import inlinepatterns, Extension, util +from zmarkdown import inlinepatterns, Extension, util # Global Vars SUBSCRIPT_RE = r'(\~)(.+?)(\~)' @@ -24,7 +24,7 @@ def handleMatch(self, m): class SubSuperscriptExtension(Extension): """ Subscript and superscript Extension for Python-Markdown. """ - def extendMarkdown(self, md, md_globals): + def extendZMarkdown(self, md, md_globals): """ Replace subscript with SubscriptPattern """ md.inlinePatterns['subscript'] = SubSuperscriptPattern(SUBSCRIPT_RE, md, "sub") md.inlinePatterns['superscript'] = SubSuperscriptPattern(SUPERSCRIPT_RE, md, "sup") diff --git a/markdown/extensions/tables.py b/zmarkdown/extensions/tables.py similarity index 98% rename from markdown/extensions/tables.py rename to zmarkdown/extensions/tables.py index 7122f057..f00fa5be 100644 --- a/markdown/extensions/tables.py +++ b/zmarkdown/extensions/tables.py @@ -93,7 +93,7 @@ def _split_row(self, row, border): class TableExtension(Extension): """ Add tables to Markdown. """ - def extendMarkdown(self, md, md_globals): + def extendZMarkdown(self, md, md_globals): """ Add an instance of TableProcessor to BlockParser. """ md.parser.blockprocessors.add('table', TableProcessor(md.parser), diff --git a/markdown/extensions/title_anchor.py b/zmarkdown/extensions/title_anchor.py similarity index 95% rename from markdown/extensions/title_anchor.py rename to zmarkdown/extensions/title_anchor.py index fdb2641f..a016e672 100644 --- a/markdown/extensions/title_anchor.py +++ b/zmarkdown/extensions/title_anchor.py @@ -34,13 +34,13 @@ def __init__(self, config, md): self.link_position = self.config.get('link_position', None) - Treeprocessor.__init__(self, markdown_instance=md) + Treeprocessor.__init__(self, zmarkdown_instance=md) self.reset() def reset(self): self.anchors = set() - self.markdown.metadata["toc"] = [] + self.zmarkdown.metadata["toc"] = [] def get_anchor_key(self, title): slug = slugify(title, "-") @@ -94,7 +94,7 @@ def run(self, root): for element, title_element in toc: self.add_anchor(element, title_element) self.add_link(element, title_element) - self.markdown.metadata["toc"] = [e for _, e in toc] + self.zmarkdown.metadata["toc"] = [e for _, e in toc] class TitleAnchorExtension(Extension): @@ -119,7 +119,7 @@ def reset(self): if self.ext is not None: self.ext.reset() - def extendMarkdown(self, md, md_globals): + def extendZMarkdown(self, md, md_globals): md.registerExtension(self) self.ext = TitleAnchorTreeprocessor(self.getConfigs(), md) md.treeprocessors.add("title_anchor", self.ext, "_end") diff --git a/markdown/extensions/urlize.py b/zmarkdown/extensions/urlize.py similarity index 89% rename from markdown/extensions/urlize.py rename to zmarkdown/extensions/urlize.py index 9aef2926..279088e9 100755 --- a/markdown/extensions/urlize.py +++ b/zmarkdown/extensions/urlize.py @@ -1,8 +1,8 @@ # Inspired by https://github.com/r0wb0t/markdown-urlize/blob/master/urlize.py from __future__ import unicode_literals -from markdown.inlinepatterns import Pattern as InlinePattern, sanitize_url, MAIL_RE -from markdown import Extension, util +from zmarkdown.inlinepatterns import Pattern as InlinePattern, sanitize_url, MAIL_RE +from zmarkdown import Extension, util try: # pragma: no cover from urllib.parse import urlparse except ImportError: # pragma: no cover @@ -59,7 +59,7 @@ def handleMatch(self, m): class UrlizeExtension(Extension): """ Urlize Extension for Python-Markdown. """ - def extendMarkdown(self, md, md_globals): + def extendZMarkdown(self, md, md_globals): """ Replace autolink with UrlizePattern """ md.inlinePatterns['autolink'] = UrlizePattern(URLIZE_RE, md) diff --git a/markdown/extensions/video.py b/zmarkdown/extensions/video.py similarity index 96% rename from markdown/extensions/video.py rename to zmarkdown/extensions/video.py index 8ed9f192..09f69c5f 100644 --- a/markdown/extensions/video.py +++ b/zmarkdown/extensions/video.py @@ -1,14 +1,14 @@ #!/usr/bin/env python -import markdown -from markdown.util import etree -from markdown.blockprocessors import BlockProcessor +import zmarkdown +from zmarkdown.util import etree +from zmarkdown.blockprocessors import BlockProcessor import re -class VideoExtension(markdown.Extension): +class VideoExtension(zmarkdown.Extension): def __init__(self, js_support=False, **kwargs): - markdown.Extension.__init__(self) + zmarkdown.Extension.__init__(self) self.config = { 'dailymotion_width': ['480', 'Width for Dailymotion videos'], @@ -44,7 +44,7 @@ def add_inline(self, md, name, klass, pat): self.config["{}_height".format(name)][0]), ">reference") - def extendMarkdown(self, md, md_globals): + def extendZMarkdown(self, md, md_globals): self.add_inline(md, 'dailymotion', Dailymotion, r'https?://www\.dailymotion\.com/video/(?P[a-z0-9]+)(_[\w\-]*)?') self.add_inline(md, 'vimeo', Vimeo, diff --git a/markdown/extensions/zds.py b/zmarkdown/extensions/zds.py similarity index 99% rename from markdown/extensions/zds.py rename to zmarkdown/extensions/zds.py index 31564324..d6da2a8f 100644 --- a/markdown/extensions/zds.py +++ b/zmarkdown/extensions/zds.py @@ -95,7 +95,7 @@ def _create_non_inline_extension(self): exts.append(title_anchor_ext) return exts - def extendMarkdown(self, md, md_globals): + def extendZMarkdown(self, md, md_globals): """ Register extension instances. """ config = self.getConfigs() self.inline = config.get("inline", True) diff --git a/markdown/inlinepatterns.py b/zmarkdown/inlinepatterns.py similarity index 96% rename from markdown/inlinepatterns.py rename to zmarkdown/inlinepatterns.py index 9bd05af4..a745fe5e 100644 --- a/markdown/inlinepatterns.py +++ b/zmarkdown/inlinepatterns.py @@ -176,7 +176,7 @@ def attributeCallback(match): class Pattern(object): """Base class that inline patterns subclass. """ - def __init__(self, pattern, markdown_instance=None, not_in=()): + def __init__(self, pattern, zmarkdown_instance=None, not_in=()): """ Create an instant of an inline pattern. @@ -192,8 +192,8 @@ def __init__(self, pattern, markdown_instance=None, not_in=()): # Api for Markdown to pass safe_mode into instance self.safe_mode = False self.not_in = not_in - if markdown_instance: - self.markdown = markdown_instance + if zmarkdown_instance: + self.zmarkdown = zmarkdown_instance def getCompiledRegExp(self): """ Return a compiled regular expression. """ @@ -218,7 +218,7 @@ def type(self): def unescape(self, text): """ Return unescaped text given text with an inline placeholder. """ try: - stash = self.markdown.treeprocessors['inline'].stashed_nodes + stash = self.zmarkdown.treeprocessors['inline'].stashed_nodes except KeyError: # pragma: no cover return text @@ -260,7 +260,7 @@ class EscapePattern(Pattern): def handleMatch(self, m): char = m.group(2) - if char in self.markdown.ESCAPED_CHARS: + if char in self.zmarkdown.ESCAPED_CHARS: return '%s%s%s' % (util.STX, ord(char), util.ETX) else: return None @@ -325,13 +325,13 @@ class HtmlPattern(Pattern): def handleMatch(self, m): rawhtml = self.unescape(m.group(2)) - place_holder = self.markdown.htmlStash.store(rawhtml) + place_holder = self.zmarkdown.htmlStash.store(rawhtml) return place_holder def unescape(self, text): """ Return unescaped text given text with an inline placeholder. """ try: - stash = self.markdown.treeprocessors['inline'].stashed_nodes + stash = self.zmarkdown.treeprocessors['inline'].stashed_nodes except KeyError: # pragma: no cover return text @@ -340,7 +340,7 @@ def get_stash(m): value = stash.get(idd) if value is not None: try: - return self.markdown.serializer(value) + return self.zmarkdown.serializer(value) except: return '\%s' % value @@ -459,9 +459,9 @@ def handleMatch(self, m): # Clean up linebreaks in id idd = self.NEWLINE_CLEANUP_RE.sub(' ', idd) - if idd not in self.markdown.references: # ignore undefined refs + if idd not in self.zmarkdown.references: # ignore undefined refs return None - href, title = self.markdown.references[idd] + href, title = self.zmarkdown.references[idd] text = m.group(2) return self.makeTag(href, title, text) diff --git a/markdown/odict.py b/zmarkdown/odict.py similarity index 100% rename from markdown/odict.py rename to zmarkdown/odict.py diff --git a/markdown/postprocessors.py b/zmarkdown/postprocessors.py similarity index 90% rename from markdown/postprocessors.py rename to zmarkdown/postprocessors.py index c66ad152..8d3b528d 100644 --- a/markdown/postprocessors.py +++ b/zmarkdown/postprocessors.py @@ -31,7 +31,7 @@ class Postprocessor(util.Processor): Each Postprocessor implements a "run" method that takes a pointer to a text string, modifies it as necessary and returns a text string. - Postprocessors must extend markdown.Postprocessor. + Postprocessors must extend zmarkdown.Postprocessor. """ @@ -50,17 +50,17 @@ class RawHtmlPostprocessor(Postprocessor): def run(self, text): """ Iterate over html stash and restore "safe" html. """ - for i in range(self.markdown.htmlStash.html_counter): - html, safe = self.markdown.htmlStash.rawHtmlBlocks[i] + for i in range(self.zmarkdown.htmlStash.html_counter): + html, safe = self.zmarkdown.htmlStash.rawHtmlBlocks[i] if not safe: html = self.escape(html) if (self.isblocklevel(html) and safe): text = text.replace( "

%s

" % - (self.markdown.htmlStash.get_placeholder(i)), + (self.zmarkdown.htmlStash.get_placeholder(i)), html + "\n") text = text.replace( - self.markdown.htmlStash.get_placeholder(i), html + self.zmarkdown.htmlStash.get_placeholder(i), html ) return text diff --git a/markdown/preprocessors.py b/zmarkdown/preprocessors.py similarity index 96% rename from markdown/preprocessors.py rename to zmarkdown/preprocessors.py index 443b7c10..67d6c635 100644 --- a/markdown/preprocessors.py +++ b/zmarkdown/preprocessors.py @@ -49,6 +49,6 @@ def run(self, lines): source = '\n'.join(lines) source = source.replace(util.STX, "").replace(util.ETX, "") source = source.replace("\r\n", "\n").replace("\r", "\n") + "\n\n" - source = source.expandtabs(self.markdown.tab_length) + source = source.expandtabs(self.zmarkdown.tab_length) source = re.sub(r'(?<=\n) +\n', '\n', source) return source.split('\n') diff --git a/markdown/serializers.py b/zmarkdown/serializers.py similarity index 100% rename from markdown/serializers.py rename to zmarkdown/serializers.py diff --git a/markdown/treeprocessors.py b/zmarkdown/treeprocessors.py similarity index 99% rename from markdown/treeprocessors.py rename to zmarkdown/treeprocessors.py index 0e287149..061e04e5 100644 --- a/markdown/treeprocessors.py +++ b/zmarkdown/treeprocessors.py @@ -51,7 +51,7 @@ def __init__(self, md): self.__placeholder_length = 4 + len(self.__placeholder_prefix) \ + len(self.__placeholder_suffix) self.__placeholder_re = util.INLINE_PLACEHOLDER_RE - self.markdown = md + self.zmarkdown = md self.inlinePatterns = md.inlinePatterns def __makePlaceholder(self, _): diff --git a/markdown/util.py b/zmarkdown/util.py similarity index 97% rename from markdown/util.py rename to zmarkdown/util.py index 34d02537..c024f1b7 100644 --- a/markdown/util.py +++ b/zmarkdown/util.py @@ -118,9 +118,9 @@ class RawHTMLString(AtomicString): class Processor(object): - def __init__(self, markdown_instance=None): - if markdown_instance: - self.markdown = markdown_instance + def __init__(self, zmarkdown_instance=None): + if zmarkdown_instance: + self.zmarkdown = zmarkdown_instance class HtmlStash(object):