Skip to content

Commit

Permalink
Add tests for including lines
Browse files Browse the repository at this point in the history
  • Loading branch information
ZedThree committed Nov 23, 2022
1 parent 03c4ea0 commit f5e754d
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/resources/longer.md
@@ -0,0 +1,8 @@
This is line 1
This is line 2
This is line 3
This is line 4
This is line 5
This is line 6
This is line 7
This is line 8
48 changes: 48 additions & 0 deletions tests/test_include.py
Expand Up @@ -142,3 +142,51 @@ def test_processor_lines():
result_lines = processor.run(source)

assert len(result_lines) == 9


def test_include_lines(markdown_include):
source = "{!resources/longer.md!lines=1 3}"
html = markdown.markdown(source, extensions=[markdown_include])

assert html == dedent(
"""\
<p>This is line 1
This is line 3</p>"""
)


def test_include_line_range(markdown_include):
source = "{!resources/longer.md!lines=3-5}"
html = markdown.markdown(source, extensions=[markdown_include])

assert html == dedent(
"""\
<p>This is line 3
This is line 4
This is line 5</p>"""
)


def test_include_lines_and_line_range(markdown_include):
source = "{!resources/longer.md!lines=1 3-5 8}"
html = markdown.markdown(source, extensions=[markdown_include])

assert html == dedent(
"""\
<p>This is line 1
This is line 3
This is line 4
This is line 5
This is line 8</p>"""
)


def test_include_lines_out_of_order(markdown_include):
source = "{!resources/longer.md!lines=3 1}"
html = markdown.markdown(source, extensions=[markdown_include])

assert html == dedent(
"""\
<p>This is line 3
This is line 1</p>"""
)

0 comments on commit f5e754d

Please sign in to comment.