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

オープン
#1,081 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@cscheid がすでに取り組んでいます。

2026年11月6日 から。

  • #1091 @cscheid による — オープン

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
rust

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Rust
スター
293
フォーク
20
平均マージ
7時間 45分
マージ済み PR(30日)
187

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

quarto-dev/q2 のほかの issue

quarto-dev/q2 の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。