Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Move inline tokens to external scanner and split the grammar into two pieces #55

Closed
wants to merge 46 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
e5bde4c
Move files into their own block level directory
treeman Aug 20, 2024
0f04575
Remove inline parsing elements from grammar
treeman Aug 21, 2024
eeab9dc
WIP First iteration of djot inline parser
treeman Aug 21, 2024
f38156a
Fix div inside blockquote
treeman Aug 22, 2024
5dcfb87
Inline parser for verbatim
treeman Aug 25, 2024
6cc531a
WIP external scanner for emphasis attempt
treeman Aug 26, 2024
394347b
WIP Almost all emphasis tests pass
treeman Aug 26, 2024
17b3d59
Some cleanup
treeman Aug 26, 2024
5660f6c
Emphasis prototype that passes the weird test cases I could find
treeman Aug 28, 2024
4cc2dd1
Merge verbatim with open elements
treeman Aug 28, 2024
ef94ad6
Mark end at the beginning in scanner
treeman Aug 28, 2024
47d1b88
Some more comments
treeman Aug 28, 2024
b7d9695
Move all span elements to external scanner
treeman Aug 28, 2024
85cf546
Update highlights
treeman Aug 28, 2024
84e0fc7
Move lots of elements to external scanner
treeman Aug 29, 2024
d33cce9
Move footnote markers to external scanner
treeman Aug 29, 2024
d6a62e2
Update comments and refactor a little
treeman Aug 29, 2024
9700795
Fix concealment and highlight of delimiters
treeman Sep 7, 2024
5ce1e6e
Refactor bracket parsing
treeman Sep 8, 2024
b915d05
Ability to escape `)` in link urls
treeman Sep 8, 2024
aeb4754
Fix dynamic precedence and refactor things a bit
treeman Sep 8, 2024
631db8f
\\ before newline shouldn't be a hard linebreak
treeman Sep 8, 2024
e4122c2
Fallback for [^foo
treeman Sep 8, 2024
34928cf
Remove locals, not sure what to do with a split parser
treeman Sep 8, 2024
63dc041
Fix highlights
treeman Oct 5, 2024
fa74cc4
feat: Stop elements inside inline urls and update to 0.24.6
treeman Jan 9, 2025
29ee257
refactor: Separate scanning and parsing end markers (except verbatim)
treeman Jan 9, 2025
e08cd93
feat: Correctly handle precedence for `*[*](y)`
treeman Jan 9, 2025
c19e267
feat: Upgrade djot to tree-sitter 0.24.6
treeman Jan 9, 2025
49bcc15
fix: only consider single alpha characters as list markers
treeman Jan 9, 2025
3473e07
docs: Update readme
treeman Jan 9, 2025
0b241cc
feat: Add fields to nodes and use `inline` for injection
treeman Jan 9, 2025
bb26458
feat: Smarter detection of inline link scanning
treeman Jan 10, 2025
e10ad91
fix: Remove unused verbatim field
treeman Jan 16, 2025
d7132b7
fix: Prevent content from jumping out of lists
treeman Jan 22, 2025
225169f
test: Two more broken list cases
treeman Jan 22, 2025
aeb3fc3
fix: Better spacer detection inside lists
treeman Jan 23, 2025
5426b10
feat: Proper block parsing of footer content (like in lists)
treeman Jan 23, 2025
0036a74
fix: Ending markers for language injection regex
treeman Jan 23, 2025
10b04b4
fix: Prefer inline attributes with text directly following
treeman Jan 23, 2025
260729d
perf: Rewrite table to use external scanner to avoid excessive branching
treeman Jan 23, 2025
ce0d52f
fix: Escape pipes and verbatim support in table cells
treeman Jan 23, 2025
385e7e0
perf: Scan block attributes via external scanner for ~4x speedup
treeman Jan 23, 2025
487a4bc
fix: Narrow verbatim in table cells
treeman Jan 23, 2025
1b53d70
test: More failing block attribute formats
treeman Jan 23, 2025
5e654be
feat: Proper handling of newlines in comments
treeman Jan 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ build
/target/
log.html
*.dj
broken.txt
63 changes: 22 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,12 @@
# tree-sitter-djot

This is an experimental [Tree-sitter][] grammar for [Djot][].

# Features

Aims to be fully feature complete with the [Djot specification][]:

- [x] Inline syntax
- [x] Links
- [x] Image
- [x] Autolink
- [x] Verbatim
- [x] Emphasis/strong
- [x] Highlighted
- [x] Super/subscript
- [x] Insert/delete
- [x] Smart punctuation
- [x] Math
- [x] Footnote reference
- [x] Line break
- [x] Comment
- [x] Symbols
- [x] Raw inline
- [x] Span
- [x] Inline attributes
- [x] Block syntax
- [x] Paragraph
- [x] Heading
- [x] Block quote
- [x] List item with the different marker types
- [x] List
- [x] Code block
- [x] Thematic break
- [x] Raw block
- [x] Div
- [x] Pipe table
- [x] Reference link definition
- [x] Footnote
- [x] Block attribute

Also contains some extra features not included in the Djot standard:
A [Djot][] parser for [tree-sitter][].

## Features

Aims to be feature complete with the [Djot specification][].

The parser contains some features outside the [Djot][] standard:

- Parses an optional frontmatter at the very start of the file, e.g:

Expand All @@ -51,6 +18,20 @@ Also contains some extra features not included in the Djot standard:

- Highlights standalone `TODO`, `NOTE` and `FIXME`.

[Tree-sitter]: https://tree-sitter.github.io/tree-sitter/
## Split parser

The parser is split into two grammars that you'll need to install/include:

1. `djot` that parses the block syntax on the top level.
2. `djot_inline` that parses all inline contexts and should be injected into the `inline` nodes from the block level parser.

> [!note]
> `split` is the main branch of this repository and the `master` branch with the old combined parser won't be maintained.

> [!warning]
> The generated language bindings for the split parsers haven't been thoroughly tested.
> If you find a problem please file an issue.

[tree-sitter]: https://tree-sitter.github.io/tree-sitter/
[Djot]: https://djot.net/
[Djot specification]: https://htmlpreview.github.io/?https://github.com/jgm/djot/blob/master/doc/syntax.html
Loading