Skip to content

Read Code Spans, Inline HTML, and Autolinks Left to Right in pr_review.py - #3264

Merged
ptr727 merged 4 commits into
developfrom
feature/span-after-html
Oct 20, 2026
Merged

ptr727 merged 4 commits into
developfrom
feature/span-after-html

Conversation

@ptr727

@ptr727 ptr727 commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

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_SPAN paired that backtick with a later one, so a live tag between them read as quoted, and unwrap printed it raw.

  • CODE_SPAN is now a CodeSpans reader. One alternation pattern reads a span first, keeping its backtick run as group 1, then INLINE_HTML, each match consuming its own text. sub, finditer, and search report only spans, so every caller keeps the interface it used.
  • INLINE_HTML follows the grammar GitHub's renderer showed for each construct:
    • a comment is <!-->, <!--->, or text not ending in - closed by -->
    • a declaration takes an uppercase name and then whitespace
    • an unquoted attribute value excludes a backtick, and a tag name excludes a colon
    • a tag's whitespace carries at most one line break inside the paragraph
    • a backslash before < escapes it
  • PARAGRAPH_BREAK and IN_PARAGRAPH give 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.
  • Every opener and every near-miss in the tests was rendered on GitHub. Over 200,000 constructed strings without a <, the reader's output matches the old regex exactly.

Decided in the local review

Local review findings listed open after the first push, now fixed

  • introduced, fixed in 8a7bd39: the attributes() docstring said the tail serves "every reader here looking for a named tag", but HTML_TAG is 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

ptr727 and others added 3 commits October 20, 2026 07:17
…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]>
Copilot AI lite review requested due to automatic review settings October 20, 2026 14:31
@ptr727 ptr727 added enhancement New feature or request script A defect in hub tooling labels Oct 20, 2026
@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Repository: ptr727/ProjectTemplate/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 03f36c5d-8211-44ed-a74a-b74cabd948c5
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ptr727

ptr727 commented Oct 20, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 1683b9cfc6ad217cd2f726cf58d1406fff605d00, the content this pull request carries at that commit against develop, and it recorded 1 finding.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 CodeSpans reader 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

Comment thread scripts/pr_review.py Resolved
Comment thread scripts/pr_review.py Resolved
@codecov

codecov Bot commented Oct 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (develop@26d6765). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #3264   +/-   ##
==========================================
  Coverage           ?   65.49%           
==========================================
  Files              ?       17           
  Lines              ?    10011           
  Branches           ?        0           
==========================================
  Hits               ?     6557           
  Misses             ?     3454           
  Partials           ?        0           
Flag Coverage Δ
python-3.13 65.49% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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]>
@ptr727

ptr727 commented Oct 20, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 8a7bd39541fe8bdf01fabaf3771dc546a4391698, the content this pull request carries at that commit against develop, and it recorded 0 findings.

@ptr727
ptr727 merged commit 2cb39cb into develop Oct 20, 2026
13 checks passed
@ptr727
ptr727 deleted the feature/span-after-html branch October 20, 2026 14:56
ptr727 added a commit that referenced this pull request Oct 20, 2026
…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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request script A defect in hub tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants