A YAML block inside a `~~~` fenced code block is applied as document metadata
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 84/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- markdown, typescript, yaml
- Bereich
- backend
Rechercherichtung
Beginne in src/core/yaml.ts bei readYamlFromMarkdown und untersuche kRegexFencedCode, das auch von skipRegexpAll verwendet wird. Vergleiche den Umgang mit Backtick-Codeblöcken mit dem von Tilde-Codeblöcken und suche anschließend die zugehörigen Tests zur YAML-Extraktion. Fertig ist die Änderung, wenn YAML innerhalb eines Tilde-Codeblocks als Metadaten ignoriert wird, der Block aber weiterhin Code bleibt und das bisherige Verhalten bei Backtick-Codeblöcken weiterhin funktioniert.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 6.2k
- Forks
- 492
- Ø Merge
- 13 Std. 51 Min.
- Gemergte PRs (30 T.)
- 82
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus quarto-dev/quarto-cli
-
accessibility bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
quarto-dev/quarto-cli#15440 ·
Maintainer antworten meist innerhalb von 1 Tag
-
accessibility bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
quarto-dev/quarto-cli#15439 ·
Maintainer antworten meist innerhalb von 1 Tag
-
accessibility bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 80/100
quarto-dev/quarto-cli#15438 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bootstrap enhancement themes
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
quarto-dev/quarto-cli#15421 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
quarto-dev/quarto-cli#15408 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in quarto-dev/quarto-cli
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
crxjs/chrome-extension-tools#1261 ·
-
support
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
01 type: bug
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 88/100
conorbronsdon/avoid-ai-writing#559 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 75/100
agentregistry-dev/website#69 ·