Comments (11)
I'd like to point out that this treesitter repository for commonmark is now recommended for use over the repository linked before.
from djot.
This would be 100% accurate (but not incremental, which might be an issue on large files).
One of the reasons I'm really interested in djot is because editing CommonMark documents becomes a pain when the documents become fairly large. It'd be awesome if editing djot documents doesn't feel that way as well.
from djot.
I don't know anything about tree-sitter, but this would be a great project for someone who does.
from djot.
Made a start on this in the tree-sitter
directory.
from djot.
OK, it looks like we'd need to define some external scanners to make this work, since the regexes tree-sitter allows don't include any assertions. (We won't be able to distinguish open- and close-emph delimiters, for example.) But tree-sitter does allow you to define external scanners in C, so maybe we could do this.
from djot.
https://tree-sitter.github.io/tree-sitter/creating-parsers#external-scanners
from djot.
Oh, thanks, that one is much easier to understand!
from djot.
An interesting option for nvim would be to use the djot lua library itself to do the lexing, and call https://neovim.io/doc/user/api.html#nvim_buf_add_highlight()
directly to add the highlighting. (nvim has a Lua api.)
This would be 100% accurate (but not incremental, which might be an issue on large files).
from djot.
That function wants to have (line, column) locations, but column is byte indexed. We could convert our current byte offsets to (line, column-byte) pairs by counting newlines. Perhaps we should change the Lua library so that it can efficiently produce this output as well as absolute byte offsets.
from djot.
Interesting. Well, we could try the thing I suggest above and see how it works. The parser is very fast, so maybe it will be okay. It would require a few changes in the Lua library, but then it should be fairly straightforward.
from djot.
While using the lua engine directly might be a good solution for highlighting, having a treesitter grammar has other advantages. In neovim, treesitter is also used for editing (selecting, deleting etc.) and navigation. Basically, as a common language abstraction, it makes integration between arbitrary plugins and arbitrary languages easier, resulting in a more homogeneous/higher level experience. So that would be a pro for a treesitter solution. Also, treesitter is supported by many editors (emerging ones like helix and zed), while a lua solution would need some integration code for each editor. (Pretty excited by the future of djot btw.)
from djot.
Related Issues (20)
- Allow Unicode symbols for list items such as •, ◦, ‣ HOT 3
- Explicit admonition types HOT 31
- Blockquote attribution / citation HOT 1
- Inclusion of other djot documents HOT 18
- Tight list and attributes HOT 1
- Task list item should allow for non-Latin checkmark HOT 4
- Limit numbers in ordered list markers HOT 5
- `[text][]` is shorthand for `[text][text]` – should `[text]()` mean `[text](text)`? HOT 3
- Footnote labels may contain spaces but not newlines
- Inline container precedence with attributes HOT 2
- Document implicit section behavior HOT 6
- Relax disallowing multiple words in `code block` / `div` first line? HOT 12
- Introduce leaf div (with `::`)
- Make `<section/>` wrappers optional (for HTML) HOT 4
- Normalize names of inline/block flavors HOT 2
- Canonical large-ish djot document (and related pandoc issues) HOT 5
- Parsing ambiguity: bracketed content followed by footnote? HOT 4
- Syntax for ruby (<ruby>) HOT 1
- Block level referencing and reuse syntax HOT 1
- URLs with parenthesis break parser HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from djot.