Repository navigation
Read Code Spans, Inline HTML, and Autolinks Left to Right in pr_review.py - #3264
Conversation
…w.py GitHub binds a code span, raw inline HTML, and an autolink by which one opens first, so a backtick inside an HTML comment, a tag's quoted value, a processing instruction, a declaration, a CDATA section, or an autolink that opened earlier opens no span. CODE_SPAN paired that backtick with a later one, so a live tag between them read as quoted. CODE_SPAN is now a CodeSpans reader whose one pattern reads all three, each match consuming its own text, and only spans are reported. Its sub, finditer, and search keep the shape every caller already used. Each opener and each near-miss is pinned from a GitHub rendering. Refs #3235 Co-Authored-By: Claude Opus 5.5 <[email protected]>
A line holding only blockquote markers ends the paragraph above it on GitHub, so PARAGRAPH_BREAK now stops there. A code span and every multi-line inline HTML reader built on it no longer run across one. A comment's text may hold "--->" before a later "-->", which GitHub reads as the close, so the comment reader no longer stops at the first "-->" it meets. attributes()' docstring now scopes its one-tail claim to HTML's own attribute reading, since TAG_ATTRIBUTE reads CommonMark's grammar. Refs #3235 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Refs #3235 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
A recorded local strict-review pass covers head |
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved parsing correctness and documentation issues remain.
2 open issues
What changed in this PR
This PR updates code-span parsing to respect inline HTML, autolinks, and paragraph boundaries in left-to-right order.
Changes:
- Adds the
CodeSpansreader and inline HTML grammar. - Expands regression coverage for HTML, autolinks, and paragraph boundaries.
- Clarifies shared attribute grammar documentation.
| File | Summary | Findings |
|---|---|---|
scripts/pr_review.py |
Implements left-to-right span and inline HTML parsing. | P2: handle even-length backslash runs before <; P2: clarify the attributes() docstring scope. |
tests/test_pr_review.py |
Adds regression coverage for parsing behavior and boundaries. | P3: correct the test docstring grammar. |
Review effort: Lite
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #3264 +/- ##
==========================================
Coverage ? 65.49%
==========================================
Files ? 17
Lines ? 10011
Branches ? 0
==========================================
Hits ? 6557
Misses ? 3454
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Two backslashes escape each other, so the "<" after an even run opens live HTML, and the reader now takes that run as part of the match. The attributes() docstring again names every reader of the shared tail, HTML_TAG included. Refs #3235 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
A recorded local strict-review pass covers head |
…and File-Naming Check to Main (#3266) ## Summary Promotes eight pull requests from develop. Three are `pr_review.py` reader fixes from this round, one answers this promotion's first review, and four are from other sessions. - #3261: each heading, thematic-break, and fence shape in `pr_review.py` has one primitive that every reader composes from. A no-break space after a heading's hashes no longer opens a heading, and a tab-spaced thematic break or setext underline closes its block. - #3262: when `wait` returns `50` at once on an uncounted-verdict head while a check has not concluded, it names a bounded `gh pr checks --watch` to watch the checks with. - #3264: `CODE_SPAN` reads code spans, raw inline HTML, and autolinks left to right, as GitHub binds them, so a backtick inside an earlier HTML comment, tag, or autolink opens no span. A line of only blockquote markers now ends a paragraph. - #3256: `pr_review.py wait` reads a superseded run's failed aggregator as superseded rather than as a verdict on the head. - #3258: a `driftNote` can exempt a tool-fixed script name from the file-naming check. - #3253: an audit check for file naming, including secret-file stem casing. - #3249: the Linux quick start names the no-sudo Debian case. - #3267: splits the over-long and two-instruction sentences that this promotion's first Copilot round found in #3249's paragraph. Closes #3241 Closes #3246 Closes #3235 Closes #3252 Closes #3254 Closes #3141 Closes #2551 🤖 Generated with [Claude Code](https://claude.com/claude-code)

Summary
GitHub binds a code span, raw inline HTML, and an autolink by which one opens first (#3235). So a backtick inside an earlier HTML comment, tag attribute value, processing instruction, declaration, CDATA section, or URI or email autolink is literal and opens no span.
CODE_SPANpaired that backtick with a later one, so a live tag between them read as quoted, andunwrapprinted it raw.CODE_SPANis now aCodeSpansreader. One alternation pattern reads a span first, keeping its backtick run as group 1, thenINLINE_HTML, each match consuming its own text.sub,finditer, andsearchreport only spans, so every caller keeps the interface it used.INLINE_HTMLfollows the grammar GitHub's renderer showed for each construct:<!-->,<!--->, or text not ending in-closed by--><escapes itPARAGRAPH_BREAKandIN_PARAGRAPHgive the span and the multi-line HTML readers one paragraph bound. That bound now also ends at a line holding only blockquote markers, which GitHub ends a paragraph at, quoted or not. Spans no longer pair across such a line either.<, the reader's output matches the old regex exactly.Decided in the local review
attributes()stays the lenient tail its tag readers share, andTAG_ATTRIBUTEis CommonMark's stricter inline grammar, which is what decides span binding. Merging them would make one of the two wrong. Theattributes()docstring now names the split.<!--,<?, or<![CDATA[openers in one paragraph cost quadratic time. Reviewer bodies are not adversarial input, and a constructed 196 KB bot-shaped body read in 9 ms.Local review findings listed open after the first push, now fixed
introduced, fixed in 8a7bd39: theattributes()docstring said the tail serves "every reader here looking for a named tag", butHTML_TAGis built on it too and reads any tag name. Copilot raised the same point.Copilot also found that the HTML guard read
\\<as an escaped<. That is fixed in 8a7bd39 too, and the span opener's matching approximation, which predates this PR, is filed as #3265.Refs #3235
🤖 Generated with Claude Code