Skip to content

fix: preserve internal tabs in list item content - #4086

Open
nrps9909 wants to merge 2 commits into
markedjs:masterfrom
nrps9909:codex/fix-list-continuation-tabs
Open

fix: preserve internal tabs in list item content#4086
nrps9909 wants to merge 2 commits into
markedjs:masterfrom
nrps9909:codex/fix-list-continuation-tabs

Conversation

@nrps9909

@nrps9909 nrps9909 commented Sep 5, 2026

Copy link
Copy Markdown

Marked version: 18.0.11, base 4417582f35d69926f0778ee133c3af75b7f3f966

Markdown flavor: CommonMark / GitHub Flavored Markdown

Description

List parsing expands tabs throughout item text before that text reaches code-span or fenced-code tokenization. For example, - \foo\tbar`renders two spaces betweenfooandbar, and a fence continuation containing foo\tbar` renders four spaces. Both should retain the literal tab under CommonMark's tab rules.

Expand only the leading spaces/tabs when preparing list lines. Content after that prefix reaches the child tokenizer unchanged. The first-line calculation retains its existing tab stops, continuation indentation retains its existing behavior, and pedantic mode retains its previous path.

This addresses internal content tabs in the list tokenizer discussed in #4050. It does not close that broad issue: tabs within the leading indentation, including a content tab directly after the list indent, still need original-column tracking across nested containers. It is separate from #4080's indented-code de-indentation change.

Validation:

  • All 16 exact-output spec fixtures fail on the base and pass after the change. The eight scenarios each run with GFM both enabled and disabled and use renderExact: true; cases cover first-line/continuation code spans, backtick/tilde fences, ordered/nested lists, repeated internal tabs, and a structural indentation tab before the content.
  • npm test passes: 1,818 spec-harness tests, 191 unit tests, docs/build, UMD/CJS checks, type/package checks and lint.
  • An independent 2,058-input comparison against commonmark 0.31.2 checks list-marker widths, whitespace prefixes and nested fences. This patch fixes 452 mismatches and introduces zero new mismatches; 1,410 existing mismatches in that deliberately broad corpus remain. The comparison preserves code whitespace while normalizing insignificant HTML formatting.

Implemented and validated with Codex.

Contributor

  • Tests exist to ensure functionality and minimize regression.
  • This fixes existing parsing behavior; no new option is introduced.

Committer

  • CI is green (no forced merge required).
  • Squash and Merge PR following conventional commit guidelines.

@vercel

vercel Bot commented Sep 5, 2026

Copy link
Copy Markdown

@nrps9909 is attempting to deploy a commit to the MarkedJS Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Sep 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
marked-website Ready Ready Preview Sep 5, 2026 8:38pm UTC

Request Review

Comment thread test/unit/marked.test.js

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Move the tests to test/specs/new. You can use renderExact if you need to test white space.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Moved the eight scenarios to test/specs/new/list_content_tabs.json, with separate GFM-on/off cases and renderExact: true on all 16 fixtures. They now compare the complete HTML string, including literal tabs and newlines, through the spec harness. The unit-test block is removed.

All 16 fixtures fail against the original base and pass on the updated branch. Full npm test passes with 1,818 spec-harness tests, 191 unit tests, docs/build, UMD/CJS, type/package checks and lint. The source fix is unchanged.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you move this to .md and .html files? They are easier to view. You can add options as front matter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants