Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/blurb/_utils/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -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. ', '#. '))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this break the generated NEWS, which prepends - to each entry?

blurb/src/blurb/_merge.py

Lines 107 to 108 in ed0ea0c

body = f'- {body}'
text = textwrap_body(body, subsequent_indent=' ')

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it will. This can wait, let's not hold up #88 for this.

if dont_reflow:
initial = kwargs.get('initial_indent', '')
subsequent = kwargs.get('subsequent_indent', '')
Expand Down
27 changes: 27 additions & 0 deletions tests/test_utils_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down