Tab width should not affect text alignment after the bullet points in Markdown lists
See original GitHub issueThis is a nested list as given in CommonMark tutorial:
* Item
1. First Subitem
2. Second Subitem
* Item
- Subitem
- Subitem
* Item
It is formatted like this with --tab-width=4
(four is a safer value than two):
- Item
1. First Subitem
2. Second Subitem
- Item
- Subitem
- Subitem
- Item
I expected this output (just *
replaced with -
):
- Item
1. First Subitem
2. Second Subitem
- Item
- Subitem
- Subitem
- Item
Reasoning:
- It’s the natural form in which nested lists are written.
- I believe it would be less work for Prettier.
- It is similarly easy to look at. There will be personal preferences here but I don’t think Prettier generally worries about beautification too much, as long as the code is “correct” (whatever that means in Markdown), reasonably formatted and consistent with common practices.
- It feels illogical to me to apply
--tab-width
both before and after the bullet, also, there is an internal inconsistency when setting tab width greater than 5 as you can see in--tab-width=5
vs.--tab-width=6
. - As a small bonus, the new formatting would be compatible with markdownlint.
I know that nested lists are one of the trickiest parts of Markdown so maybe I’m missing some non-obvious reason why list texts are aligned the way they are. If that was a purely aesthetic decision, I wanted to create this issue as a counter-argument as I believe simplicity and consistency are generally preferred in Prettier over attempts at beautification.
(As a side note, I ran Prettier over hundreds of Markdown files in our repo and it did a great job overall, better than I expected. That is admirable with virtually zero config options. 👍)
Issue Analytics
- State:
- Created 5 years ago
- Reactions:84
- Comments:24 (5 by maintainers)
Top Results From Across the Web
Tab space in Markdown - Stack Overflow
In Markdown, as any markup languages, the tab space collapses to a single space. Also, several consecutive horizontal whitespace (e.g. spaces, ...
Read more >Extended Syntax - Markdown Guide
You can align text in the columns to the left, right, or center by adding a colon ( : ) to the left,...
Read more >Working with Tables in GitHub Markdown - Pluralsight
The second row is just metadata for the table that determines how the text will be vertically aligned. Each column can be aligned...
Read more >Markdown reference for Microsoft Learn - Contributor guide
To indent text to align with a preceding paragraph or an item in a numbered or bulleted list, use spaces. The following two...
Read more >Why is my sub bullet indendtun g
Unlike Word, PowerPoint does not automatically use different bullets for different list levels. Press the tab key on your keyboard before your first...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Actually I wouldn’t. This is a bug. There’s no way on earth that this output is correct:
Hello, I have the same problem with @borekb. My Vscode is ver.1.35.1 and Prettier is ver.1.9.0.