Built-in highlighting for ```qmd (and ```markdown / ```md) code blocks with q2's own qmd parser

Đã đóng
#1,081 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Một pull request liên quan đã được merge.

  • #1091 của @cscheid — đã merge

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust

Hướng nghiên cứu

Start by tracing q2's code block highlighting and built-in grammar registration, then inspect the bundled tree-sitter-qmd parser and its highlights.scm query. Check how aliases and grammar injections are handled for embedded code cells and YAML front matter. Done means qmd, markdown, and md blocks receive the requested syntax highlighting, including the listed Quarto constructs.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement

q2 has no built-in highlighting for Quarto markdown in code blocks: ```qmd, ```markdown, and ```md render as plain <pre> with no sourceCode wrapper. Documentation about Quarto and about publishing tools shows a lot of qmd and markdown. q2 already has its own qmd parser, tree-sitter-qmd, so it is the natural grammar for these blocks.

Versions

  • q2 0.41.0 (macOS, arm64)
  • Quarto 1.11.7, for comparison

Repro

index.qmd, with no _quarto.yml:

---
title: qmd highlighting
engine: markdown
---

`````qmd
---
title: "Report"
format: html
---

## Results

Some **bold** text and a [link](https://example.com).

```{python}
#| echo: false
print("hello")
```
`````

````markdown
## Results

Some **bold** text.
````
q2 render index.qmd

Quarto 1.11.7

  • ```qmd: not highlighted (<pre class="qmd">). Pandoc's highlighter does not know qmd.
  • ```markdown: highlighted with Pandoc's Markdown syntax (<pre class="sourceCode markdown">, heading tokens).

q2 0.41.0

Both blocks are <pre class="qmd code-with-copy"> and <pre class="markdown code-with-copy">, with no spans and no div.sourceCode wrapper.

Request

Highlight qmd, with markdown and md as aliases, using q2's own parser: front matter, headings, emphasis, links, code cells and their #| options, shortcodes, and divs. Ideally, embedded code cells and YAML front matter are highlighted with the matching built-in grammars, like an injection.

Notes

I tried the user-grammar route first. tree-sitter build --wasm on crates/tree-sitter-qmd/tree-sitter-markdown gives a 1.1 MB WASM file. It loads from _quarto/grammars/ only under the name markdown, because the WASM exports tree_sitter_markdown and the user-grammar loader derives the language function from the file name, so it cannot register qmd. With the bundled queries/highlights.scm, only **strong** and some punctuation get spans. Headings, links, front matter, and the nested code cell stay plain. A built-in, native path seems better than asking projects to vendor a large WASM build of q2's own parser.

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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của quarto-dev/q2

Tất cả issue của quarto-dev/q2

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.