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

Abbreviations within links within strike-throughs break Markdown to PDF generation #8411

Closed
benwbrum opened this issue Nov 1, 2022 · 9 comments
Labels

Comments

@benwbrum
Copy link

benwbrum commented Nov 1, 2022

Explain the problem.
I'm trying to generate a PDF that has a a link within a strike-through. When the anchor text includes a title like Rev. A W McLum, the PDF generation fails. Further investigation shows that this appears with any string in the abbreviations file, followed by a space, if the string is nested within a link that is nested within a strike-through.

$ echo '~~[Sen. Jones](#footnote)~~' | pandoc --from markdown+superscript -o edited.tex --pdf-engine=xelatex  
$ cat edited.tex 
\sout{\protect\hyperlink{footnote}{Sen.~Jones}}

$ echo '~~[Sen. Jones](#footnote)~~' | pandoc --from markdown+superscript -o edited.pdf --pdf-engine=xelatex  
Error producing PDF.
! Extra }, or forgotten \endgroup.
\UL@stop ...z@ \else \UL@putbox \fi \else \egroup 
                                                  \egroup \UL@putbox \fi \if...
l.56 ...{\protect\hyperlink{footnote}{Sen.~Jones}}

This can be circumvented by not using the default abbreviations file, so that Markdown doesn't recognize Rev. or Sen. as an abbreviation:
$ echo '~~[Sen. Jones](#footnote)~~' | pandoc --from markdown+superscript -o edited.pdf --pdf-engine=xelatex --abbreviations=/dev/null

Pandoc version

$ pandoc -v
pandoc 2.19.2
Compiled with pandoc-types 1.22.2.1, texmath 0.12.5.2, skylighting 0.13,
citeproc 0.8.0.1, ipynb 0.2, hslua 2.2.1
Scripting engine: Lua 5.4
User data directory: /home/benwbrum/.local/share/pandoc
Copyright (C) 2006-2022 John MacFarlane. Web:  https://pandoc.org
This is free software; see the source for copying conditions. There is no
warranty, not even for merchantability or fitness for a particular purpose.
$ uname -a
Linux sparckjones 5.4.0-131-generic #147~18.04.1-Ubuntu SMP Sat Oct 15 13:10:18 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
@benwbrum benwbrum added the bug label Nov 1, 2022
@jgm
Copy link
Owner

jgm commented Nov 1, 2022

An easier way to defeat this is to escape the period: Sen\. Jones

@ickc
Copy link
Contributor

ickc commented Nov 18, 2022

I am experiencing the same issue with the following example:

echo '~~[N comparison](example.com)~~' | pandoc -o temp.pdf 
Error producing PDF.
! Extra }, or forgotten \endgroup.
\UL@stop ...z@ \else \UL@putbox \fi \else \egroup 
                                                  \egroup \UL@putbox \fi \if...
l.56 \sout{\href{example.com}{N~comparison}}

@jgm
Copy link
Owner

jgm commented Nov 18, 2022

@ickc this example does not raise an error for me.

@ickc
Copy link
Contributor

ickc commented Nov 18, 2022

After some confusion I found that the example I used has a unicode non-breaking space   where most probably the markdown rendered here turned that into normal space.

Hence it is equivalent to

echo '~~[N\ comparison](example.com)~~' | pandoc -o temp.pdf 
Error producing PDF.
! Extra }, or forgotten \endgroup.
\UL@stop ...z@ \else \UL@putbox \fi \else \egroup 
                                                  \egroup \UL@putbox \fi \if...
l.56 \sout{\href{example.com}{N~comparison}}

where we know why it fails. What's not very obvious is when the source has a non-breaking space, it is hard to understand what's happening (even when I am using an editor that shows space and non-breaking space differently.)

The doc of ulem mentioned they only support ~ in underline. Are there anywhere discussed why we chose ulem instead of soul or changes here? (Probably changes is too new.)

@jgm
Copy link
Owner

jgm commented Nov 18, 2022

The doc of ulem mentioned they only support ~ in underline. Are there anywhere discussed why we chose ulem instead of soul or changes here? (Probably changes is too new.)

See #7835

@ickc
Copy link
Contributor

ickc commented Nov 18, 2022

Seems like #7835 is not related? #5529 or others?

@ickc
Copy link
Contributor

ickc commented Nov 18, 2022

Or #7351, #2873.

jgm added a commit that referenced this issue Nov 19, 2022
This handles things like hyphenation, line breaks, and nonbreaking
spaces better.

Closes #8411.
@jgm jgm closed this as completed in 144bf90 Nov 19, 2022
@jgm
Copy link
Owner

jgm commented Nov 19, 2022

I just decided to go with soul, we need it anyway for highlighting.

@ickc
Copy link
Contributor

ickc commented Nov 20, 2022

Notes for self and others: c.f. #7743 and commit 7543538.

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

No branches or pull requests

3 participants