Markdown nested code blocks delimited by tildes error
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 52.3k
- Forks
- 5k
- Avg merge
- 19h 2m
- Merged PRs (30d)
- 117
Description
Prettier 2.8.7
Playground link
--parser markdown
Input:
```markdown
**This is markdown**
~~~json
"this is json"
~~~
```
Output:
```markdown
**This is markdown**
```json
"this is json"
```
```
Expected behavior:
```markdown
**This is markdown**
~~~json
"this is json"
~~~
```
or
````markdown
**This is markdown**
```json
"this is json"
```
````
Hey Prettier crew. I was writing a blog post about how to write Markdown code blocks inside Markdown code blocks. There are multiple ways of doing this, the easiest being to use different numbers of backticks (`) for each nested code block. Another way of doing it is to use, for example, triple backticks for the outer code block and then triple tildes for the inner one. That's what I used in the example above.
The issue, though, is that Prettier is converting the triple tildes to triple backticks. With that change, my Markdown parser (GFM through Kramdown on Jekyll) is no longer able to delimit between the outer and inner code blocks.
Suggestions:
- Prettier should leave tilde-delimited code blocks inside other code blocks alone, or
- Prettier should convert the tildes into backticks and automatically increase the number of backticks in the parent code block.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the reported case in the Prettier Playground with --parser markdown, using the nested backtick and tilde examples in the issue. Trace the Markdown formatting entry point and verify that formatting preserves a tilde-delimited inner block or safely increases the parent fence when converting it. Done when the output remains correctly delimited in the stated examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100