Skip to content
This repository was archived by the owner on Mar 26, 2022. It is now read-only.

Commit 698ae5c

Browse files
committed
Rename package name to commonmark
This makes the package name PEP8-compliant by changing: import CommonMark to: import commonmark The old camel-cased import should still work as well though, for now. Closes #60
1 parent cfb58a5 commit 698ae5c

29 files changed

+106
-105
lines changed

CommonMark

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
commonmark/

CommonMark/__init__.py

-8
This file was deleted.

MANIFEST.in

+14-14
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ include README.rst
22
include LICENSE
33
include .gitignore
44
include spec.txt
5-
include CommonMark/__init__.py
6-
include CommonMark/blocks.py
7-
include CommonMark/common.py
8-
include CommonMark/dump.py
9-
include CommonMark/entitytrans.py
10-
include CommonMark/inlines.py
11-
include CommonMark/main.py
12-
include CommonMark/node.py
13-
include CommonMark/utils.py
14-
include CommonMark/render/__init__.py
15-
include CommonMark/render/renderer.py
16-
include CommonMark/render/html.py
17-
include CommonMark/tests/run_spec_tests.py
18-
include CommonMark/tests/unit_tests.py
5+
include commonmark/__init__.py
6+
include commonmark/blocks.py
7+
include commonmark/common.py
8+
include commonmark/dump.py
9+
include commonmark/entitytrans.py
10+
include commonmark/inlines.py
11+
include commonmark/main.py
12+
include commonmark/node.py
13+
include commonmark/utils.py
14+
include commonmark/render/__init__.py
15+
include commonmark/render/renderer.py
16+
include commonmark/render/html.py
17+
include commonmark/tests/run_spec_tests.py
18+
include commonmark/tests/unit_tests.py

README.rst

+12-12
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,25 @@ Usage
2828

2929
::
3030

31-
>>> import CommonMark
32-
>>> CommonMark.commonmark('*hello!*')
31+
>>> import dommonmark
32+
>>> commonmark.commonmark('*hello!*')
3333
'<p><em>hello!</em></p>\n'
3434

3535
Or, without the syntactic sugar:
3636

3737
.. code:: python
3838
39-
import CommonMark
40-
parser = CommonMark.Parser()
39+
import commonmark
40+
parser = commonmark.Parser()
4141
ast = parser.parse("Hello *World*")
4242
43-
renderer = CommonMark.HtmlRenderer()
43+
renderer = commonmark.HtmlRenderer()
4444
html = renderer.render(ast)
4545
print(html) # <p>Hello <em>World</em><p/>
4646
4747
# inspecting the abstract syntax tree
48-
json = CommonMark.dumpJSON(ast)
49-
CommonMark.dumpAST(ast) # pretty print generated AST structure
48+
json = commonmark.dumpJSON(ast)
49+
commonmark.dumpAST(ast) # pretty print generated AST structure
5050
5151
There is also a CLI:
5252

@@ -92,7 +92,7 @@ something like this:
9292
$ pyvenv venv
9393
$ ./venv/bin/python setup.py develop test
9494

95-
The tests script, ``CommonMark/tests/run_spec_tests.py``, is pretty much a devtool. As
95+
The tests script, ``commonmark/tests/run_spec_tests.py``, is pretty much a devtool. As
9696
well as running all the tests embedded in ``spec.txt`` it also allows you
9797
to run specific tests using the ``-t`` argument, provide information
9898
about passed tests with ``-p``, percentage passed by category of test
@@ -103,11 +103,11 @@ tracing.
103103

104104
::
105105

106-
$ ./venv/bin/python CommonMark/tests/run_spec_tests.py -h
106+
$ ./venv/bin/python commonmark/tests/run_spec_tests.py -h
107107
usage: run_spec_tests.py [-h] [-t T] [-p] [-f] [-i] [-d] [-np] [-s]
108108

109-
script to run the CommonMark specification tests against the CommonMark.py
110-
parser
109+
script to run the CommonMark specification tests against the CommonMark-py
110+
parser.
111111

112112
optional arguments:
113113
-h, --help show this help message and exit
@@ -124,7 +124,7 @@ Authors
124124

125125
- `Bibek Kafle <https://github.com/kafle>`__
126126
- `Roland Shoemaker <https://github.com/rolandshoemaker>`__
127-
- `Nik Nyby <https://github.com/nikolas>`__
127+
- `Nikolas Nyby <https://github.com/nikolas>`__
128128

129129
.. |Build Status| image:: https://travis-ci.org/rtfd/CommonMark-py.svg?branch=master
130130
:target: https://travis-ci.org/rtfd/CommonMark-py

commonmark/__init__.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# flake8: noqa
2+
from __future__ import unicode_literals, absolute_import
3+
4+
from commonmark.main import commonmark
5+
from commonmark.dump import dumpAST, dumpJSON
6+
from commonmark.blocks import Parser
7+
from commonmark.render.html import HtmlRenderer
8+
from commonmark.render.rst import ReStructuredTextRenderer

CommonMark/blocks.py renamed to commonmark/blocks.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
import re
44
from importlib import import_module
5-
from CommonMark import common
6-
from CommonMark.common import unescape_string
7-
from CommonMark.inlines import InlineParser
8-
from CommonMark.node import Node
9-
from CommonMark.utils import to_camel_case
5+
from commonmark import common
6+
from commonmark.common import unescape_string
7+
from commonmark.inlines import InlineParser
8+
from commonmark.node import Node
9+
from commonmark.utils import to_camel_case
1010

1111

1212
CODE_INDENT = 4
@@ -610,12 +610,12 @@ def add_child(self, tag, offset):
610610
""" Add block of type tag as a child of the tip. If the tip can't
611611
accept children, close and finalize it and try its parent,
612612
and so on til we find a block that can accept children."""
613-
block_class = getattr(import_module('CommonMark.blocks'),
613+
block_class = getattr(import_module('commonmark.blocks'),
614614
to_camel_case(self.tip.t))
615615
while not block_class.can_contain(tag):
616616
self.finalize(self.tip, self.line_number - 1)
617617
block_class = getattr(
618-
import_module('CommonMark.blocks'),
618+
import_module('commonmark.blocks'),
619619
to_camel_case(self.tip.t))
620620

621621
column_number = offset + 1
@@ -731,7 +731,7 @@ def incorporate_line(self, ln):
731731

732732
self.find_next_nonspace()
733733
block_class = getattr(
734-
import_module('CommonMark.blocks'),
734+
import_module('commonmark.blocks'),
735735
to_camel_case(container.t))
736736
rv = block_class.continue_(self, container)
737737
if rv == 0:
@@ -757,7 +757,7 @@ def incorporate_line(self, ln):
757757
self.all_closed = (container == self.oldtip)
758758
self.last_matched_container = container
759759

760-
block_class = getattr(import_module('CommonMark.blocks'),
760+
block_class = getattr(import_module('commonmark.blocks'),
761761
to_camel_case(container.t))
762762
matched_leaf = container.t != 'paragraph' and block_class.accepts_lines
763763
starts = self.block_starts
@@ -824,7 +824,7 @@ def incorporate_line(self, ln):
824824
cont.last_line_blank = last_line_blank
825825
cont = cont.parent
826826

827-
block_class = getattr(import_module('CommonMark.blocks'),
827+
block_class = getattr(import_module('commonmark.blocks'),
828828
to_camel_case(t))
829829
if block_class.accepts_lines:
830830
self.add_line()
@@ -853,7 +853,7 @@ def finalize(self, block, line_number):
853853
above = block.parent
854854
block.is_open = False
855855
block.sourcepos[1] = [line_number, self.last_line_length]
856-
block_class = getattr(import_module('CommonMark.blocks'),
856+
block_class = getattr(import_module('commonmark.blocks'),
857857
to_camel_case(block.t))
858858
block_class.finalize(self, block)
859859

CommonMark/cmark.py renamed to commonmark/cmark.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from __future__ import unicode_literals
33
import argparse
44
import sys
5-
import CommonMark
5+
import commonmark
66

77

88
def main():
@@ -27,7 +27,7 @@ def main():
2727
parser.add_argument('-a', action="store_true", help="Print formatted AST")
2828
parser.add_argument('-aj', action="store_true", help="Output JSON AST")
2929
args = parser.parse_args()
30-
parser = CommonMark.Parser()
30+
parser = commonmark.Parser()
3131
f = args.infile
3232
o = args.o
3333
lines = []
@@ -36,16 +36,16 @@ def main():
3636
data = "".join(lines)
3737
ast = parser.parse(data)
3838
if not args.a and not args.aj:
39-
renderer = CommonMark.HtmlRenderer()
39+
renderer = commonmark.HtmlRenderer()
4040
o.write(renderer.render(ast))
4141
exit()
4242
if args.a:
4343
# print ast
44-
CommonMark.dumpAST(ast)
44+
commonmark.dumpAST(ast)
4545
exit()
4646

4747
# o.write(ast.to_JSON())
48-
o.write(CommonMark.dumpJSON(ast))
48+
o.write(commonmark.dumpJSON(ast))
4949
exit()
5050

5151

CommonMark/common.py renamed to commonmark/common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from .entitytrans import _unescape
1717
HTMLunescape = _unescape
1818
else:
19-
from CommonMark import entitytrans
19+
from commonmark import entitytrans
2020
HTMLunescape = entitytrans._unescape
2121

2222
ENTITY = '&(?:#x[a-f0-9]{1,8}|#[0-9]{1,8}|[a-z][a-z0-9]{1,31});'

CommonMark/dump.py renamed to commonmark/dump.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from builtins import str
44
import json
5-
from CommonMark.node import is_container
5+
from commonmark.node import is_container
66

77

88
def prepare(obj, topnode=False):
File renamed without changes.

CommonMark/inlines.py renamed to commonmark/inlines.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
import re
44
import sys
5-
from CommonMark import common
6-
from CommonMark.common import normalize_uri, unescape_string
7-
from CommonMark.node import Node
5+
from commonmark import common
6+
from commonmark.common import normalize_uri, unescape_string
7+
from commonmark.node import Node
88

99
if sys.version_info >= (3, 0):
1010
if sys.version_info >= (3, 4):
@@ -14,7 +14,7 @@
1414
from .entitytrans import _unescape
1515
HTMLunescape = _unescape
1616
else:
17-
from CommonMark import entitytrans
17+
from commonmark import entitytrans
1818
HTMLunescape = entitytrans._unescape
1919

2020
# Some regexps used in inline parser:

CommonMark/main.py renamed to commonmark/main.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
# 2014 - Bibek Kafle & Roland Shoemaker
2-
# 2015-2017 - Nik Nyby
2+
# 2015-2017 - Nikolas Nyby
33
# Port of @jgm's commonmark.js implementation of the CommonMark spec.
44

55
# Basic usage:
66
#
7-
# import CommonMark
8-
# parser = CommonMark.Parser()
9-
# renderer = CommonMark.HtmlRenderer()
7+
# import commonmark
8+
# parser = commonmark.Parser()
9+
# renderer = commonmark.HtmlRenderer()
1010
# print(renderer.render(parser.parse('Hello *world*')))
1111

1212
from __future__ import absolute_import, unicode_literals
1313

14-
from CommonMark.blocks import Parser
15-
from CommonMark.dump import dumpAST, dumpJSON
16-
from CommonMark.render.html import HtmlRenderer
17-
from CommonMark.render.rst import ReStructuredTextRenderer
14+
from commonmark.blocks import Parser
15+
from commonmark.dump import dumpAST, dumpJSON
16+
from commonmark.render.html import HtmlRenderer
17+
from commonmark.render.rst import ReStructuredTextRenderer
1818

1919

2020
def commonmark(text, format="html"):
File renamed without changes.
File renamed without changes.

CommonMark/render/html.py renamed to commonmark/render/html.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
import re
55
from builtins import str
6-
from CommonMark.common import escape_xml
7-
from CommonMark.render.renderer import Renderer
6+
from commonmark.common import escape_xml
7+
from commonmark.render.renderer import Renderer
88

99

1010
reUnsafeProtocol = re.compile(
File renamed without changes.

CommonMark/render/rst.py renamed to commonmark/render/rst.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import unicode_literals
22

33

4-
from CommonMark.render.renderer import Renderer
4+
from commonmark.render.renderer import Renderer
55

66

77
class ReStructuredTextRenderer(Renderer):
@@ -12,12 +12,12 @@ class ReStructuredTextRenderer(Renderer):
1212
1313
.. code:: python
1414
15-
import CommonMark
15+
import commonmark
1616
17-
parser = CommonMark.Parser()
17+
parser = commonmark.Parser()
1818
ast = parser.parse('Hello `inline code` example')
1919
20-
renderer = CommonMark.ReStructuredTextRenderer()
20+
renderer = commonmark.ReStructuredTextRenderer()
2121
rst = renderer.render(ast)
2222
print(rst) # Hello ``inline code`` example
2323
"""
File renamed without changes.

CommonMark/tests/rst_tests.py renamed to commonmark/tests/rst_tests.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import unittest
22

3-
import CommonMark
3+
import commonmark
44

55

66
class TestCommonmark(unittest.TestCase):
77
def setUp(self):
8-
self.parser = CommonMark.Parser()
9-
self.renderer = CommonMark.ReStructuredTextRenderer()
8+
self.parser = commonmark.Parser()
9+
self.renderer = commonmark.ReStructuredTextRenderer()
1010

1111
def render_rst(self, test_str):
1212
ast = self.parser.parse(test_str)

CommonMark/tests/run_spec_tests.py renamed to commonmark/tests/run_spec_tests.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import argparse
88
import sys
99
from builtins import str
10-
from CommonMark.render.html import HtmlRenderer
11-
from CommonMark.main import Parser, dumpAST
10+
from commonmark.render.html import HtmlRenderer
11+
from commonmark.main import Parser, dumpAST
1212

1313

1414
class colors(object):

CommonMark/tests/test.md renamed to commonmark/tests/test.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ Installation
1616
Usage
1717
-----
1818

19-
import CommonMark
20-
parser = CommonMark.Parser()
21-
renderer = CommonMark.HtmlRenderer()
19+
import commonmark
20+
parser = commonmark.Parser()
21+
renderer = commonmark.HtmlRenderer()
2222
ast = parser.parse("Hello *World*")
2323
html = renderer.render(ast)
24-
json = CommonMark.dumpJSON(ast)
25-
CommonMark.dumpAST(ast) # pretty print generated AST structure
24+
json = commonmark.dumpJSON(ast)
25+
commonmark.dumpAST(ast) # pretty print generated AST structure
2626
print(html) # <p>Hello <em>World</em><p/>
2727

2828
----- or -----

0 commit comments

Comments
 (0)