Skip to content

Commit 98fa584

Browse files
committed
test(render-eval): add visible_open_double_backtick audit rule
Catches asymmetric typographic-quote emission where mandoc emits literal \`\` for the open side while converting '' to U+201D.
1 parent a4f9a2e commit 98fa584

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

tests/evals/render/render_eval.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,7 @@ def diff_report(args: argparse.Namespace) -> int:
903903
_AUDIT_VISIBLE_ZWNJ_RE = re.compile(r"‌")
904904
_AUDIT_VISIBLE_NBSP_RE = re.compile(r" ")
905905
_AUDIT_VISIBLE_DOUBLE_AMP_RE = re.compile(r"&")
906+
_AUDIT_OPEN_DOUBLE_BACKTICK_RE = re.compile(r"\\`\\`")
906907
_AUDIT_SYNOPSIS_HEADING_RE = re.compile(r"^#+\s+SYNOPSIS\s*$", re.IGNORECASE)
907908
_AUDIT_WHITESPACE_RE = re.compile(r"\s")
908909
_AUDIT_UNICODE_ESCAPE_RE = re.compile(r"^u[0-9A-Fa-f]{4,6}$")
@@ -1198,6 +1199,14 @@ def _audit_scan_visible_double_amp(markdown: str, html: str) -> list[tuple[int,
11981199
]
11991200

12001201

1202+
def _audit_scan_open_double_backtick(markdown: str, html: str) -> list[tuple[int, str]]:
1203+
hits: list[tuple[int, str]] = []
1204+
for line_no, line in enumerate(markdown.splitlines(), 1):
1205+
for match in _AUDIT_OPEN_DOUBLE_BACKTICK_RE.finditer(line):
1206+
hits.append((line_no, _audit_snippet(line, match.start(), match.end())))
1207+
return hits
1208+
1209+
12011210
def _audit_scan_giant_markdown_line(markdown: str, html: str) -> list[tuple[int, str]]:
12021211
hits: list[tuple[int, str]] = []
12031212
for line_no, line in enumerate(markdown.splitlines(), 1):
@@ -1262,6 +1271,11 @@ def _audit_scan_synopsis_no_spaces_run(
12621271
_audit_scan_visible_double_amp,
12631272
"double-encoded ampersand &",
12641273
),
1274+
(
1275+
"visible_open_double_backtick",
1276+
_audit_scan_open_double_backtick,
1277+
r"literal `\`\`` in markdown (asymmetric typographic open quote)",
1278+
),
12651279
(
12661280
"giant_markdown_line",
12671281
_audit_scan_giant_markdown_line,

0 commit comments

Comments
 (0)