Repository navigation
fix(ci): a fence opened inside a blockquote must close with the quote - #170
Merged
Merged
Conversation
_strip_fences in launchpad/scripts/pr_body_check.py strips blockquote markers before matching a fence, but kept no record of the container a fence opened in. A fence opened with `> ` and never explicitly closed stayed open past the blockquote's own end, consuming every remaining line — including a `Refs #<n>` GitHub renders as ordinary prose once the quote ends, blocking a compliant PR for appearing to have no issue reference at all. CommonMark ends a block quote lazily: a line with no `>` marker (a blank line included, since a bare `>` strips to empty) closes it, the same way a blank line ends one at the top level. A fence carries no memory of its container, so one opened inside a quote must close when the quote does — it cannot lazily continue past the boundary the way a paragraph can't either. _strip_fences now tracks whether the currently-open fence started inside a quote. On each line, if that's true and the raw line no longer carries a blockquote marker, the fence is force-closed before the line is evaluated — so it falls through to ordinary prose handling (or a new fence opening) instead of being silently swallowed as leftover fence content. Three new tests: the core fix (issue's own repro), the same defect with a bare blank line instead of an omitted one, and a regression guard — a fence that closes explicitly while still inside the quote must still close there, not run to the quote's end regardless. Confirmed the first two fail against the pre-fix code with the exact symptom described (the Refs line vanishes) and the regression guard already held. Verified: $ python3 -m unittest test_pr_body_check Ran 47 tests in 0.004s OK Closes #145 Signed-off-by: Serina Mcfall <serina.mcfall@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_strip_fencesinlaunchpad/scripts/pr_body_check.pykept no record of whether a fence opened inside a blockquote, so one opened with>and never explicitly closed stayed open past the quote's own end — silently consuming aRefs #<n>GitHub renders as ordinary prose, and blocking a compliant PR for appearing to have no issue reference.Related issue
Closes #145
Issue type
Bug
Agent provenance
Objective
Make
_strip_fencesclose a fence when the blockquote that contains it ends, so prose after the quote is no longer swallowed as leftover fence content.Impacted components
launchpad/scripts/pr_body_check.py(_strip_fences)launchpad/scripts/test_pr_body_check.pyApproach and rejected alternatives
Track whether the currently-open fence started inside a quote (
fence_in_quote). On each subsequent line, if that flag is set and the raw line no longer carries a blockquote marker, force-close the fence before evaluating the line — so it falls through to ordinary prose handling instead of being swallowed.Rejected: tracking full blockquote depth (nesting level) rather than a simple in-quote boolean. The issue's own converse case ("a quoted ``` closing an unquoted fence") is explicitly out of scope, and #145 only needs to know "did this fence open inside any quote, and has that quote now ended" — a boolean is sufficient and simpler to reason about than tracking depth for a case not being fixed here.
Verification
Command run:
Raw output:
Confirmed the two new core tests fail against the pre-fix code with the exact symptom the issue describes:
and that the regression guard (a fence that closes explicitly while still inside the quote must still close there) already held before the fix — confirming it guards against over-correction rather than duplicating the core fix's own assertion.
Not verified
commonmark.jsor similar.Security implications
None. This only affects which lines of a PR body are treated as prose vs. code for the purpose of finding an issue-closing reference; it has no effect on repository content, secrets, or access.
Escalations
None — the fix follows directly from CommonMark's documented lazy-continuation rule, and the issue's own scope notes (bare
>in-scope, quoted-fence-closing-unquoted-fence out-of-scope) left no ambiguity to resolve.