Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions scripts/pr_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,9 @@
FENCE = re.compile(r"^ {0,3}```.*?^ {0,3}```[^\n]*", re.DOTALL | re.MULTILINE)
# An inline code span is a quotation for the same reason a fenced block is.
# A reviewer naming `<summary>` in prose was read as opening one.
# That swallowed the body from there to the next real close tag.
# The backreference between two boundary guards matches the run length exactly.
# So a one-backtick span carrying a two-backtick run closes on its own run.
# A span cannot cross a blank line, per CommonMark.
# Unbounded it paired two stray backticks and masked every marker between them.
# Replaced by a space rather than deleted, since deleting joins the text on either side.
# ``<summary`x`>`` would otherwise become an opening tag the body never carried.
# A space also leaves nothing unprintable in a marker this script quotes to a reader.
CODE_SPAN = re.compile(r"(?<!`)(`+)(?!`)(?:[^\n]|\n(?!\s*\n))*?(?<!`)\1(?!`)")
# Bounded to a paragraph, and an escaped tick delimits nothing, since either masks a section.
# Replaced by a space, since deleting joins the sides into a tag the body never carried.
CODE_SPAN = re.compile(r"(?<![\\`])(`+)(?!`)(?:[^\n]|\n(?!\s*\n))*?(?<![\\`])\1(?!`)")
Comment thread
qodo-code-review[bot] marked this conversation as resolved.
Outdated
Comment thread
Copilot marked this conversation as resolved.
Outdated


# The round's own file summary table, whose first column is a path and whose second is prose.
Expand Down
13 changes: 13 additions & 0 deletions scripts/tests/test_pr_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -1700,6 +1700,19 @@ def test_a_real_coverage_line_survives_the_code_span_mask(self) -> None:
line = "- **Files reviewed:** 31/31 changed files"
self.assertEqual([line], pr_review.coverage_statements(OVERVIEW + "\n" + line + "\n"))

def test_an_escaped_backtick_does_not_open_a_span(self) -> None:
"""A backslash-escaped backtick is a literal, so it delimits nothing.

Read as an opener it paired with the next real tick and masked everything between, which
is the silent direction: a genuine unknown section disappears and the loop closes on a
body nobody read.
Comment thread
ptr727 marked this conversation as resolved.
Outdated
"""
body = (
OVERVIEW
+ "\nEscaped \\` then <details><summary>Bogus</summary></details> then ` a span `."
)
self.assertIn("summary: Bogus", pr_review.unrecognized_in(body))
Comment thread
Copilot marked this conversation as resolved.
Outdated

Comment thread
ptr727 marked this conversation as resolved.
def test_every_vetted_marker_together_reads_as_recognized(self) -> None:
"""The corpus shape in one body, so the lists are held against what they were built from."""
self.assertEqual([], pr_review.unrecognized_in(nested()))
Expand Down