Skip to content

Commit 974c4a6

Browse files
committed
feat: try to test for wrapping attrs
1 parent 9d4242a commit 974c4a6

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

mdformat_mkdocs/_postprocess_inline.py

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def postprocess_list_wrap(
4141
and node.parent.parent
4242
and node.parent.parent.type != "list_item"
4343
)
44+
or "{:" in text # Prevent wrapping when attribute list is present
4445
):
4546
return text
4647

tests/format/test_wrap.py

+9
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,13 @@
179179
[link](http://example.com){: class="foo bar" title="Some title!" .a_class1 .a_class2 .a_class1 .a_class2 .a_class1 .a_class2 }
180180
"""
181181

182+
CASE_ATTR_LIST_WRAP = """
183+
This is a paragraph with a long attribute list that should not be wrapped {: .class1 .class2 .class3 .class4 .class5 .class6 .class7 .class8 .class9 .class10 .class11 .class12 .class13 .class14 .class15 .class16 .class17 .class18 .class19 .class20 }
184+
"""
185+
186+
CASE_ATTR_LIST_WRAP_TRUE_80 = """
187+
This is a paragraph with a long attribute list that should not be wrapped {: .class1 .class2 .class3 .class4 .class5 .class6 .class7 .class8 .class9 .class10 .class11 .class12 .class13 .class14 .class15 .class16 .class17 .class18 .class19 .class20 }
188+
"""
182189

183190
@pytest.mark.parametrize(
184191
("text", "expected", "align_lists", "wrap"),
@@ -190,6 +197,7 @@
190197
(TICKET_020, TICKET_020_TRUE_79, True, 79),
191198
(WITH_CODE, WITH_CODE_TRUE_80, True, 80),
192199
(WITH_ATTR_LIST, WITH_ATTR_LIST_TRUE_80, True, 80),
200+
(CASE_ATTR_LIST_WRAP, CASE_ATTR_LIST_WRAP_TRUE_80, True, 80),
193201
],
194202
ids=[
195203
"CASE_1_FALSE_40",
@@ -199,6 +207,7 @@
199207
"TICKET_020_TRUE_79",
200208
"WITH_CODE_TRUE_80",
201209
"WITH_ATTR_LIST_TRUE_80",
210+
"CASE_ATTR_LIST_WRAP_TRUE_80",
202211
],
203212
)
204213
def test_wrap(text: str, expected: str, align_lists: bool, wrap: int):

0 commit comments

Comments
 (0)