Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prettier support #751

Closed
lydell opened this issue Nov 6, 2018 · 7 comments
Closed

Prettier support #751

lydell opened this issue Nov 6, 2018 · 7 comments
Labels
3rd-party Should be implemented as a third party extension. duplicate The issue has been previously reported.

Comments

@lydell
Copy link
Contributor

lydell commented Nov 6, 2018

I know about #451 and about the following:

https://daringfireball.net/projects/markdown/syntax#list

List items may consist of multiple paragraphs. Each subsequent paragraph in a list item must be indented by either 4 spaces or one tab

But not even the original markdown implementation follows that. Try pasting the following:

- one

  two

…in https://daringfireball.net/projects/markdown/dingus. Result:

<ul>
<li><p>one</p>

<p>two</p></li>
</ul>

And since then, CommonMark has gained popularity, and it allows fewer spaces:

https://spec.commonmark.org/0.28/#example-219

- one

  two
<ul>
<li>
<p>one</p>
<p>two</p>
</li>
</ul>

And here’s the thing: Prettier can auto-format markdown, and it uses CommonMark spec. Which unfortunately means that it turns more 4 spaces into the more good-looking 2 spaces:

Prettier 1.14.3
Playground link

--parser markdown

Input:

- one

    two

Output:

- one

  two

Which means that I cannot use Prettier to format markdown that will be parsed using this package :(

Would you be willing to reconsider this?

  • Not even the original implementation follows the 4 space rule.
  • Most markdown implementations don’t either.
  • Being able to use Prettier would be awesome!

EDIT: This fixes the issue: https://github.com/radude/mdx_truly_sane_lists

@waylan
Copy link
Member

waylan commented Nov 6, 2018

Not even the original implementation follows the 4 space rule.

I consider this a bug and will never be convinced otherwise.

Most markdown implementations don’t either.

Those implementation also have a bug.

As an side, I do not consider CommonMark to be Markdown (but a derivative). Therefore, it is not relevant to this discussion.

Being able to use Prettier would be awesome!

Great. Then you may implement your own extension which supports that syntax.

Finally, all of these points have been discussed with more detail elsewhere. Therefore this is a duplicate.

@waylan waylan closed this as completed Nov 6, 2018
@waylan waylan added duplicate The issue has been previously reported. 3rd-party Should be implemented as a third party extension. labels Nov 6, 2018
@lydell
Copy link
Contributor Author

lydell commented Nov 6, 2018

Thanks for answering!

all of these points have been discussed with more detail elsewhere

Where?

EDIT: Here: #3, #125, #227, #313, #442, #451.

@lydell
Copy link
Contributor Author

lydell commented Nov 6, 2018

Also, just out of pure curiosity: What's the benefit of enforcing 4 spaces?

Allow fewer spaces:
Pros: Wide compatibility (28 impls support it, 5 doesn't)
Cons: None?

Enforce 4 spaces:
Pros: ???
Cons: Worse compatibility

@mitya57
Copy link
Collaborator

mitya57 commented Nov 6, 2018

Cons of fewer spaces are:

  • Breaking compatibility. The existing documents will start to render differently.
  • Breaking the Markdown specification, which is the first place to look at for syntax rules. The Markdown.pl implementation is only on the second place, we look there only if the spec is not clear enough.

@lydell
Copy link
Contributor Author

lydell commented Nov 6, 2018

Cool, thanks for the answer!

Breaking compatibility. The existing documents will start to render differently.

Yeah, backwards compatibility is important. 👍

Breaking the Markdown specification, which is the first place to look at for syntax rules.

Even the HTML standard has made changes after de facto usage in browsers. ¯\_(ツ)_/¯

Still, my question was what the benefit of 4 spaces was. Is there any?

@facelessuser
Copy link
Collaborator

I can't honestly say there is a benefit to 4 spaces. It's just what the spec had said. And now with a history of support for this behavior, it is hard to break it now. This is a really a discussion of what is better as much as what the original spec indicated. That is generally the aim of Python Markdown, that and the ability to easily extend it to whatever you want.

With that said, there is no reason you can't implement an extension to do as you desire. Even as a member of this team, I try not to push my personal preferred syntax, and instead keep it to my own 3rd party extensions.

If you don't want to write your own extension, you may find that there is an extension for this already somewhere, I haven't looked.

As an alternative to writing your own extension, I've seen people mitigate the "ugliness" by indenting their lists two spaces so everything lines up:

  - List 1
  - List 2
    - Sub list A paragrah 1
       
       Sublist A paragraph 2
  • List 1
  • List 2
    • Sub list A paragrah 1

      Sublist A paragraph 2

Anyways, there are options available.

@lydell
Copy link
Contributor Author

lydell commented Nov 6, 2018

Thanks, I found an extension that works for me in one of the other 6 duplicates: https://github.com/radude/mdx_truly_sane_lists

I've made a PR to mention it in the docs: #752

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3rd-party Should be implemented as a third party extension. duplicate The issue has been previously reported.
Projects
None yet
Development

No branches or pull requests

4 participants