Skip to content

Escape block markers on paragraph continuation lines with the GFM extension too - #316

Merged
frostming merged 1 commit into
frostming:masterfrom
RavSinghChandan:gfm-paragraph-continuation-block-start
Nov 11, 2026
Merged

frostming merged 1 commit into
frostming:masterfrom
RavSinghChandan:gfm-paragraph-continuation-block-start

Conversation

@RavSinghChandan

Copy link
Copy Markdown
Contributor

#310 escapes a block marker at the start of a paragraph continuation line in MarkdownRenderer.render_paragraph(). But the GFM extension overrides render_paragraph() for the Markdown renderer, to write the checkbox of a task list item, and it renders the children itself, so with extensions=["gfm"] the escaping doesn't happen:

>>> md = marko.Markdown(renderer=MarkdownRenderer, extensions=["gfm"])
>>> md("foo\n    # bar\n")
'foo\n# bar\n'
<!-- before: one paragraph -->
<p>foo
# bar</p>
<!-- after re-rendering: a paragraph and a heading -->
<p>foo</p>
<h1>bar</h1>

The rendering of the paragraph's children, with the escaping, is moved to MarkdownRenderer._render_paragraph_children(), which render_paragraph() and the GFM override both use. The output of MarkdownRenderer itself is unchanged, and the GFM override still writes the checkbox.

Added test_render_paragraph_continuation_block_start to TestGFMTableLlistElement, with a task list item; its three cases fail on master. Across the GFM spec examples, the number whose re-rendered Markdown gives different HTML with the GFM extension goes from 23 to 18 (examples 19, 40, 57, 214 and 290, the same ones #310 fixed without the extension). pytest tests, black, isort and flake8 pass, and mypy reports the same 5 errors as on master.

Used Claude (Opus) to help find and patch this; I reviewed and tested the change

@human-attestation

Copy link
Copy Markdown

🛡️ Human Attestation required. A human needs to confirm this PR once before it can merge.

Attest this PR — sign in with GitHub, pass the challenge, and confirm one of the statements.

@frostming
frostming merged commit 0c80f4d into frostming:master Nov 11, 2026
19 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants