-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Description
Prettier 1.9.1
Playground link
--parser markdownInput:
Code blocks may be nested within list items per the original Markdown syntax for lists:
To put a code block within a list item, the code block needs to be indented twice
— 8 spaces or two tabs:
1. Change to your home directory:
········cd
2. List the contents:
········ls -l
Output:
Prettier strips the 8 leading spaces and replaces them with 3 to align with the list item content:
1. Change to your home directory:
···cd
2. List the contents:
···ls -l
This treats the nested code blocks as subsequent paragraphs in the list items rather than as code blocks:
-
Change to your home directory:
cd
-
List the contents:
ls -l
Expected behavior:
The original input should either be preserved, indented with tabs or fenced to ensure the nested code blocks are rendered properly:
-
Change to your home directory:
cd -
List the contents:
ls -l
Subsequent runs change result
If the nested code blocks are indented with 2 tabs (rather than 8 spaces), they are initially converted to 7 spaces. If the same file is saved again, the 7 spaces are converted to 3 spaces.
Fenced code blocks as workaround
If the nested code blocks are fenced, the input is preserved and output is generated as expected:
1. Change to your home directory:
```sh
cd
```
2. List the contents:
```sh
ls -l
```