diff --git a/CommonMark b/CommonMark new file mode 120000 index 0000000..b56c996 --- /dev/null +++ b/CommonMark @@ -0,0 +1 @@ +commonmark/ \ No newline at end of file diff --git a/CommonMark/__init__.py b/CommonMark/__init__.py deleted file mode 100644 index a8332d0..0000000 --- a/CommonMark/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -# flake8: noqa -from __future__ import unicode_literals, absolute_import - -from CommonMark.main import commonmark -from CommonMark.dump import dumpAST, dumpJSON -from CommonMark.blocks import Parser -from CommonMark.render.html import HtmlRenderer -from CommonMark.render.rst import ReStructuredTextRenderer diff --git a/MANIFEST.in b/MANIFEST.in index 1f2612b..e3aada7 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,17 +2,18 @@ include README.rst include LICENSE include .gitignore include spec.txt -include CommonMark/__init__.py -include CommonMark/blocks.py -include CommonMark/common.py -include CommonMark/dump.py -include CommonMark/entitytrans.py -include CommonMark/inlines.py -include CommonMark/main.py -include CommonMark/node.py -include CommonMark/utils.py -include CommonMark/render/__init__.py -include CommonMark/render/renderer.py -include CommonMark/render/html.py -include CommonMark/tests/run_spec_tests.py -include CommonMark/tests/unit_tests.py \ No newline at end of file +include commonmark/__init__.py +include commonmark/blocks.py +include commonmark/common.py +include commonmark/dump.py +include commonmark/entitytrans.py +include commonmark/inlines.py +include commonmark/main.py +include commonmark/node.py +include commonmark/utils.py +include commonmark/render/__init__.py +include commonmark/render/renderer.py +include commonmark/render/html.py +include commonmark/tests/run_spec_tests.py +include commonmark/tests/unit_tests.py +include CommonMark diff --git a/README.rst b/README.rst index e8e02c0..1fcbd2b 100644 --- a/README.rst +++ b/README.rst @@ -28,25 +28,25 @@ Usage :: - >>> import CommonMark - >>> CommonMark.commonmark('*hello!*') + >>> import dommonmark + >>> commonmark.commonmark('*hello!*') '

hello!

\n' Or, without the syntactic sugar: .. code:: python - import CommonMark - parser = CommonMark.Parser() + import commonmark + parser = commonmark.Parser() ast = parser.parse("Hello *World*") - renderer = CommonMark.HtmlRenderer() + renderer = commonmark.HtmlRenderer() html = renderer.render(ast) print(html) #

Hello World

# inspecting the abstract syntax tree - json = CommonMark.dumpJSON(ast) - CommonMark.dumpAST(ast) # pretty print generated AST structure + json = commonmark.dumpJSON(ast) + commonmark.dumpAST(ast) # pretty print generated AST structure There is also a CLI: @@ -92,7 +92,7 @@ something like this: $ pyvenv venv $ ./venv/bin/python setup.py develop test -The tests script, ``CommonMark/tests/run_spec_tests.py``, is pretty much a devtool. As +The tests script, ``commonmark/tests/run_spec_tests.py``, is pretty much a devtool. As well as running all the tests embedded in ``spec.txt`` it also allows you to run specific tests using the ``-t`` argument, provide information about passed tests with ``-p``, percentage passed by category of test @@ -103,11 +103,11 @@ tracing. :: - $ ./venv/bin/python CommonMark/tests/run_spec_tests.py -h + $ ./venv/bin/python commonmark/tests/run_spec_tests.py -h usage: run_spec_tests.py [-h] [-t T] [-p] [-f] [-i] [-d] [-np] [-s] - script to run the CommonMark specification tests against the CommonMark.py - parser + script to run the CommonMark specification tests against the CommonMark-py + parser. optional arguments: -h, --help show this help message and exit @@ -124,7 +124,7 @@ Authors - `Bibek Kafle `__ - `Roland Shoemaker `__ -- `Nik Nyby `__ +- `Nikolas Nyby `__ .. |Build Status| image:: https://travis-ci.org/rtfd/CommonMark-py.svg?branch=master :target: https://travis-ci.org/rtfd/CommonMark-py diff --git a/commonmark/__init__.py b/commonmark/__init__.py new file mode 100644 index 0000000..1c2193c --- /dev/null +++ b/commonmark/__init__.py @@ -0,0 +1,8 @@ +# flake8: noqa +from __future__ import unicode_literals, absolute_import + +from commonmark.main import commonmark +from commonmark.dump import dumpAST, dumpJSON +from commonmark.blocks import Parser +from commonmark.render.html import HtmlRenderer +from commonmark.render.rst import ReStructuredTextRenderer diff --git a/CommonMark/blocks.py b/commonmark/blocks.py similarity index 98% rename from CommonMark/blocks.py rename to commonmark/blocks.py index ebafa41..fa236a8 100644 --- a/CommonMark/blocks.py +++ b/commonmark/blocks.py @@ -2,11 +2,11 @@ import re from importlib import import_module -from CommonMark import common -from CommonMark.common import unescape_string -from CommonMark.inlines import InlineParser -from CommonMark.node import Node -from CommonMark.utils import to_camel_case +from commonmark import common +from commonmark.common import unescape_string +from commonmark.inlines import InlineParser +from commonmark.node import Node +from commonmark.utils import to_camel_case CODE_INDENT = 4 @@ -610,12 +610,12 @@ def add_child(self, tag, offset): """ Add block of type tag as a child of the tip. If the tip can't accept children, close and finalize it and try its parent, and so on til we find a block that can accept children.""" - block_class = getattr(import_module('CommonMark.blocks'), + block_class = getattr(import_module('commonmark.blocks'), to_camel_case(self.tip.t)) while not block_class.can_contain(tag): self.finalize(self.tip, self.line_number - 1) block_class = getattr( - import_module('CommonMark.blocks'), + import_module('commonmark.blocks'), to_camel_case(self.tip.t)) column_number = offset + 1 @@ -731,7 +731,7 @@ def incorporate_line(self, ln): self.find_next_nonspace() block_class = getattr( - import_module('CommonMark.blocks'), + import_module('commonmark.blocks'), to_camel_case(container.t)) rv = block_class.continue_(self, container) if rv == 0: @@ -757,7 +757,7 @@ def incorporate_line(self, ln): self.all_closed = (container == self.oldtip) self.last_matched_container = container - block_class = getattr(import_module('CommonMark.blocks'), + block_class = getattr(import_module('commonmark.blocks'), to_camel_case(container.t)) matched_leaf = container.t != 'paragraph' and block_class.accepts_lines starts = self.block_starts @@ -824,7 +824,7 @@ def incorporate_line(self, ln): cont.last_line_blank = last_line_blank cont = cont.parent - block_class = getattr(import_module('CommonMark.blocks'), + block_class = getattr(import_module('commonmark.blocks'), to_camel_case(t)) if block_class.accepts_lines: self.add_line() @@ -853,7 +853,7 @@ def finalize(self, block, line_number): above = block.parent block.is_open = False block.sourcepos[1] = [line_number, self.last_line_length] - block_class = getattr(import_module('CommonMark.blocks'), + block_class = getattr(import_module('commonmark.blocks'), to_camel_case(block.t)) block_class.finalize(self, block) diff --git a/CommonMark/cmark.py b/commonmark/cmark.py similarity index 88% rename from CommonMark/cmark.py rename to commonmark/cmark.py index d5ca11f..c6bd438 100755 --- a/CommonMark/cmark.py +++ b/commonmark/cmark.py @@ -2,7 +2,7 @@ from __future__ import unicode_literals import argparse import sys -import CommonMark +import commonmark def main(): @@ -27,7 +27,7 @@ def main(): parser.add_argument('-a', action="store_true", help="Print formatted AST") parser.add_argument('-aj', action="store_true", help="Output JSON AST") args = parser.parse_args() - parser = CommonMark.Parser() + parser = commonmark.Parser() f = args.infile o = args.o lines = [] @@ -36,16 +36,16 @@ def main(): data = "".join(lines) ast = parser.parse(data) if not args.a and not args.aj: - renderer = CommonMark.HtmlRenderer() + renderer = commonmark.HtmlRenderer() o.write(renderer.render(ast)) exit() if args.a: # print ast - CommonMark.dumpAST(ast) + commonmark.dumpAST(ast) exit() # o.write(ast.to_JSON()) - o.write(CommonMark.dumpJSON(ast)) + o.write(commonmark.dumpJSON(ast)) exit() diff --git a/CommonMark/common.py b/commonmark/common.py similarity index 98% rename from CommonMark/common.py rename to commonmark/common.py index 6a1885e..9156d88 100644 --- a/CommonMark/common.py +++ b/commonmark/common.py @@ -16,7 +16,7 @@ from .entitytrans import _unescape HTMLunescape = _unescape else: - from CommonMark import entitytrans + from commonmark import entitytrans HTMLunescape = entitytrans._unescape ENTITY = '&(?:#x[a-f0-9]{1,8}|#[0-9]{1,8}|[a-z][a-z0-9]{1,31});' diff --git a/CommonMark/dump.py b/commonmark/dump.py similarity index 98% rename from CommonMark/dump.py rename to commonmark/dump.py index b9746db..d83f259 100644 --- a/CommonMark/dump.py +++ b/commonmark/dump.py @@ -2,7 +2,7 @@ from builtins import str import json -from CommonMark.node import is_container +from commonmark.node import is_container def prepare(obj, topnode=False): diff --git a/CommonMark/entitytrans.py b/commonmark/entitytrans.py similarity index 100% rename from CommonMark/entitytrans.py rename to commonmark/entitytrans.py diff --git a/CommonMark/inlines.py b/commonmark/inlines.py similarity index 99% rename from CommonMark/inlines.py rename to commonmark/inlines.py index d8c1be8..748bc2c 100644 --- a/CommonMark/inlines.py +++ b/commonmark/inlines.py @@ -2,9 +2,9 @@ import re import sys -from CommonMark import common -from CommonMark.common import normalize_uri, unescape_string -from CommonMark.node import Node +from commonmark import common +from commonmark.common import normalize_uri, unescape_string +from commonmark.node import Node if sys.version_info >= (3, 0): if sys.version_info >= (3, 4): @@ -14,7 +14,7 @@ from .entitytrans import _unescape HTMLunescape = _unescape else: - from CommonMark import entitytrans + from commonmark import entitytrans HTMLunescape = entitytrans._unescape # Some regexps used in inline parser: diff --git a/CommonMark/main.py b/commonmark/main.py similarity index 75% rename from CommonMark/main.py rename to commonmark/main.py index 852db21..cffe63c 100755 --- a/CommonMark/main.py +++ b/commonmark/main.py @@ -1,20 +1,20 @@ # 2014 - Bibek Kafle & Roland Shoemaker -# 2015-2017 - Nik Nyby +# 2015-2017 - Nikolas Nyby # Port of @jgm's commonmark.js implementation of the CommonMark spec. # Basic usage: # -# import CommonMark -# parser = CommonMark.Parser() -# renderer = CommonMark.HtmlRenderer() +# import commonmark +# parser = commonmark.Parser() +# renderer = commonmark.HtmlRenderer() # print(renderer.render(parser.parse('Hello *world*'))) from __future__ import absolute_import, unicode_literals -from CommonMark.blocks import Parser -from CommonMark.dump import dumpAST, dumpJSON -from CommonMark.render.html import HtmlRenderer -from CommonMark.render.rst import ReStructuredTextRenderer +from commonmark.blocks import Parser +from commonmark.dump import dumpAST, dumpJSON +from commonmark.render.html import HtmlRenderer +from commonmark.render.rst import ReStructuredTextRenderer def commonmark(text, format="html"): diff --git a/CommonMark/node.py b/commonmark/node.py similarity index 100% rename from CommonMark/node.py rename to commonmark/node.py diff --git a/CommonMark/render/__init__.py b/commonmark/render/__init__.py similarity index 100% rename from CommonMark/render/__init__.py rename to commonmark/render/__init__.py diff --git a/CommonMark/render/html.py b/commonmark/render/html.py similarity index 98% rename from CommonMark/render/html.py rename to commonmark/render/html.py index 6009569..66612f7 100644 --- a/CommonMark/render/html.py +++ b/commonmark/render/html.py @@ -3,8 +3,8 @@ import re from builtins import str -from CommonMark.common import escape_xml -from CommonMark.render.renderer import Renderer +from commonmark.common import escape_xml +from commonmark.render.renderer import Renderer reUnsafeProtocol = re.compile( diff --git a/CommonMark/render/renderer.py b/commonmark/render/renderer.py similarity index 100% rename from CommonMark/render/renderer.py rename to commonmark/render/renderer.py diff --git a/CommonMark/render/rst.py b/commonmark/render/rst.py similarity index 95% rename from CommonMark/render/rst.py rename to commonmark/render/rst.py index b5b9726..a18f7b2 100644 --- a/CommonMark/render/rst.py +++ b/commonmark/render/rst.py @@ -1,7 +1,7 @@ from __future__ import unicode_literals -from CommonMark.render.renderer import Renderer +from commonmark.render.renderer import Renderer class ReStructuredTextRenderer(Renderer): @@ -12,12 +12,12 @@ class ReStructuredTextRenderer(Renderer): .. code:: python - import CommonMark + import commonmark - parser = CommonMark.Parser() + parser = commonmark.Parser() ast = parser.parse('Hello `inline code` example') - renderer = CommonMark.ReStructuredTextRenderer() + renderer = commonmark.ReStructuredTextRenderer() rst = renderer.render(ast) print(rst) # Hello ``inline code`` example """ diff --git a/CommonMark/tests/__init__.py b/commonmark/tests/__init__.py similarity index 100% rename from CommonMark/tests/__init__.py rename to commonmark/tests/__init__.py diff --git a/CommonMark/tests/rst_tests.py b/commonmark/tests/rst_tests.py similarity index 96% rename from CommonMark/tests/rst_tests.py rename to commonmark/tests/rst_tests.py index c71df18..b8fa890 100644 --- a/CommonMark/tests/rst_tests.py +++ b/commonmark/tests/rst_tests.py @@ -1,12 +1,12 @@ import unittest -import CommonMark +import commonmark class TestCommonmark(unittest.TestCase): def setUp(self): - self.parser = CommonMark.Parser() - self.renderer = CommonMark.ReStructuredTextRenderer() + self.parser = commonmark.Parser() + self.renderer = commonmark.ReStructuredTextRenderer() def render_rst(self, test_str): ast = self.parser.parse(test_str) diff --git a/CommonMark/tests/run_spec_tests.py b/commonmark/tests/run_spec_tests.py similarity index 98% rename from CommonMark/tests/run_spec_tests.py rename to commonmark/tests/run_spec_tests.py index bf3e57a..346e46f 100755 --- a/CommonMark/tests/run_spec_tests.py +++ b/commonmark/tests/run_spec_tests.py @@ -7,8 +7,8 @@ import argparse import sys from builtins import str -from CommonMark.render.html import HtmlRenderer -from CommonMark.main import Parser, dumpAST +from commonmark.render.html import HtmlRenderer +from commonmark.main import Parser, dumpAST class colors(object): diff --git a/CommonMark/tests/test.md b/commonmark/tests/test.md similarity index 94% rename from CommonMark/tests/test.md rename to commonmark/tests/test.md index e001487..392ca6c 100644 --- a/CommonMark/tests/test.md +++ b/commonmark/tests/test.md @@ -16,13 +16,13 @@ Installation Usage ----- - import CommonMark - parser = CommonMark.Parser() - renderer = CommonMark.HtmlRenderer() + import commonmark + parser = commonmark.Parser() + renderer = commonmark.HtmlRenderer() ast = parser.parse("Hello *World*") html = renderer.render(ast) - json = CommonMark.dumpJSON(ast) - CommonMark.dumpAST(ast) # pretty print generated AST structure + json = commonmark.dumpJSON(ast) + commonmark.dumpAST(ast) # pretty print generated AST structure print(html) #

Hello World

----- or ----- diff --git a/CommonMark/tests/unit_tests.py b/commonmark/tests/unit_tests.py similarity index 82% rename from CommonMark/tests/unit_tests.py rename to commonmark/tests/unit_tests.py index fc85f7f..aebcfbb 100644 --- a/CommonMark/tests/unit_tests.py +++ b/commonmark/tests/unit_tests.py @@ -20,29 +20,29 @@ def text(): pass -import CommonMark -from CommonMark.blocks import Parser -from CommonMark.render.html import HtmlRenderer -from CommonMark.inlines import InlineParser -from CommonMark.node import NodeWalker, Node -from CommonMark.utils import to_camel_case +import commonmark +from commonmark.blocks import Parser +from commonmark.render.html import HtmlRenderer +from commonmark.inlines import InlineParser +from commonmark.node import NodeWalker, Node +from commonmark.utils import to_camel_case class TestCommonmark(unittest.TestCase): def test_output(self): - s = CommonMark.commonmark('*hello!*') + s = commonmark.commonmark('*hello!*') self.assertEqual(s, '

hello!

\n') def test_unicode(self): - s = CommonMark.commonmark('
\u2020
\n') + s = commonmark.commonmark('
\u2020
\n') self.assertEqual(s, '
\u2020
\n', 'Unicode works in an HTML block.') - CommonMark.commonmark('* unicode: \u2020') - CommonMark.commonmark('# unicode: \u2020') - CommonMark.commonmark('```\n# unicode: \u2020\n```') + commonmark.commonmark('* unicode: \u2020') + commonmark.commonmark('# unicode: \u2020') + commonmark.commonmark('```\n# unicode: \u2020\n```') def test_null_string_bug(self): - s = CommonMark.commonmark('> sometext\n>\n\n') + s = commonmark.commonmark('> sometext\n>\n\n') self.assertEqual( s, '
\n
sometext\n
' @@ -76,11 +76,11 @@ def assert_text_literals(text_literals): def test_dumpAST_orderedlist(self): md = '1.' ast = Parser().parse(md) - CommonMark.dumpAST(ast) + commonmark.dumpAST(ast) @given(text()) def test_random_text(self, s): - CommonMark.commonmark(s) + commonmark.commonmark(s) def test_smart_dashes(self): md = 'a - b -- c --- d ---- e ----- f' @@ -94,9 +94,9 @@ def test_smart_dashes(self): + 'd ' + EN + EN + ' ' + 'e ' + EM + EN + ' ' + 'f

\n') - parser = CommonMark.Parser(options=dict(smart=True)) + parser = commonmark.Parser(options=dict(smart=True)) ast = parser.parse(md) - renderer = CommonMark.HtmlRenderer() + renderer = commonmark.HtmlRenderer() html = renderer.render(ast) self.assertEqual(html, expected_html) diff --git a/CommonMark/utils.py b/commonmark/utils.py similarity index 100% rename from CommonMark/utils.py rename to commonmark/utils.py diff --git a/docs/html.rst b/docs/html.rst index d93a527..dee0be3 100644 --- a/docs/html.rst +++ b/docs/html.rst @@ -1,7 +1,7 @@ HTML ==== -.. currentmodule:: CommonMark.render.html +.. currentmodule:: commonmark.render.html .. autoclass:: HtmlRenderer :members: diff --git a/docs/node.rst b/docs/node.rst index 3a301c6..122bafb 100644 --- a/docs/node.rst +++ b/docs/node.rst @@ -1,7 +1,7 @@ Node ==== -.. currentmodule:: CommonMark.node +.. currentmodule:: commonmark.node .. autoclass:: NodeWalker :members: diff --git a/docs/parser.rst b/docs/parser.rst index bb4b591..c6e9c79 100644 --- a/docs/parser.rst +++ b/docs/parser.rst @@ -1,7 +1,7 @@ Parser ====== -.. currentmodule:: CommonMark.blocks +.. currentmodule:: commonmark.blocks .. autoclass:: Parser :members: diff --git a/docs/rst.rst b/docs/rst.rst index 400b9d5..66ec2a7 100644 --- a/docs/rst.rst +++ b/docs/rst.rst @@ -1,7 +1,7 @@ reStructuredText ================ -.. currentmodule:: CommonMark.render.rst +.. currentmodule:: commonmark.render.rst .. autoclass:: ReStructuredTextRenderer :members: diff --git a/setup.py b/setup.py index ec71b36..45a9cac 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ def run(self): import subprocess import sys errno = subprocess.call([ - sys.executable, 'CommonMark/tests/run_spec_tests.py']) + sys.executable, 'commonmark/tests/run_spec_tests.py']) raise SystemExit(errno) @@ -27,7 +27,7 @@ def run(self): setup( - name="CommonMark", + name="commonmark", packages=find_packages(exclude=['tests']), version="0.7.5", license="BSD-3-Clause", @@ -41,7 +41,7 @@ def run(self): keywords=["markup", "markdown", "commonmark"], entry_points={ 'console_scripts': [ - 'cmark = CommonMark.cmark:main', + 'cmark = commonmark.cmark:main', ] }, cmdclass={'test': Test}, diff --git a/tox.ini b/tox.ini index 3495ee3..9161612 100644 --- a/tox.ini +++ b/tox.ini @@ -9,5 +9,5 @@ envlist = py{26,27,33,34,35,36,py,py3} [testenv] deps = .[test] commands = - python -m CommonMark.tests.unit_tests - python -m CommonMark.tests.run_spec_tests {posargs:} + python -m commonmark.tests.unit_tests + python -m commonmark.tests.run_spec_tests {posargs:}