Commit 4a97e5a
committed
Fix: Preserve newlines in code blocks with github flavor
Commit 7c4daaf introduced a workaround for GitHub-flavored markdown treating
newlines as <br/> in paragraphs by unconditionally replacing all \n with
spaces when markdown_flavor='github'. However, this broke code blocks,
doctest blocks, and math blocks where newlines are semantically significant.
The visit_literal_block method already sets escape_text=False to signal
verbatim contexts. This fix conditions the newline replacement on
escape_text=True, so newlines are only collapsed in prose paragraphs,
not in code/math/comment blocks.
Impact: Multi-line argparse usage text (e.g., from sphinxcontrib-autoprogram)
now renders correctly with proper line breaks instead of collapsing into
a single line with multiple spaces.
Added test case with multi-line code block to prevent regression.
Signed-off-by: Eike Waldt <waldt@b1-systems.de>
On-behalf-of: SAP <eike.waldt@sap.com>1 parent d2dff40 commit 4a97e5a
2 files changed
Lines changed: 11 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
346 | 346 | | |
347 | 347 | | |
348 | 348 | | |
349 | | - | |
| 349 | + | |
350 | 350 | | |
351 | 351 | | |
352 | 352 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
26 | 36 | | |
27 | 37 | | |
28 | 38 | | |
| |||
0 commit comments