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

Pandoc 3.1.6.2 fails conversion to Beamer if URLs contain '#' #9014

Closed
cagix opened this issue Aug 23, 2023 · 9 comments
Closed

Pandoc 3.1.6.2 fails conversion to Beamer if URLs contain '#' #9014

cagix opened this issue Aug 23, 2023 · 9 comments
Labels

Comments

@cagix
Copy link
Contributor

cagix commented Aug 23, 2023

The following example document stopped compiling with Pandoc 3.1.6.2 to Beamer:

[Module pandoc](https://pandoc.org/lua-filters.html#module-pandoc)

When translating I get the following error message:

$ pandoc -t beamer mwe.md -o mwe.pdf
Error producing PDF.
! Illegal parameter number in definition of \iterate.
<to be read again> 
                   m
l.100 \end{frame}

Using the ARM64 Linux binary from the GitHub release page:

$ pandoc -v
pandoc 3.1.6.2
Features: +server +lua
Scripting engine: Lua 5.4
User data directory: /usr/local/share/pandoc
Copyright (C) 2006-2023 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.

$ pdflatex -version
pdfTeX 3.141592653-2.6-1.40.22 (TeX Live 2022/dev/Debian)
kpathsea version 6.3.4/dev
Copyright 2021 Han The Thanh (pdfTeX) et al.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.37; using libpng 1.6.37
Compiled with zlib 1.2.11; using zlib 1.2.11
Compiled with xpdf version 4.03

Changing the MWE to

[Module pandoc](https://pandoc.org/lua-filters.html)

i.e. removing the #module-pandoc will compile as expected.


Edit: The issue seems to be related to the Beamer target. With pandoc -t latex mwe.md -o mwe.pdf I could successfully create a PDF (3.1.6.2).

Edit: The last working Pandoc version was pandoc-3.1.6.1-linux-arm64.tar.gz (just tested).

@cagix cagix added the bug label Aug 23, 2023
@jgm
Copy link
Owner

jgm commented Aug 23, 2023

This must have to do with one of these changes:

 * LaTeX writer:

    + Improve escaping of URIs in href, url (#8992).
    + Improve internal links and targets (#8744). We no longer
      wrap section headings in a `\hypertarget`. This is unnecessary
      (hyperref creates an anchor based on the label) and it interferes with
      tagging. In addition, we now use `\hyperref` rather than `\hyperlink`
      for internal links. Currently `\hypertarget` is still being used for
      link anchors not on headings. Thanks to @u-fischer.

@jgm
Copy link
Owner

jgm commented Aug 23, 2023

OK, the difference is that in 3.1.6.1 we got

\href{https://pandoc.org/lua-filters.html\#module-pandoc}{Module pandoc}

while in 3.1.6.2 we get

\begin{frame}
\href{https://pandoc.org/lua-filters.html#module-pandoc}{Module pandoc}
\end{frame}

The # is no longer backslash-escaped.
This is due to commit cbb33fe

@jgm
Copy link
Owner

jgm commented Aug 23, 2023

Apparently, in general # does not need to be backslash-escaped in a URL in \href, but something special is going on when it's in a frame environment, so this breaks with beamer. I think the simplest fix is to restore backslash-escaping of # in a URL, which seems harmless. Maybe @u-fischer has further insight.

@jgm jgm closed this as completed in 7c43546 Aug 23, 2023
@u-fischer
Copy link

u-fischer commented Aug 23, 2023

frame is a rather special environment that works like a command with argument. That means it can't contain verbatim or verbatim-like material. Either escape problematic chars in the url (# and %, the rest should normally not be a problem) or use the fragile keyword:

\documentclass{beamer}

\usepackage{hyperref}

\begin{document}

\begin{frame}
\href{https://pandoc.org/lua-filters.html\#module-pandoc}{Module pandoc}
\end{frame}

\begin{frame}[fragile]
\href{https://pandoc.org/lua-filters.html#module-pandoc}{Module pandoc}
\end{frame}

\end{document}

@jgm
Copy link
Owner

jgm commented Aug 23, 2023

Adding fragile seems like a nicer solution.
Currently we add fragile in the following cases:

  • class contains fragile
  • slide contains code or a code block

Would there be any drawback to adding it always to slide environments?

@jgm jgm reopened this Aug 23, 2023
@jgm
Copy link
Owner

jgm commented Aug 23, 2023

Discussion of drawbacks here: https://tex.stackexchange.com/questions/136240/drawbacks-of-using-fragile-frames-in-beamer

What I get from this is that fragile might interact badly with noframebreaks, and that it might increase compile time, but otherwise it's fairly harmless.

@jgm
Copy link
Owner

jgm commented Aug 24, 2023

Closoed for now by d21a9cd

@jgm jgm closed this as completed Aug 24, 2023
@cagix
Copy link
Contributor Author

cagix commented Aug 24, 2023

thx 👍

@cderv
Copy link
Contributor

cderv commented Aug 28, 2023

FWIW Just sharing as I found this issue with 3.1.6.2 too, using a link inside a caption.
With hyperref package, there is special because \href is used inside \caption in that case.
About \href[options]{URL}{text} in the hyperref manual:

The text is made a hyperlink to the URL; this must be a full URL (relative to the base URL, if that is defined). The special characters # and % do not need to be escaped in any way (unless the command is used in the argument of another command). The optional argument options recognizes the hyperref

So # and % still needs to be escaped under some conditions.

Example
---
title: "Example"
---

See [Quarto guide](https://quarto.org/docs/authoring/markdown-basics.html#text-formatting)

![See [Quarto guide](https://quarto.org/docs/authoring/markdown-basics.html#test-formatting)](https://quarto.org/quarto.png)

Rendering to PDF will fail with 3.1.6.2

  • First link will be ok, even with # not escaped
  • Second link is making build fail - # needs to be escaped because inside caption

To be clear, using latest nighlty, it works. Just sharing related to d21a9cd message. It is not just a matter of adding fragile to slide on beamer as it happens also with non-beamer.

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

4 participants