Skip to content

Commit

Permalink
test(#4): demo passing the CLI option
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleKing committed Jun 27, 2023
1 parent 815e977 commit 7fb0476
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 7 deletions.
5 changes: 2 additions & 3 deletions mdformat_mkdocs/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
def update_mdit(mdit: MarkdownIt) -> None:
"""No changes to markdown parsing are necessary."""
global _ALIGN_SEMANTIC_BREAKS_IN_NUMBERED_LISTS
# FIXME: How do I add this configuration option?
_ALIGN_SEMANTIC_BREAKS_IN_NUMBERED_LISTS = mdit.options.get(
"align_semantic_breaks_in_numbered_lists", True
_ALIGN_SEMANTIC_BREAKS_IN_NUMBERED_LISTS = mdit.options.get("mdformat", {}).get(
"align_semantic_breaks_in_numbered_lists", False
)


Expand Down
8 changes: 4 additions & 4 deletions tests/fixtures.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,15 @@ Hanging List (https://github.com/executablebooks/mdformat/issues/371)
Otherwise this next paragraph doesn't belong in the same list item.
.
1. Here indent width is
three.
three.

1. Here indent width is
three.
three.

1. Here indent width is
five. It needs to be so, because
five. It needs to be so, because

Otherwise this next paragraph doesn't belong in the same list item.
Otherwise this next paragraph doesn't belong in the same list item.
.

Table
Expand Down
37 changes: 37 additions & 0 deletions tests/test_align_semantic_breaks_in_numbered_lists.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import mdformat


def test_align_semantic_breaks_in_numbered_lists():
"""For https://github.com/KyleKing/mdformat-mkdocs/issues/4."""
input_text = """\
1. Here indent width is
three.
2. Here indent width is
three.
123. Here indent width is
five. It needs to be so, because
Otherwise this next paragraph doesn't belong in the same list item.
"""
expected_output = """\
1. Here indent width is
three.
1. Here indent width is
three.
1. Here indent width is
five. It needs to be so, because
Otherwise this next paragraph doesn't belong in the same list item.
"""

output = mdformat.text(
input_text,
options={"align_semantic_breaks_in_numbered_lists": True},
extensions={"mkdocs"},
)

assert output == expected_output

0 comments on commit 7fb0476

Please sign in to comment.