Skip to content

Failed to execute 'querySelector' on 'Document' in console after click on link in the TOC #9125

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

Closed
AndreiBiziuk opened this issue Mar 18, 2024 · 1 comment
Assignees
Labels
bug Something isn't working html Issues with HTML and related web technology (html/css/scss/js)
Milestone

Comments

@AndreiBiziuk
Copy link

Bug description

When I write .qmd file in Russian and render to HTML, links in TOC cause errors in browser console:

Uncaught DOMException: Failed to execute 'querySelector' on 'Document': '[data-anchor-id=%D0%BE%D0%BF%D1%80%D0%B5%D0%B4%D0%B5%D0%BB%D0%B5%D0%BD%D0%B8%D0%B5]' is not a valid selector.
    at HTMLAnchorElement.<anonymous> (http://localhost:7547/site_libs/quarto-html/quarto.js:96:41)

Although the page scrolls to the desired heading.

Apparently the problem is in the automatically assigned identifiers for headings in Cyrillic.

Steps to reproduce

bug.qmd:

---
format: html
toc: true
---

# Заголовок 1

## Заголовок 2
  1. quarto render ./bug.qmd

  2. Open bug.html in browser

  3. Open dev-tools

  4. Click on link in TOC

Expected behavior

No errors in console

Actual behavior

Uncaught DOMException: Failed to execute 'querySelector' on 'Document': '[data-anchor-id=%D0%B7%D0%B0%D0%B3%D0%BE%D0%BB%D0%BE%D0%B2%D0%BE%D0%BA-1]' is not a valid selector.
    at HTMLAnchorElement.<anonymous> (file:///home/andrei/src/quarto/bug/bug_files/libs/quarto-html/quarto.js:96:41)

Your environment

quarto -V
1.5.25

Quarto check output

Quarto 1.5.25
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.11: OK
      Dart Sass version 1.70.0: OK
      Deno version 1.41.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.5.25
      Path: /opt/quarto/bin

[✓] Checking tools....................OK
      Chromium: 869685
      TinyTeX: (not installed)

[✓] Checking LaTeX....................OK
      Using: Installation From Path
      Path: /usr/bin
      Version: undefined

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.11.8
      Path: /usr/bin/python3
      Jupyter: 5.7.2
      Kernels: haskell, python3

[✓] Checking Jupyter engine render....OK

[✓] Checking R installation...........OK
      Version: 4.3.3
      Path: /usr/lib64/R
      LibPaths:
        - /home/andrei/R/x86_64-pc-linux-gnu-library/4.3
        - /usr/lib/R/library
      knitr: 1.45
      rmarkdown: 2.25

[✓] Checking Knitr engine render......OK

@AndreiBiziuk AndreiBiziuk added the bug Something isn't working label Mar 18, 2024
@cderv
Copy link
Collaborator

cderv commented Mar 18, 2024

Thanks for the report. I can reproduce, this is a small issue with non quoted string as the id in the selector will be completely 100% HTML encoded characters in this case

[data-anchor-id=%D0%B7%D0%B0%D0%B3%D0%BE%D0%BB%D0%BE%D0%B2%D0%BE%D0%BA-2]

and without quotes it causes issues.

As a workaround for now, you can set ids on the headers

# Заголовок 1 {#header1}

## Заголовок 2 {#header2}

@cderv cderv added the html Issues with HTML and related web technology (html/css/scss/js) label Mar 18, 2024
@cderv cderv self-assigned this Mar 18, 2024
@cderv cderv closed this as completed in f431072 Mar 18, 2024
@cderv cderv added this to the v1.5 milestone Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working html Issues with HTML and related web technology (html/css/scss/js)
Projects
None yet
Development

No branches or pull requests

2 participants