Skip to content

Commit 26b8d30

Browse files
authored
#663 Fix section depth in markdown template (#664)
2 parents 322506d + 86149f5 commit 26b8d30

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
When no sections are present,
2+
the default Markdown template now renders the category headers as H2.
3+
In previous versions it was rendered as H3.

src/towncrier/templates/default.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
{% if sections[section] %}
1515
{% for category, val in definitions.items() if category in sections[section] %}
16-
### {{ definitions[category]['name'] }}
16+
##{% if section %}#{% endif %} {{ definitions[category]['name'] }}
1717

1818
{% for text, values in sections[section][category].items() %}
1919
- {{ text }}

src/towncrier/test/test_build.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ def test_title_format_custom_markdown(self, runner):
10851085
10861086
[20-01-2001] CUSTOM RELEASE for FooBarBaz version 7.8.9
10871087
1088-
### Features
1088+
## Features
10891089
10901090
- Adds levitation (#123)
10911091
@@ -1136,11 +1136,10 @@ def test_markdown_injected_after_header(self, runner):
11361136
)
11371137

11381138
default_template = read_pkg_resource("templates/default.md")
1139+
assert "##{%" in default_template
11391140
write(
11401141
"custom_template.md",
1141-
contents=default_template.replace(
1142-
"### {{ definitions", "#### {{ definitions"
1143-
),
1142+
contents=default_template.replace("##{%", "####{%"),
11441143
)
11451144

11461145
result = runner.invoke(_main, ["--date", "01-01-2001"], catch_exceptions=False)
@@ -1387,7 +1386,7 @@ def test_default_start_string_markdown(self, runner):
13871386
13881387
# Foo 1.2.3 (01-01-2001)
13891388
1390-
### Features
1389+
## Features
13911390
13921391
- Adds levitation (#123)
13931392
@@ -1437,7 +1436,7 @@ def test_markdown_no_name_title(self, runner):
14371436
14381437
# 1.2.3 (01-01-2001)
14391438
1440-
### Features
1439+
## Features
14411440
14421441
- Adds levitation (#123)
14431442
"""
@@ -1607,7 +1606,7 @@ def test_orphans_in_non_showcontent_markdown(self, runner):
16071606
16081607
# 7.8.9 (20-01-2001)
16091608
1610-
### Misc
1609+
## Misc
16111610
16121611
- #123, #345
16131612
- Another orphan misc still displayed!

src/towncrier/test/test_format.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -205,15 +205,15 @@ def test_markdown(self):
205205

206206
expected_output = """# MyProject 1.0 (never)
207207
208-
### Features
208+
## Features
209209
210210
- Fun! (baz)
211211
- Foo added. (#2, #9, #72)
212212
- Multi-line
213213
here (#3)
214214
- Stuff! (#4)
215215
216-
### Misc
216+
## Misc
217217
218218
- bar, #1, #9, #142
219219
@@ -254,7 +254,7 @@ def test_markdown(self):
254254
# Also test with custom issue format
255255
expected_output = """# MyProject 1.0 (never)
256256
257-
### Features
257+
## Features
258258
259259
- Fun! ([baz])
260260
- Foo added. ([2], [9], [72])
@@ -269,7 +269,7 @@ def test_markdown(self):
269269
[9]: https://github.com/twisted/towncrier/issues/9
270270
[72]: https://github.com/twisted/towncrier/issues/72
271271
272-
### Misc
272+
## Misc
273273
274274
- [bar], [1], [9], [142]
275275

0 commit comments

Comments
 (0)