A YAML block inside a `~~~` fenced code block is applied as document metadata
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 84/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- markdown, typescript, yaml
- 领域
- backend
调研方向
从 src/core/yaml.ts 中的 readYamlFromMarkdown 开始,检查 skipRegexpAll 也会使用的 kRegexFencedCode。比较其对反引号围栏代码块和波浪号围栏代码块的处理方式,然后查找与 YAML 提取相关的测试。完成标准是:波浪号围栏代码块中的 YAML 被忽略,不作为元数据;该代码块仍被视为代码;现有的反引号处理行为也继续正常工作。
由索引模型根据 Issue 内容生成。
描述
Bug description
Quarto strips backtick-fenced code before looking for YAML metadata blocks in the document body, but not tilde-fenced code. A --- ... --- block inside a ~~~ fence is therefore read as front matter: its keys (lang, toc, format, execute, filters, ...) take effect. Pandoc treats the same text as a code block and ignores it, as it does for a backtick fence. The two fence styles are equivalent in CommonMark and Pandoc Markdown, so this looks like an oversight.
It matters for documents that show front matter as an example, for instance a tutorial on Quarto itself written with ~~~ fences so that it can contain a literal triple backtick. The example silently changes the real document.
Reproducible example
x.qmd (markdown engine, so no R or Python is involved):
---
title: Tilde fence
engine: markdown
---
Text before the fence.
~~~
---
lang: fr
toc: true
---
~~~
Text after the fence.
quarto render x.qmd --to html
Expected: <html lang="en">, and the fenced block shown as a code block, as with a backtick fence (the same file with ``` in place of ~~~ behaves like this).
Actual: <html ... lang="fr" xml:lang="fr">. The block is applied as metadata, and also appears as a code block in the output. A Lua filter that dumps doc.meta sees lang = fr. (quarto pandoc -f markdown -s x.qmd alone leaves lang unset, with the block as a CodeBlock.)
With a heading in the document, toc: true from inside the fence also produces a table of contents. With the knitr engine, execute: echo: false inside the fence hides all code in the document.
Cause
src/core/yaml.ts: readYamlFromMarkdown deletes fenced code with
const kRegexFencedCode = /^([\t >]*`{3,})[^`\n]*\n[\W\w]*?\n\1\s*$/gm;
(line 49 at commit 83432c0). The pattern only matches a run of backticks, so a ~~~ fence is not removed before kRegExYAML is applied. Allowing ~{3,} as well (with the closing fence being the same character, at least as long) would fix it. The same constant is used by the skipRegexpAll call at line 144.
Environment
$ quarto --version
1.11.9
$ quarto pandoc --version | head -1
pandoc 3.10
macOS; the regex is platform independent.
Related
#3004: the same kind of problem for a --- inside a backtick fence, which kRegexFencedCode addressed.
- 主要语言
- JavaScript
- 星标
- 6.2k
- 派生
- 492
- 平均合并
- 13 小时 51 分钟
- 30 天内合并 PR
- 82
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
quarto-dev/quarto-cli 的其他 Issue
-
accessibility bug
难度 2/5 1-3 小时 新手友好度 78/100
quarto-dev/quarto-cli#15440 ·
维护者通常 1 天内回复
-
accessibility bug
难度 2/5 1-3 小时 新手友好度 84/100
quarto-dev/quarto-cli#15439 ·
维护者通常 1 天内回复
-
accessibility bug
难度 2/5 1-3 小时 新手友好度 80/100
quarto-dev/quarto-cli#15438 ·
维护者通常 1 天内回复
-
bootstrap enhancement themes
难度 2/5 1-3 小时 新手友好度 70/100
quarto-dev/quarto-cli#15421 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 85/100
quarto-dev/quarto-cli#15408 ·
维护者通常 1 天内回复
查看 quarto-dev/quarto-cli 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
crxjs/chrome-extension-tools#1261 ·
-
support
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
01 type: bug
难度 1/5 1 小时以内 新手友好度 76/100
维护者通常 1 天内回复
-
难度 1/5 1-3 小时 新手友好度 88/100
conorbronsdon/avoid-ai-writing#559 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 75/100
agentregistry-dev/website#69 ·