← Back to Pull requests

fix: keep text after a nested list tight inside a list item #4269

Open
unknown opened this pull request with 302 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 21, 2026 08:09 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

    Text that follows a nested list inside a tight list item is part of that tight item, so it shouldn't be wrapped in <p>:

    - -
      foo
    

    should render <li><ul><li></li></ul>foo</li>, and

    - - a
      # heading
      bar
    

    should render bar without a <p> after the heading.

    Result

    foo / bar are rendered as <p>foo</p> / <p>bar</p> even though the outer list is tight (master, commonmark; master, commonmark).

    list() sets lexer.state.top = false before lexing each item, but blockTokens() sets state.top = true when it returns. After a nested list is lexed, the rest of the enclosing item is lexed with top === true, so paragraph is used instead of text. The same thing happens after a nested list ended by a heading, thematic break, or fenced code block, and inside block quotes.

    What changed

  • list() saves lexer.state.top before lexing its items and restores it afterwards, like blockquote() already does.

  • New spec test/specs/new/list_nested_list_then_text_tight covers text after an empty nested item, after a heading, a thematic break and a fenced code block that end the nested list, and the same case inside a block quote. 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: 302 lines (+226 / -76) across 3 files Reviewer: UziTech Review duration: 6835m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.40) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 302 lines diff across 3 files
    0.40
    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
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.342
    Real PR Conversation Timeline
    1 comments
    "Review active on #4269"
    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: 40.1% (MEDIUM) · Higher = larger blast radius
    40.1%
    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: 21.4% · Safe to merge
    21.4%