-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests; fix minor bugs with stop_if()
Also use stop_if() to tweak stringify() of definition list
- Loading branch information
1 parent
e68d2d0
commit c8b4365
Showing
3 changed files
with
47 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import panflute as pf | ||
|
||
|
||
def validate(markdown_text, expected_text): | ||
doc = pf.convert_text(markdown_text, input_format='markdown', output_format='panflute', standalone=True) | ||
output_text = pf.stringify(doc) | ||
assert expected_text == output_text | ||
|
||
|
||
def test_simple(): | ||
markdown_text = '''Hello **world**! *How* are ~you~ doing?''' | ||
expected_text = '''Hello world! How are you doing?\n\n''' | ||
validate(markdown_text, expected_text) | ||
|
||
|
||
def test_definition_list(): | ||
markdown_text = '''Term 1\n: Definition 1\n\nTerm 2 with *inline markup*\n\n: Definition 2''' | ||
expected_text = '''- Term 1: Definition 1\n- Term 2 with inline markup: Definition 2\n\n''' | ||
validate(markdown_text, expected_text) | ||
|
||
|
||
def test_definition_list_complex(): | ||
markdown_text = '''Term 1\n~ Definition 1\n\nTerm 2\n~ Definition 2a\n~ Definition 2b''' | ||
expected_text = '''- Term 1: Definition 1\n- Term 2: Definition 2a; Definition 2b''' | ||
validate(markdown_text, expected_text) | ||
|
||
|
||
if __name__ == "__main__": | ||
test_simple() | ||
test_definition_list() | ||
test_definition_list_complex() |