From 11a1125e68f4931ee1ba311ac68e221bbea30cb1 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Thu, 27 Aug 2026 16:43:29 +0300 Subject: [PATCH] Don't reflow dashed lists, same as asterisk lists --- src/blurb/_utils/text.py | 2 +- tests/test_utils_text.py | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/blurb/_utils/text.py b/src/blurb/_utils/text.py index 39c0399..24b9202 100644 --- a/src/blurb/_utils/text.py +++ b/src/blurb/_utils/text.py @@ -39,7 +39,7 @@ def textwrap_body(body: str | Iterable[str], *, subsequent_indent: str = '') -> dont_reflow = False for paragraph in paragraphs: # don't reflow bulleted / numbered lists - dont_reflow = dont_reflow or paragraph.startswith(('* ', '1. ', '#. ')) + dont_reflow = dont_reflow or paragraph.startswith(('* ', '- ', '1. ', '#. ')) if dont_reflow: initial = kwargs.get('initial_indent', '') subsequent = kwargs.get('subsequent_indent', '') diff --git a/tests/test_utils_text.py b/tests/test_utils_text.py index 962792c..5ad291d 100644 --- a/tests/test_utils_text.py +++ b/tests/test_utils_text.py @@ -40,6 +40,33 @@ ' * Item 1\n' ' * Item 2\n', ), + ( + 'This is a test of the textwrap_body function with a dashed list and subsequent indent. The list should not be wrapped.\n' + '\n' + '- Item 1\n' + '- Item 2\n', + ' ', + 'This is a test of the textwrap_body function with a dashed list and\n' + ' subsequent indent. The list should not be wrapped.\n' + '\n' + ' - Item 1\n' + ' - Item 2\n', + ), + ( + 'The following `threading` methods are now deprecated and should be replaced:\n' + '\n' + '- `threading.activeCount` => :func:`threading.active_count`\n' + '\n' + '- `threading.Condition.notifyAll` =>\n' + ' :meth:`threading.Condition.notify_all`\n', + ' ', + 'The following `threading` methods are now deprecated and should be replaced:\n' + '\n' + ' - `threading.activeCount` => :func:`threading.active_count`\n' + '\n' + ' - `threading.Condition.notifyAll` =>\n' + ' :meth:`threading.Condition.notify_all`\n', + ), ), ) def test_textwrap_body(body, subsequent_indent, expected):