forked from python-semantic-release/python-semantic-release
-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.py
27 lines (21 loc) · 730 Bytes
/
util.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from __future__ import annotations
import re
breaking_re = re.compile(r"BREAKING[ -]CHANGE:\s?(.*)")
def parse_paragraphs(text: str) -> list[str]:
r"""
This will take a text block and return a list containing each
paragraph with single line breaks collapsed into spaces.
To handle Windows line endings, carriage returns '\r' are removed before
separating into paragraphs.
:param text: The text string to be divided.
:return: A list of condensed paragraphs, as strings.
"""
return list(
filter(
None,
[
paragraph.replace("\n", " ").strip()
for paragraph in text.replace("\r", "").split("\n\n")
],
)
)