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

[Markdown] Dash-separated long list items rendered as sublist #6497

Closed
kdeldycke opened this issue Jul 1, 2020 · 5 comments
Closed

[Markdown] Dash-separated long list items rendered as sublist #6497

kdeldycke opened this issue Jul 1, 2020 · 5 comments

Comments

@kdeldycke
Copy link

kdeldycke commented Jul 1, 2020

Here is a Markdown file with a list of very long items:

❯ cat ./dash-separated-link-list.md
- [Link 1](#link-1) - Description of line 1.
- [Link 2](#link-2) - A very long description for the second link in the list. That description is more than 80 characters wide.
- [This is a very long title, pointing to an awesome article on incredible stuff we're not used to see everyday](#link-3) - Line #3's description.
- [Link number three](#this-is-a-very-long-url-that-is-pointing-to-a-really-really-great-website) - Fourth description.

Which renders into a clean list of four items:

Now I want to clean this file and have pandoc automatically wraps long lines. Here is the CLI I run:

❯ pandoc ./dash-separated-link-list.md --to=gfm
  - [Link 1](#link-1) - Description of line 1.
  - [Link 2](#link-2) - A very long description for the second link in
    the list. That description is more than 80 characters wide.
  - [This is a very long title, pointing to an awesome article on
    incredible stuff we’re not used to see everyday](#link-3) - Line
    \#3’s description.
  - [Link number
    three](#this-is-a-very-long-url-that-is-pointing-to-a-really-really-great-website)
    - Fourth description.

Which renders to:

You can see how the fourth description is rendered as a sub-list because of the dash? I think this is a bug.

What's interesting in this case is that other variants of Markdown seems to account for this edge-case and keep the dash in the previous line to prevent accidental rendering of sublists:

❯ pandoc ./dash-separated-link-list.md --to=markdown_github
[WARNING] Deprecated: markdown_github. Use gfm instead.
-   [Link 1](#link-1) - Description of line 1.
-   [Link 2](#link-2) - A very long description for the second link in
    the list. That description is more than 80 characters wide.
-   [This is a very long title, pointing to an awesome article on
    incredible stuff we’re not used to see everyday](#link-3) - Line
    \#3’s description.
-   [Link number
    three](#this-is-a-very-long-url-that-is-pointing-to-a-really-really-great-website) -
    Fourth description.

❯ pandoc ./dash-separated-link-list.md --to=markdown_mmd
-   [Link 1](#link-1) - Description of line 1.
-   [Link 2](#link-2) - A very long description for the second link in
    the list. That description is more than 80 characters wide.
-   [This is a very long title, pointing to an awesome article on
    incredible stuff we’re not used to see everyday](#link-3) - Line
    \#3’s description.
-   [Link number
    three](#this-is-a-very-long-url-that-is-pointing-to-a-really-really-great-website) -
    Fourth description.

❯ pandoc ./dash-separated-link-list.md --to=markdown_strict
-   [Link 1](#link-1) - Description of line 1.
-   [Link 2](#link-2) - A very long description for the second link in
    the list. That description is more than 80 characters wide.
-   [This is a very long title, pointing to an awesome article on
    incredible stuff we’re not used to see everyday](#link-3) - Line
    \#3’s description.
-   [Link number
    three](#this-is-a-very-long-url-that-is-pointing-to-a-really-really-great-website) -
    Fourth description.

For the record, here is my version of pandoc, straight out of brew on macOS Catalina:

❯ pandoc --version
pandoc 2.9.2.1
Compiled with pandoc-types 1.20, texmath 0.12.0.1, skylighting 0.8.3.2
@jgm
Copy link
Owner

jgm commented Jul 1, 2020

For gfm we use libcmark's renderer, which in this respect is less sophisticated than the native pandoc renderers. (Of course I could do something about this, since I'm also the maintainer of libcmark, but it would have to be fixed there: commonmark/cmark on GitHub. You can report this there if you like.)

@kdeldycke
Copy link
Author

Thanks @jgm for the tip. I just reproduced the bug with the standalone cmark CLI and created a bug report at commonmark/cmark#347 .

@kdeldycke
Copy link
Author

BTW @jgm, what do you think of @DavidAnson workaround at DavidAnson/markdownlint#302 (comment) of using link references?

@jgm
Copy link
Owner

jgm commented Jul 13, 2020

I'll close here, since it's really an upstream issue.
Yes, using link references can help in particular cases.

@jgm jgm closed this as completed Jul 13, 2020
@kdeldycke
Copy link
Author

Fair enough! Thanks @jgm for the feedback! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants