Table of contents highlight stops working when a heading id contains a percent sign
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 78/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- javascript
- 领域
- frontend
调研方向
从 src/resources/formats/html/quarto.js 中的 DOMContentLoaded 处理程序开始,尤其检查第 145–152 行的 decodeURI 调用。使用提供的 Quarto 文档复现问题,该文档使用 id="bad%zz";然后检查滚动时目录是否更新,以及格式错误的目标是否不再抛出未捕获的 URIError。报告建议在解码失败时回退到原始目标。
由索引模型根据 Issue 内容生成。
描述
I have:
- searched the issue tracker for similar issues
- installed the latest version of Quarto CLI
- formatted my issue following the Bug Reports guide
Bug description
quarto.js passes each table of contents data-scroll-target through decodeURI.
A heading id with a % that does not start a valid escape, such as {id="bad%zz"}, makes decodeURI throw URIError: URI malformed.
The error is not caught, so the rest of that DOMContentLoaded handler does not run.
The visible effect: the table of contents no longer follows the scroll position.
This is an edge case.
Only an explicit id="..." attribute triggers it.
Automatic ids drop the %, and Pandoc does not read {#bad%zz} as an attribute, so both are safe.
A valid escape such as id="bad%20ok" is also safe.
At render time, Quarto already warns: WARN: Invalid URI '#bad%zz' in attribute 'href' of element 'A'.
Steps to reproduce
---
title: "Repro"
format:
html:
toc: true
---
## Fine
Text.
## Bad target {id="bad%zz"}
Text.
## Last
Text.
- Run
quarto renderand serve the output over HTTP. - Open the page and scroll down.
Actual behavior
The console shows Uncaught URIError: URI malformed from quarto.js.
After scrolling, the table of contents still highlights "Fine".
Expected behavior
The table of contents highlights the section in view, as it does when the id has no %.
A target that cannot be decoded could fall back to the raw value.
Your environment
- IDE: none, command line.
- OS: macOS 27.2.
- Browser: Brave, Chromium 156.0.8078.80.
Quarto check output
Reproduced with a development build of main at 089ba530b.
Quarto 99.9.9
[✓] Checking environment information...
Quarto cache location: /Users/mcanouil/Library/Caches/quarto
Project: none found (single-file mode)
[✓] Checking versions of quarto binary dependencies...
Pandoc version 3.10.0: OK
Dart Sass version 1.107.1: OK
Deno version 2.9.8: OK
Typst version 0.15.1: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
Version: 99.9.9
commit: 089ba530b3ed4ec156a355d41b6b7de2db3e44ea
Path: /Users/mcanouil/Projects/quarto-dev/quarto-cli/package/dist/bin
[✓] Checking tools....................OK
TinyTeX: v2026.07
Chrome Headless Shell: (not installed)
VeraPDF: (not installed)
[✓] Checking LaTeX....................OK
Using: TinyTex
Path: /Users/mcanouil/Library/TinyTeX/bin/universal-darwin
Version: 2026
[✓] Checking Chrome Headless....................OK
Using: Chrome from QUARTO_CHROMIUM
Path: /Applications/Brave Browser.app/Contents/MacOS/Brave Browser
[✓] Checking basic markdown render....OK
- 主要语言
- JavaScript
- 星标
- 6.1k
- 派生
- 478
- 平均合并
- 17 小时 53 分钟
- 30 天内合并 PR
- 135
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
quarto-dev/quarto-cli 的其他 Issue
-
accessibility bug embed
难度 2/5 1-3 小时 新手友好度 85/100
quarto-dev/quarto-cli#15306 ·
维护者通常 1 天内回复
-
bootstrap bug themes
难度 2/5 1-3 小时 新手友好度 82/100
quarto-dev/quarto-cli#15304 ·
维护者通常 1 天内回复
-
accessibility bug code-blocks html themes
难度 2/5 1-3 小时 新手友好度 78/100
quarto-dev/quarto-cli#15303 ·
维护者通常 1 天内回复
-
accessibility brand bug dark-mode
难度 2/5 1-3 小时 新手友好度 82/100
quarto-dev/quarto-cli#15301 ·
维护者通常 1 天内回复
-
bootstrap bug html tables
难度 2/5 1-3 小时 新手友好度 75/100
quarto-dev/quarto-cli#15300 · 1 条评论 ·
维护者通常 1 天内回复
查看 quarto-dev/quarto-cli 的全部 Issue
相似的 Issue
-
test-reliability
难度 2/5 1-3 小时 新手友好度 78/100
Azure/azure-sdk-for-js#40672 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
txn2/mcp-data-platform#2492 ·
维护者通常 1 天内回复
-
documentation
难度 2/5 1-3 小时 新手友好度 76/100
liberation-data/drivine#639 · 2 条评论 ·
维护者通常 1 天内回复
-
accessibility ux
难度 2/5 1-3 小时 新手友好度 78/100
prophet-technocracy/civilizational-emergency-protocol#59 ·
维护者通常 1 天内回复
-
type: bug
难度 1/5 1-3 小时 新手友好度 72/100
RocketChat/Rocket.Chat#43554 · 1 条评论 ·
维护者通常 1 天内回复