Skip to content

Commit f531671

Browse files
committed
[chore] doc refactoring
1 parent 266c245 commit f531671

File tree

6 files changed

+47
-70
lines changed

6 files changed

+47
-70
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,4 @@ Parses [quarto-web](https://github.com/quarto-dev/quarto-web) with a small numbe
6464

6565
- actually good error messages
6666
- fine-grained source location tracking
67-
- WASM distribution
6867
- solve glaring performance issues

crates/tree-sitter-qmd/README.md

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,8 @@ It has a number of non-standard syntax that are used by Quarto in .qmd files spe
55

66
The original `tree-sitter-markdown` grammar was written by [Matthias Deiml](https://github.com/MDeiml).
77

8-
At a high level, tree-sitter-qmd should be used like tree-sitter-md, by using the results of a block parse
9-
to trigger the inline grammar parsing.
8+
`tree-sitter-qmd` is an internal package written entirely to support `quarto-markdown-pandoc`.
109

1110
For the original tree-sitter-md readme, see [README.tree-sitter-md.md].
1211

13-
## QMD changes/additions
14-
15-
- A fixed set of extensions
16-
17-
- shortcode syntax
18-
19-
- attribute syntax
20-
21-
- including Quarto's `{lang}` syntax that isn't commonmark
22-
23-
- including raw block/inline `{=format}` syntax
24-
25-
## QMD _REMOVALS_
26-
27-
- Simplified link syntax. the only link syntax supported are _inline links_: `[text](destination title)`
28-
29-
- no wikilink support
30-
31-
- no shortcut reference link support, we use that syntax for spans instead
32-
33-
- Similarly, the only image syntax supported is the one corresponding to inline links: `![text](image-name title)`
34-
35-
- no HTML support: QMD is meant to translate into more than one syntax. We use rawblock instead.
12+
For more information on the syntax supported by quarto-markdown, see the top-level docs folder, and specifically the [syntax-nodes.md file](../../docs/syntax-notes.md).

docs/syntax-notes.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,31 @@ We aim to be largely compatible with Pandoc's `markdown` and `Commonmark` format
88

99
Syntax extensions are handled by [desugaring](https://cs.brown.edu/courses/cs173/2012/book/Desugaring_as_a_Language_Feature.html) into regular Pandoc AST nodes.
1010

11+
### Scoped metadata
12+
13+
Our intermediate representation can store a metadata block inside the document, allowing (in principle)
14+
for metadata in the document to be scoped to a particular portion of the document.
15+
1116
### Shortcodes
1217

1318
We have "native" shortcode support in the "Pandoc" AST in pandoc.rs, and
1419
we desugar them to Pandoc spans in a Rust filter.
1520

16-
### Notes
21+
### Footnotes
1722

1823
We parse footnotes differently from Pandoc.
1924
We use NoteReference (Inline) and NoteDefinition (block) nodes.
2025
These are desugared into spans and divs in a Rust filter.
2126

27+
### Editor markup
28+
29+
Inspired by [CriticMarkup](https://fletcher.github.io/MultiMarkdown-6/syntax/critic.html) and [djot](https://djot.net), Quarto offers syntax for edit marks:
30+
31+
- Insertions: `[++ Insert this markdown content]`
32+
- Deletions: `[-- Delete this sentence]`
33+
- Highlighting: `[!! this will be highlighted in rendering]`
34+
- Comment: `[>> this will show up as a comment]`
35+
2236
### Reader raw blocks
2337

2438
Quarto Markdown supports the following syntax:
@@ -200,4 +214,16 @@ We will also not support definition lists directly.
200214
Consider `^[footnote-or-span]{.class}^`. `^[` denotes both the start of a footnote and potentially the combination of a superscript block with a span; this parse is ambiguous.
201215

202216
Quarto-markdown's parser prefers the footnote interpretation. In case an immediately nested span is needed, use a space between `^` and `[`.
203-
Superscript nodes with leading spaces are disallowed in Pandoc, but Quarto-markdown will trim spaces.
217+
Superscript nodes with leading spaces are disallowed in Pandoc, but Quarto-markdown will trim spaces.
218+
219+
## QMD _REMOVALS_
220+
221+
- Simplified link syntax. the only link syntax supported are _inline links_: `[text](destination title)`
222+
223+
- no wikilink support
224+
225+
- no shortcut reference link support, we use that syntax for spans instead
226+
227+
- Similarly, the only image syntax supported is the one corresponding to inline links: `![text](image-name title)`
228+
229+
- no HTML support: QMD is meant to translate into more than one syntax. We use rawblock instead.

docs/testing.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## Testing
2+
3+
tree-sitter-markdown-inline has a tree-sitter test suite that can be run with
4+
5+
```
6+
$ tree-sitter test
7+
```
8+
9+
Many tests there were inherited from the grammar we forked. Many of those fail, and some shouldn't actually pass.
10+
11+
In addition to a fixed test suite, we have `./tree-sitter-markdown-inline/scripts/shortcode_generator.py` to test the shortcode parsing subsystem specifically.
12+
It uses random testing to generate large numbers of shortcodes, calls `tree-sitter parse` on them, and checks if the output matches expectations.
13+
14+
We use it to generate failing tests that are then fixed and added to the test suite (crates/tree-sitter-qmd/tree-sitter-markdown-inline/test/corpus/shortcodes.txt).
15+
At present time, we have generated over 10k random tests without failures.
Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
21
## TODO
32

3+
- Allow attributes in editor marks (importantly for date/author)
4+
45
- attribute handling in ATX headers
56

67
- equation handling
@@ -32,28 +33,3 @@
3233
3334
- in addition, if we _do_ add support for in-block equation ids, we should consider that the output
3435
will not only need to exist for LaTeX, but will need to exist for html and typst as well.
35-
36-
37-
## notes
38-
39-
- I really think Pandoc would benefit from the following rawblock extensions, and I
40-
wonder if we should try to adopt this into Quarto somehow:
41-
42-
- `{<format}` parses input from the rawblock as if it were Pandoc's `format`
43-
44-
- This would be, then, how code opts into Quarto's html-table-is-ast feature.
45-
46-
-
47-
```
48-
::: {>format}
49-
:::
50-
```
51-
52-
process this output as if it were markdown, but only produce output in `format`.
53-
54-
In Quarto, this is "just" syntax for
55-
56-
```
57-
::: {.content-visible when-format="format"}
58-
:::
59-
```

notes.md renamed to docs/wasm.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
## Testing
2-
3-
tree-sitter-markdown-inline has a tree-sitter test suite that can be run with
4-
5-
```
6-
$ tree-sitter test
7-
```
8-
9-
Many tests there were inherited from the grammar we forked. Many of those fail, and some shouldn't actually pass.
10-
11-
In addition to a fixed test suite, we have `./tree-sitter-markdown-inline/scripts/shortcode_generator.py` to test the shortcode parsing subsystem specifically.
12-
It uses random testing to generate large numbers of shortcodes, calls `tree-sitter parse` on them, and checks if the output matches expectations.
13-
14-
We use it to generate failing tests that are then fixed and added to the test suite (crates/tree-sitter-qmd/tree-sitter-markdown-inline/test/corpus/shortcodes.txt).
15-
At present time, we have generated over 10k random tests without failures.
16-
171
## Wasm builds
182

193
```

0 commit comments

Comments
 (0)