lmd: list-table and definition-list divs built from AST nodes in a cell are not desugared
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 15/100
Hướng nghiên cứu
Start with transform_divs, validate_list_table_div and is_valid_definition_list_div in pampa/src/pandoc/treesitter_utils/postprocess.rs, then find where lmd cell results are spliced in at the lmd-execute stage. Linked PR #850 is already open against this, so read it before touching code. Done means sections 2 and 4 of the repro render <table> and <dl> instead of nested <div> and <ul>, with sections 1 and 3 unchanged.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
A .list-table or .definition-list div that an {lmd} cell builds from AST nodes (pandoc.Div + pandoc.BulletList) is never desugared into a Table / DefinitionList. It reaches the HTML writer as a div containing nested bullet lists. The same markup written literally in the document body converts fine.
The desugaring lives in the reader's postprocess step (pampa/src/pandoc/treesitter_utils/postprocess.rs, transform_divs / validate_list_table_div / is_valid_definition_list_div), so it only ever sees blocks that came out of the qmd reader. Blocks that lmd cells return at lmd-execute (which runs after the engine, before ast-transforms) are spliced in without that step. The natural fix seems to be running the same div transform over each cell's returned blocks (or as a stage right after lmd-execute); transform_divs is already public and used from pampa's CLI.
This matters for the use lmd was built for: a Lua function that builds a table from data (porting an Astro/Hugo "ConfigTable"-style component) has no clean way to produce a table. Building a pandoc.Table by hand is far more verbose than the list-table div; pandoc.read of generated markdown works but defeats the point of building nodes.
Repro
repro.qmd:
---
title: list-table and definition-list divs from lmd
---
## 1. Literal list-table (control)
::: {.list-table}
* - Key
- Value
* - `a`
- one
:::
## 2. list-table div built from AST nodes in an lmd cell
```{lmd}
local function row(cells)
local items = {}
for _, c in ipairs(cells) do table.insert(items, { pandoc.Plain(c) }) end
return { pandoc.BulletList(items) }
end
local rows = {
row({ {pandoc.Str("Key")}, {pandoc.Str("Value")} }),
row({ {pandoc.Code("b")}, {pandoc.Str("two")} }),
}
return pandoc.Div({ pandoc.BulletList(rows) }, pandoc.Attr("", {"list-table"}))
```
## 3. Literal definition-list (control)
::: {.definition-list}
* Term
* A definition.
:::
## 4. definition-list div built from AST nodes in an lmd cell
```{lmd}
local item = {
pandoc.Plain({ pandoc.Str("Term") }),
pandoc.BulletList({ { pandoc.Plain({ pandoc.Str("A definition.") }) } }),
}
return pandoc.Div({ pandoc.BulletList({ item }) }, pandoc.Attr("", {"definition-list"}))
```
q2 render repro.qmd --to html
Renders without diagnostics. In repro.html:
| Section | Expected | Actual |
|---|---|---|
| 1. literal list-table | <table> |
<table> |
| 2. AST-built list-table | <table> |
<div class="list-table"><ul><li><ul>… |
| 3. literal definition-list | <dl> |
<dl> |
| 4. AST-built definition-list | <dl> |
<div class="definition-list"><ul><li>… |
The node shapes in 2 and 4 match what the reader produces for 1 and 3 before postprocess (the validators' documented structure), so once transform_divs runs over them they should convert.
Related: the same markup inside a markdown fragment
The obvious workaround, writing the list-table literally inside a fragment, is also blocked, for the opposite reason: the fragment is parsed by the reader with postprocess, so it becomes a Table, and the desugarer then reports
Warning: lmd cell could not be desugared
lmd: `Table` nodes are not supported inside markdown fragments yet
The cell is left as written and will not run.
for
```{lmd}
return {=:
::: {.list-table}
* - Key
- Value
* - `b`
- two
:::
:=}
```
So today the only route from an lmd cell to a table is pandoc.read(markdown_string, "markdown"), which does run postprocess and produces a table.
Environment
q2 0.33.0 (macOS, arm64); repo inspected at e308835bd.
- Ngôn ngữ chính
- Rust
- Star
- 278
- Fork
- 19
- Merge trung bình
- 20 giờ 23 phút
- Pull request đã merge (30 ngày)
- 164
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ó 3/5 1-2 ngày Mức phù hợp với người mới 54/100
quarto-dev/q2#905 ·
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 63/100
quarto-dev/q2#904 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 48/100
quarto-dev/q2#900 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
quarto-dev/q2#896 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
"I want :emoji: to work"Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
quarto-dev/q2#893 · 3 reaction ·
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ự
-
checkpoint/verify/rebuild_indexes on a thread holding a WriteTransaction deadlock instead of INT-001Đang mởbug known-issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
project-minigraf/minigraf#734 ·
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 70/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/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 70/100
bitcoindevkit/electrum_streaming_client#57 ·
Maintainer thường phản hồi trong vòng 2 ngày