Code blocks in a language without a grammar get no div.sourceCode wrapper, so they lose the code-block box
Maintainer thường phản hồi trong vòng 1 ngày
Một pull request liên quan đã được merge.
- #1093 của @cscheid — đã merge
Đá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
- 72/100
Hướng nghiên cứu
Start by tracing how q2 renders fenced code blocks and adds sourceCode classes or the div.sourceCode wrapper, comparing the grammar and no grammar paths. Reproduce with the provided ini, default, and bash blocks in index.qmd. Done when language blocks without a grammar retain the code block box, and the behavior for blocks with no language matches the intended choice.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
When q2 has no grammar for a code block's language, it writes a bare <pre class="<lang> code-with-copy">, with no div.sourceCode wrapper and no sourceCode classes. The theme draws the code-block box (background, border, padding) on div.sourceCode, so these blocks render as plain text on the page background. Quarto 1 (Pandoc) wraps every block whose language its highlighter knows in div.sourceCode, even when it adds no colors. An example is ```default.
So a migrated site loses the code-block box on every block in a language outside q2's grammar set, not only the colors.
Versions
- q2 0.41.0 (macOS, arm64)
- Quarto 1.11.7, for comparison
- Chrome, 1280×800 viewport, default theme
Repro
_quarto.yml:
project:
type: website
website:
title: Example
index.qmd:
---
title: Code styling
---
```ini
[Widget]
; Turn the widget on.
Enabled = true
```
```default
/opt/widget/1.0/bin/widget
```
```bash
echo "highlighted in both"
```
q2 render
Expected (Quarto 1.11.7)
All three blocks are div.sourceCode > pre.sourceCode.<lang>, and all three have the box. Computed style of each div.sourceCode: background rgba(233, 236, 239, 0.65), border 1px solid. The default block has the box but no colors.
<pre class="sourceCode ini code-with-copy">
<pre class="sourceCode default code-with-copy">
<pre class="sourceCode bash code-with-copy">
Actual (q2 0.41.0)
<pre class="ini code-with-copy">
<pre class="default code-with-copy">
<pre class="sourceCode bash">
Only the bash block has the box. The ini and default blocks have background rgba(0, 0, 0, 0) and no border.
Notes
- Quarto 1 still leaves blocks with no language, and languages its highlighter does not know (for example
text,nginx), without the wrapper. So "wrap every block that has a language class" would box a few blocks that Quarto 1 does not. To me that looks like the better default, but it is a choice. - Scale, from one real documentation site (about 2,070 code blocks): 617 blocks lost the box after the migration. They were
ini466,default113,markdown24,toml5, and a few each ofdockerfile,xml,powershell,apache,conf, andtxt. - A user grammar in
_quarto/grammars/<lang>/fixes this for one language, because a highlighted block gets the wrapper. But that does not helpdefault, which has nothing to highlight.
- Ngôn ngữ chính
- Rust
- Star
- 293
- Fork
- 20
- Merge trung bình
- 5 giờ 38 phút
- Pull request đã merge (30 ngày)
- 199
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
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
quarto-dev/q2#1103 · 1 bình luận ·
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 ·
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 77/100
quarto-dev/q2#1031 ·
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 78/100
quarto-dev/q2#957 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
quarto-dev/q2#1115 · 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 78/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
aaif-goose/goose#13364 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ai_p2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
ClickHouse/ClickHouse#130006 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: PostgreSQL backend: Queue.remove() / Job.remove() never emit the QueueEvents "removed" eventCó thể đã có người làm @1AbdullahButt đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
taskforcesh/bullmq#5085 ·
Maintainer thường phản hồi trong vòng 1 ngày