• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"""
2Python Markdown
3
4A Python implementation of John Gruber's Markdown.
5
6Documentation: https://python-markdown.github.io/
7GitHub: https://github.com/Python-Markdown/markdown/
8PyPI: https://pypi.org/project/Markdown/
9
10Started by Manfred Stienstra (http://www.dwerg.net/).
11Maintained for a few years by Yuri Takhteyev (http://www.freewisdom.org).
12Currently maintained by Waylan Limberg (https://github.com/waylan),
13Dmitry Shachnev (https://github.com/mitya57) and Isaac Muse (https://github.com/facelessuser).
14
15Copyright 2007-2018 The Python Markdown Project (v. 1.7 and later)
16Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b)
17Copyright 2004 Manfred Stienstra (the original version)
18
19License: BSD (see LICENSE.md for details).
20"""
21
22from markdown.test_tools import LegacyTestCase, Kwargs
23import os
24import warnings
25
26# Warnings should cause tests to fail...
27warnings.simplefilter('error')
28# Except for the warnings that shouldn't
29warnings.filterwarnings('default', category=PendingDeprecationWarning)
30warnings.filterwarnings('default', category=DeprecationWarning, module='markdown')
31
32parent_test_dir = os.path.abspath(os.path.dirname(__file__))
33
34
35class TestBasic(LegacyTestCase):
36    location = os.path.join(parent_test_dir, 'basic')
37
38
39class TestMisc(LegacyTestCase):
40    location = os.path.join(parent_test_dir, 'misc')
41
42
43class TestPhp(LegacyTestCase):
44    """
45    Notes on "excluded" tests:
46
47    Quotes in attributes: attributes get output in different order
48
49    Inline HTML (Span): Backtick in raw HTML attribute TODO: fixme
50
51    Backslash escapes: Weird whitespace issue in output
52
53    Ins & del: Our behavior follows markdown.pl I think PHP is wrong here
54
55    Auto Links: TODO: fix raw HTML so is doesn't match <hr@example.com> as a <hr>.
56
57    Empty List Item: We match markdown.pl here. Maybe someday we'll support this
58
59    Headers: TODO: fix headers to not require blank line before
60
61    Mixed OLs and ULs: We match markdown.pl here. I think PHP is wrong here
62
63    Emphasis: We have various minor differences in combined & incorrect em markup.
64    Maybe fix a few of them - but most aren't too important
65
66    Code block in a list item: We match markdown.pl - not sure how php gets that output??
67
68    PHP-Specific Bugs: Not sure what to make of the escaping stuff here.
69    Why is PHP not removing a blackslash?
70    """
71    location = os.path.join(parent_test_dir, 'php')
72    normalize = True
73    input_ext = '.text'
74    output_ext = '.xhtml'
75    exclude = [
76        'Quotes_in_attributes',
77        'Inline_HTML_(Span)',
78        'Backslash_escapes',
79        'Ins_&_del',
80        'Auto_Links',
81        'Empty_List_Item',
82        'Headers',
83        'Mixed_OLs_and_ULs',
84        'Emphasis',
85        'Code_block_in_a_list_item',
86        'PHP_Specific_Bugs'
87    ]
88
89
90# class TestPhpExtra(LegacyTestCase):
91#     location = os.path.join(parent_test_dir, 'php/extra')
92#     normalize = True
93#     input_ext = '.text'
94#     output_ext = '.xhtml'
95#     default_kwargs = Kwargs(extensions=['extra'])
96
97
98class TestPl2004(LegacyTestCase):
99    location = os.path.join(parent_test_dir, 'pl/Tests_2004')
100    normalize = True
101    input_ext = '.text'
102    exclude = ['Yuri_Footnotes', 'Yuri_Attributes']
103
104
105class TestPl2007(LegacyTestCase):
106    """
107    Notes on "excluded" tests:
108
109    Images: the attributes don't get ordered the same so we skip this
110
111    Code Blocks: some weird whitespace issue
112
113    Links, reference style: weird issue with nested brackets TODO: fixme
114
115    Backslash escapes: backticks in raw html attributes TODO: fixme
116
117    Code Spans: more backticks in raw html attributes TODO: fixme
118    """
119    location = os.path.join(parent_test_dir, 'pl/Tests_2007')
120    normalize = True
121    input_ext = '.text'
122    exclude = [
123        'Images',
124        'Code_Blocks',
125        'Links,_reference_style',
126        'Backslash_escapes',
127        'Code_Spans'
128    ]
129
130
131class TestExtensions(LegacyTestCase):
132    location = os.path.join(parent_test_dir, 'extensions')
133    exclude = ['codehilite']
134
135    attr_list = Kwargs(extensions=['attr_list', 'def_list', 'smarty'])
136
137    codehilite = Kwargs(extensions=['codehilite'])
138
139    toc = Kwargs(extensions=['toc'])
140
141    toc_invalid = Kwargs(extensions=['toc'])
142
143    toc_out_of_order = Kwargs(extensions=['toc'])
144
145    toc_nested = Kwargs(
146        extensions=['toc'],
147        extension_configs={'toc': {'permalink': True}}
148    )
149
150    toc_nested2 = Kwargs(
151        extensions=['toc'],
152        extension_configs={'toc': {'permalink': "[link]"}}
153    )
154
155    toc_nested_list = Kwargs(extensions=['toc'])
156
157    wikilinks = Kwargs(extensions=['wikilinks'])
158
159    github_flavored = Kwargs(extensions=['fenced_code'])
160
161    sane_lists = Kwargs(extensions=['sane_lists'])
162
163    nl2br_w_attr_list = Kwargs(extensions=['nl2br', 'attr_list'])
164
165    admonition = Kwargs(extensions=['admonition'])
166
167    smarty = Kwargs(
168        extensions=['smarty'],
169        extension_configs={'smarty': {'smart_angled_quotes': True}}
170    )
171
172
173class TestExtensionsExtra(LegacyTestCase):
174    location = os.path.join(parent_test_dir, 'extensions/extra')
175    default_kwargs = Kwargs(extensions=['extra'])
176
177    loose_def_list = Kwargs(extensions=['def_list'])
178
179    simple_def_lists = Kwargs(extensions=['def_list'])
180
181    abbr = Kwargs(extensions=['abbr'])
182
183    footnotes = Kwargs(extensions=['footnotes'])
184
185    extra_config = Kwargs(
186        extensions=['extra'],
187        extension_configs={
188            'extra': {
189                'footnotes': {
190                    'PLACE_MARKER': '~~~placemarker~~~'
191                }
192            }
193        }
194    )
195