Skip to content

Markdown: respect useTabs for indented code blocks and footnote bodies#19352

Open
WhoamiI00 wants to merge 2 commits into
prettier:mainfrom
WhoamiI00:fix/markdown-use-tabs
Open

Markdown: respect useTabs for indented code blocks and footnote bodies#19352
WhoamiI00 wants to merge 2 commits into
prettier:mainfrom
WhoamiI00:fix/markdown-use-tabs

Conversation

@WhoamiI00

@WhoamiI00 WhoamiI00 commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes a subset of #8782 — when useTabs is enabled, Prettier was still emitting four literal spaces for indented code blocks and for the 4-column alignment used inside footnote definitions.

CommonMark explicitly treats a tab as advancing to the next 4-column stop (spec §2.2), so a single \t is structurally equivalent to four spaces for both of these cases — the document still parses as an indented code block / footnote continuation, and tabWidth doesn't change that (the 4-column rule is fixed by the spec, not by Prettier's setting).

List-item alignment is intentionally not changed in this PR: list prefixes (- , 1. , …) are not multiples of 4 columns, so substituting a tab there would actually break the structure. That part of #8782 needs a separate, more involved fix.

Before / after

<!-- Input (with `--use-tabs`) -->
# Indented code block

	first line
	second line

[^x]: Footnote

	Continuation paragraph.
<!-- Prettier stable (4 spaces — ignores --use-tabs) -->
# Indented code block

    first line
    second line

[^x]: Footnote

    Continuation paragraph.
<!-- Prettier main (tab — respects --use-tabs) -->
# Indented code block

	first line
	second line

[^x]: Footnote

	Continuation paragraph.

Checklist

  • I've added tests to confirm my change works.
  • (If changing the API or CLI) I've documented the changes I've made (in the docs/ directory).
  • (If the change is user-facing) I've added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I've read the contributing guidelines.
  • I did not use AI to generate this PR.
  • (If the above is not checked) I have reviewed the AI-generated content before submitting.

WhoamiI00 added 2 commits June 13, 2026 22:56
In Markdown, an indented code block must be indented by 4 columns, and
CommonMark explicitly treats a tab as advancing to the next 4-column
stop. When `useTabs` is enabled, emitting four spaces ignores the user's
indentation preference even though a single tab is a spec-equivalent
substitute. Apply the same reasoning to the 4-column alignment used for
subsequent blocks inside a footnote definition.

Fixes prettier#8782 for the cases where the spec allows a tab without altering
the document structure. List-item alignment is left unchanged because
its prefix width is not a multiple of 4.
@netlify

netlify Bot commented Jun 13, 2026

Copy link
Copy Markdown

Deploy Preview for prettier ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 897507c
🔍 Latest deploy log https://app.netlify.com/projects/prettier/deploys/6a2d9327a8dbf50008ac8888
😎 Deploy Preview https://deploy-preview-19352--prettier.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

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.

1 participant