question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tab width should not affect text alignment after the bullet points in Markdown lists

See original GitHub issue

This 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

(Playground)

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:open
  • Created 5 years ago
  • Reactions:84
  • Comments:24 (5 by maintainers)

github_iconTop GitHub Comments

33reactions
glen-84commented, Feb 26, 2022

I’d be just as happy with an opt-out, as would all the other supporters of this issue

Actually I wouldn’t. This is a bug. There’s no way on earth that this output is correct:

-   Item
    1. First Subitem
    2. Second Subitem
-   Item
    -   Subitem
    -   Subitem
-   Item
19reactions
ryul1206commented, Jun 16, 2019

Hello, I have the same problem with @borekb. My Vscode is ver.1.35.1 and Prettier is ver.1.9.0.

prettier-formatting

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found