A `{=html}` block holding `<style>` or `<script>` fails to parse on a page with code cells
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 65/100
Hướng nghiên cứu
Start with round_trips_bare_html and write_rawblock in crates/pampa/src/writers/qmd.rs, then read the related tests for raw HTML round trips. Check how fenced {=html} blocks containing style and script elements are serialized and parsed when a document has a code cell. Done when both reproductions render successfully and preserve the raw HTML in the output.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
This issue was written by Claude while adding q2 support to
Great Docs. The output shown comes from running each repro.
Bug description
A ```{=html} block that holds a <style> or <script> element renders correctly on a page
without code cells. On a page with a code cell, the same block fails with a parse error in the
intermediate .jupyter.rmarkdown file, at the block's CSS or JavaScript.
Before running an engine, serialize_ast_to_qmd in
crates/quarto-core/src/stage/stages/engine_execution.rs writes the document as qmd, and the qmd
writer drops the block's fence. write_rawblock in crates/pampa/src/writers/qmd.rs writes HTML
bare when round_trips_bare_html accepts it, and that function accepts any raw-text element
(<pre>, <script>, <style>, <textarea>) on its opening tag alone. Its doc comment says the
reader leaves such an element's interior unparsed. But the interior is parsed as Markdown before
paragraph.rs lifts the paragraph to a RawBlock, so braces and indented lines are errors when
the intermediate file is read.
#674 reported this along with bare <style> and <script> elements, and was closed as not
planned: q2 will discourage bare elements because their contents can't be parsed reliably. This
issue is only about the fenced form, which is what an author is asked to write instead, and which
q2's own writer turns into the bare form. Keeping the fence on raw-text elements in
round_trips_bare_html, as #674 suggested, would fix it.
Great Docs wrote a <style> rule on its homepage this way, and pages with code cells failed to
render under q2. It now puts the rule in its stylesheet instead, so this no longer blocks Great
Docs.
Steps to reproduce
With Python and ipykernel available:
mkdir raw-style && cd raw-style
printf -- '---\ntitle: Raw style\n---\n\n```{=html}\n<style>\nh1 { color: red; }\n</style>\n```\n' > plain.qmd
printf -- '---\ntitle: Raw style\n---\n\n```{=html}\n<style>\nh1 { color: red; }\n</style>\n```\n\n```{python}\n1 + 1\n```\n' > code.qmd
q2 render plain.qmd
q2 render code.qmd
Actual behavior
plain.qmd renders, and plain.html has the <style> element. code.qmd fails:
error: while rendering /private/tmp/raw-style/code.qmd
Error: [Q-2-41] Curly braces are reserved for attribute syntax
╭─[ /private/tmp/raw-style/code.jupyter.rmarkdown:136:5 ]
│
136 │ h1 { color: red; }
│ ───┬───
│ ╰───── Curly braces are reserved for attribute syntax in Quarto markdown. To write literal braces, escape them as `\{...\}`. If you meant to attach an attribute, use `.class` / `#id` / `key="value"` syntax, e.g. `[text]{.class}`.
─────╯
error: while rendering /private/tmp/raw-style/code.qmd
Error: Parse error
╭─[ /private/tmp/raw-style/code.jupyter.rmarkdown:153:4 ]
│
153 │ :::
│ ┬
│ ╰── unexpected character or token here
─────╯
2 errors
A <script> block holding if (a) { and an indented b(); line fails the same way, with a parse
error at the indented line. The same block wrapped in <div> instead of <style> keeps its fence
and renders.
Expected behavior
code.qmd renders as plain.qmd does, with the <style> element in the output, as in Quarto
1.9.37.
- Ngôn ngữ chính
- Rust
- Star
- 316
- Fork
- 23
- Merge trung bình
- 11 giờ 49 phút
- Pull request đã merge (30 ngày)
- 245
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của quarto-dev/q2
-
Heading anchor links have no icon: AnchorJS is initialised with an empty `icon`Có thể đã có người làm @cscheid đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
quarto-dev/q2#1419 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug testing windows
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 78/100
quarto-dev/q2#1346 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
quarto-dev/q2#1095 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 67/100
quarto-dev/q2#1418 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug readers-writers windows
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
quarto-dev/q2#1416 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của quarto-dev/q2
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 82/100
BurntSushi/jiff#755 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
After the kernel is given up on, a new import leaves "Importing…" and its Cancel on the status lineĐang mởbug help wanted priority: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
sawhorse3d/sawhorse#163 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
MartinPTielemans/ilo#4607 ·