Skip to content

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

Closed

Description

@cagix

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).

Activity

  1. jgm commented on Aug 23, 2023

    @jgm
    Owner

    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.
    
  2. jgm commented on Aug 23, 2023

    @jgm
    Owner

    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

  3. jgm commented on Aug 23, 2023

    @jgm
    Owner

    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.

  4. u-fischer commented on Aug 23, 2023

    @u-fischer

    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}
    
  5. jgm commented on Aug 23, 2023

    @jgm
    Owner

    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?

  6. reopened this on Aug 23, 2023
  7. jgm commented on Aug 23, 2023

    @jgm
    Owner

    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.

  8. jgm commented on Aug 24, 2023

    @jgm
    Owner

    Closoed for now by d21a9cd

  9. cagix commented on Aug 24, 2023

    @cagix
    ContributorAuthor

    thx 👍

  10. cderv commented on Aug 28, 2023

    @cderv
    Contributor

    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.

  11. added a commit that references this issue on Feb 2, 2024
    7c43546
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions