Skip to content

href are escaped by Pandoc 3.2.1 breaking toc #2580

Open

Description

@cderv

This (edit: #1776) just became very relevant for me. It turns out, pandoc started to escape href URIs starting with 3.2.1 because of jgm/pandoc#9905

This specifically broke all toc entries in my document that do not consisted solely of ascii characters:

Uncaught Error: Syntax error, unrecognized expression: #bundesl%C3%A4nder
    jQuery 7
    refresh file:///XX/report_files/bootstrap-3.3.7/js/bootstrap.min.js:6
    jQuery 3
    refresh file:///XX/report_files/bootstrap-3.3.7/js/bootstrap.min.js:6
    b file:///XX/report_files/bootstrap-3.3.7/js/bootstrap.min.js:6
    c file:///XX/report_files/bootstrap-3.3.7/js/bootstrap.min.js:6
    jQuery 2
    c file:///XX/report_files/bootstrap-3.3.7/js/bootstrap.min.js:6
    <anonymous> file:///XX/report_files/downcute-0.1/downcute.js:44
    EventListener.handleEvent* file:///XX/report_files/downcute-0.1/downcute.js:11

A way to tell pandoc to use --to html5 would solve this.

Originally posted by @octomike in #1776 (comment)

Activity

  1. self-assigned this
    on Oct 31, 2024
  2. added
    theme: pandoc
    bug
    on Oct 31, 2024
  3. moved this from Backlog to Next / Ready for Dev in R Markdown Team Projectson Oct 31, 2024
  4. cderv commented on Sep 10, 2025

    @cderv
    CollaboratorAuthor

    @octomike are you able to provide a reproducible example of the problem ?

    I see downcute.js in your log, and so I wonder if you are using a specific format like downcute() in https://github.com/juba/rmdformats#downcute

    The JS script has processing of the TOC
    https://github.com/juba/rmdformats/blob/70c327640e88c9a80652bfa4393954688d5105a3/inst/templates/downcute/downcute.js#L44C15-L44C24

    and it may not be compatible with Pandoc 3.2.1+ that now URL encode IDs in link...

    I just want to confirm. Thank you !

    @yihui I believe the issue is related to the bookdown one I solved.

    ---
    title: "Untitled"
    date: "`r Sys.Date()`"
    output: 
      html_document:
        toc: true
    ---
    
    # entraîneur
    
    content
    
    pandoc::with_pandoc_version("3.1.7", {
        res <- rmarkdown::render("test.Rmd", quiet = TRUE)
        grep("#entra", xfun::read_utf8(res), value = TRUE)
    })
    #> [1] "<li><a href=\"#entraîneur\" id=\"toc-entraîneur\">entraîneur</a></li>"
    pandoc::with_pandoc_version("3.7.0.2", {
        res <- rmarkdown::render("test.Rmd", quiet = TRUE)
        grep("#entra", xfun::read_utf8(res), value = TRUE)
    })
    #> [1] "<li><a href=\"#entra%C3%AEneur\" id=\"toc-entraîneur\">entraîneur</a></li>"

    So now Pandoc does really URL escape ids, and this could have impact on processing. Except for bookdown, I don't know if this is a problem. Do you think of something else ?

  5. yihui commented on Sep 23, 2025

    @yihui
    Collaborator

    Thanks! For now, I can't think of possible problems in other packages, either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugtheme: pandoc

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions