diff --git a/mdformat_mkdocs/plugin.py b/mdformat_mkdocs/plugin.py index 11377cd..b52b675 100644 --- a/mdformat_mkdocs/plugin.py +++ b/mdformat_mkdocs/plugin.py @@ -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 ) diff --git a/tests/fixtures.md b/tests/fixtures.md index 6949911..278e12c 100644 --- a/tests/fixtures.md +++ b/tests/fixtures.md @@ -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 diff --git a/tests/test_align_semantic_breaks_in_numbered_lists.py b/tests/test_align_semantic_breaks_in_numbered_lists.py new file mode 100644 index 0000000..644176d --- /dev/null +++ b/tests/test_align_semantic_breaks_in_numbered_lists.py @@ -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