Skip to content

Commit 60b3fd9

Browse files
committed
more on syntax
1 parent 8359604 commit 60b3fd9

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

posts/2025-02-28-syntax/index.qmd

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,21 @@ Similarly, inline executable code cells have the language attribute declared ins
5656
code non-executable inline code elements have attributes declared outside the ticks.
5757
We could improve all of this.
5858

59+
## Notes
60+
61+
### 2:04PM
62+
63+
```
64+
$ pandoc -f markdown to native
65+
## Hello {#id .class key=value}
66+
^D
67+
[ Header
68+
2
69+
( "id" , [ "class" ] , [ ( "key" , "value" ) ] )
70+
[ Str "Notes" ]
71+
]
72+
```
73+
74+
Pandoc supports attributes at the end of ATX heading lines as the above example.
75+
This seems hard to do in the way that `tree-sitter-markdown` is structured, because the
76+
entire line starting with `##` is sent to the `inline` grammar.

posts/2025-03-02/index.qmd

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: Syntax errors are Good, Actually
3+
author: Carlos
4+
date: 2025-03-03
5+
categories:
6+
- syntax
7+
---
8+
9+
I consider the following [sentence in the CommonMark spec](https://spec.commonmark.org/0.31.2/#preliminaries) to be a fatal flaw in its design:
10+
11+
> Any sequence of characters is a valid CommonMark document.
12+
13+
Syntax errors are good!
14+
People make typos; a good language makes it so that common typos are obviously detectable.
15+
Imagine ifevery sequence of characters were a valid English word.
16+
The reason it isn't the case, of course, is that languages that are bad like this are selected away.
17+
18+
Why is CommonMark making this obvious mistake?
19+
I don't understand it.
20+
A lack of errors isn't a kindness to novice users.
21+
It's the other way around!
22+
23+
Incidentally, this is another thing that [Typst](https://typst.app/docs/) gets right.
24+
You get _excellent_ syntax errors and linting when using Typst.
25+
That's how it should be!
26+
27+
And that's what we're going to try in Quarto Markdown.
28+
A syntax that's as close to Markdown as we can make it, but for which you get proper syntax errors.
29+
30+
Consider [Example 307](https://github.github.com/gfm/#example-307) from the GFM spec:
31+
32+
> Input: `` `hi`lo` ``
33+
>
34+
> Output: `` <p><code>hi</code>lo`</p> ``
35+
36+
This really should be a syntax error.
37+
Mismatched backquotes should be disallowed, and "naked" backquotes should be escaped (likely with a backslash).
38+
I'm not sure how many of these classes of examples we will be able to convert, but it should give you an idea

0 commit comments

Comments
 (0)