prettier / prettier/prettier

Interpolation in markdown tagged literal breaks formatting

Open
#16,612 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
52.3k
Forks
5k
Avg merge
19h 2m
Merged PRs (30d)
117

Description

Prettier 3.3.3
Playground link

--parser babel

Input:

const literal = md`
1. One
3. Two 
`;

const interpolated = md`
1. One
3. Two ${arg}
`;

const literalHTML = html`<p>
hello!
</p>`;

const interpolatedHTML = html`<p>
hello ${arg}!
</p>`;


Output:

const literal = md`
1. One
2. Two
`;

const interpolated = md`
1. One
3. Two ${literal}
`;

const literalHTML = html`<p>hello!</p>`;

const interpolatedHTML = html`<p>hello ${arg}!</p>`;

Expected output:

const interpolated = md`
1. One
2. Two ${arg}
`;

Markdown-in-js works as expected when it is a literal, but fails when there are interpolated values.

I tried something similar for embedded HTML, and it returns the same formatted result regardless of interpolation.


Did some digging and realize interpolated markdown was never a feature.

Will be interested to experiment with supporting it. Will likely give it a go when #13676 lands.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Prettier Playground example and compare the literal and interpolated markdown outputs. Read the discussion around supporting interpolated markdown and #13676; done means interpolated markdown preserves the intended list numbering and formatting while retaining the embedded value.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, markdown
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.