Skip to content

Commit 11a1125

Browse files
committed
Don't reflow dashed lists, same as asterisk lists
1 parent 72a52da commit 11a1125

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

‎src/blurb/_utils/text.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def textwrap_body(body: str | Iterable[str], *, subsequent_indent: str = '') ->
3939
dont_reflow = False
4040
for paragraph in paragraphs:
4141
# don't reflow bulleted / numbered lists
42-
dont_reflow = dont_reflow or paragraph.startswith(('* ', '1. ', '#. '))
42+
dont_reflow = dont_reflow or paragraph.startswith(('* ', '- ', '1. ', '#. '))
4343
if dont_reflow:
4444
initial = kwargs.get('initial_indent', '')
4545
subsequent = kwargs.get('subsequent_indent', '')

‎tests/test_utils_text.py‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,33 @@
4040
' * Item 1\n'
4141
' * Item 2\n',
4242
),
43+
(
44+
'This is a test of the textwrap_body function with a dashed list and subsequent indent. The list should not be wrapped.\n'
45+
'\n'
46+
'- Item 1\n'
47+
'- Item 2\n',
48+
' ',
49+
'This is a test of the textwrap_body function with a dashed list and\n'
50+
' subsequent indent. The list should not be wrapped.\n'
51+
'\n'
52+
' - Item 1\n'
53+
' - Item 2\n',
54+
),
55+
(
56+
'The following `threading` methods are now deprecated and should be replaced:\n'
57+
'\n'
58+
'- `threading.activeCount` => :func:`threading.active_count`\n'
59+
'\n'
60+
'- `threading.Condition.notifyAll` =>\n'
61+
' :meth:`threading.Condition.notify_all`\n',
62+
' ',
63+
'The following `threading` methods are now deprecated and should be replaced:\n'
64+
'\n'
65+
' - `threading.activeCount` => :func:`threading.active_count`\n'
66+
'\n'
67+
' - `threading.Condition.notifyAll` =>\n'
68+
' :meth:`threading.Condition.notify_all`\n',
69+
),
4370
),
4471
)
4572
def test_textwrap_body(body, subsequent_indent, expected):

0 commit comments

Comments
 (0)