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 writer: incorrect word wrapping when a list item has a very long word #5033

Closed
lollipopman opened this issue Oct 30, 2018 · 6 comments

Comments

@lollipopman
Copy link
Contributor

When a list item has a word that extends beyond the column setting, the previous list entry is not wrapped correctly:

test:

; pandoc -f gfm -t gfm <<EOF
>   - The next line should be joined
>     here.
>   - asaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
> EOF
  - The next line should be joined
    here.
  - asaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

expected output:

  - The next line should be joined here.
  - asaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

version:

; pandoc -v
pandoc 2.3.1
Compiled with pandoc-types 1.17.5.1, texmath 0.11.1, skylighting 0.7.2
@jgm
Copy link
Owner

jgm commented Oct 30, 2018

Possibly an issue in Text.Pandoc.Pretty.

@agusmba
Copy link
Contributor

agusmba commented Oct 31, 2018

Isn't this what --wrap is for?

$ pandoc -f gfm -t gfm --wrap=none <<EOF
>   - The next line should be joined
>     here.
>   - asaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
> EOF
  - The next line should be joined here.
  - asaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

@agusmba
Copy link
Contributor

agusmba commented Oct 31, 2018

My previous comment could be a workaround as I believe that the default --wrap=auto should also yield the expected result, but it doesn't:

$ pandoc -f gfm -t gfm --wrap=auto --columns=72 <<EOF
>   - The next line should be joined
>     here.
>   - asaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
> EOF
  - The next line should be joined
    here.
  - asaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

EDIT: note that if the second list item line isn't as long, the wrapping works correctly

@jgm
Copy link
Owner

jgm commented Oct 31, 2018

If anyone wants to diagnose this, I'd do it by using traceShowId from Debug.Trace to inspect the Doc produced by the markdown writer before it is rendered. Then try to reproduce the issue directly with Text.Pandoc.Pretty.

Ignore that: it's gfm, so libcmark is doing the formatting/wrapping.
Nothing to do with any code in pandoc itself.

@jgm
Copy link
Owner

jgm commented Nov 1, 2018

This can be reproduced with the cmark executable:

% ./cmark -t commonmark --width 80
  - the next line should be joined
    here
  - aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  - the next line should be joined
    here
  - aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

So the issue should really be reported to cmark

@jgm jgm closed this as completed Nov 1, 2018
jgm added a commit to commonmark/cmark that referenced this issue Nov 1, 2018
@jgm
Copy link
Owner

jgm commented Nov 1, 2018

Never mind, I just fixed this on cmark.
The fix will propagate to pandoc after the cmark change floats up to cmark-gfm and then the gfm haskell wrapper.

talum pushed a commit to github/cmark-gfm that referenced this issue Sep 14, 2021
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

3 participants