Skip to content

Commit 3f6b355

Browse files
committed
Better multi line support
1 parent 254b80b commit 3f6b355

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
- Show helpful error message if `show <release>` does not find requested `release`.
1111
- `keepachangelog.to_dict` will now return a single multi line string value for multi line values or values with sub items.
1212
- `keepachangelog.to_dict` will now also considers `+` as a list identifier (joining `-` and `*`).
13+
- `keepachangelog.from_dict` will now indent (by one space) multi-line values.
1314

1415
### Added
1516
- `Python` `3.13` is now explicitly supported.
@@ -18,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1819
- `keepachangelog.to_dict` does not allow to provide anything else than a `Path` or a `str` as path to the changelog.
1920
- `keepachangelog.to_dict` will now return a single multi line string value for multi line values or values with sub items.
2021
- `keepachangelog.to_dict` will not contains values prefixed with `+` anymore as it is a list identifier.
22+
- `keepachangelog.from_dict` will now indent (by one space) multi-line values.
2123

2224
## [2.0.0] - 2024-06-14
2325
### Removed

keepachangelog/_changelog.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ def from_dict(changes: dict[str, dict]) -> str:
126126

127127
uncategorized = current_release.get("uncategorized", [])
128128
for category_content in uncategorized:
129+
category_content = category_content.replace("\n", "\n ")
129130
content += f"\n* {category_content}"
130131
if uncategorized:
131132
content += "\n"
@@ -137,6 +138,7 @@ def from_dict(changes: dict[str, dict]) -> str:
137138
content += f"\n### {category_name.capitalize()}"
138139

139140
for categorized in category_content:
141+
categorized = categorized.replace("\n", "\n ")
140142
content += f"\n- {categorized}"
141143

142144
content += "\n"

tests/test_changelog_unreleased.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,14 @@ def test_changelog_from_dict(changelog):
197197
198198
### Added
199199
- Enhancement 1
200-
- sub enhancement 1
201-
* sub enhancement 2
200+
- sub enhancement 1
201+
* sub enhancement 2
202202
- Enhancement 2
203203
204204
### Fixed
205205
- Bug fix 1
206-
- sub bug 1
207-
* sub bug 2
206+
- sub bug 1
207+
* sub bug 2
208208
- Bug fix 2
209209
210210
### Security

0 commit comments

Comments
 (0)