← Back to Pull requests

fix: don't treat a backtick fence with a backtick in its info string as a fence opener #4268

Open
unknown opened this pull request with 323 lines diff across 4 files
View on GitHub
unknown unknown commented on Nov 21, 2026 08:08 UTC
Author

Marked version: 18.2.1 (master at 6c2a5ab4)

Markdown flavor: CommonMark|GitHub Flavored Markdown

Description

  • No existing issue. Found by comparing marked with commonmark.js on generated inputs.
  • Expectation

    CommonMark §4.5: the info string after a backtick fence can't contain a backtick, so a line like ``` ` ``` is not a fence opener. It's ordinary paragraph text, so it can be a setext heading's content and a lazy continuation line in a list item.


    ===
    
    should render `<h1>
    </h1>, and

    - foo
    

    
    should keep 
    `` ``` in the list item's paragraph.

    Result

  • Setext heading: <p>`` \n===</p> (master, commonmark)

  • List item: the list ends and `` ` ``` becomes a separate paragraph (master, commonmark)
  • The fences tokenizer and the paragraph interrupt rule already reject these lines, but the lheading lookaheads ( {0,3}(?:{3,}|~{3,})`) and fencesBeginRegex (used by list()) match any line that starts with three backticks.

    What changed

  • lheading / lheadingGfm: the fence lookahead only matches a backtick fence when the rest of the line has no backtick, same as the fences rule and the paragraph interrupt.

  • fencesBeginRegex: same check, so an invalid fence line no longer ends a list item, either as the next line or as the line before a lazy line.

  • New spec test/specs/new/fences_invalid_backtick_info` covers both setext underlines, multi-line heading content, a lazy line in a list item, a setext heading inside a list item, and lazy text after the invalid fence line. The expected output matches commonmark.js.
  • Contributor

  • Test(s) exist to ensure functionality and minimize regression (if no tests added, list tests covering this PR); or,

  • no tests required for this PR.

  • If submitting new feature, it has been documented in the appropriate places.
  • Committer

    In most cases, this should be a different person than the contributor.

  • CI is green (no forced merge required).

  • Squash and Merge PR following conventional commit guidelines.
  • Diff: 323 lines (+242 / -81) across 4 files Reviewer: UziTech Review duration: 6836m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.42) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 323 lines diff across 4 files
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.346
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #4268"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.0% (MEDIUM) · Higher = larger blast radius
    42.0%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 22.4% · Safe to merge
    22.4%