Skip to content

feat: Read markup from the grammar - #1207

Open
seflue wants to merge 4 commits into
masterfrom
feat/treesitter-markup
Open

seflue wants to merge 4 commits into
masterfrom
feat/treesitter-markup

Conversation

@seflue

@seflue seflue commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Closes #452, closes #1014

Moves to tree-sitter-org 2.1.0 and highlights markup through the treesitter query instead of the Lua markup highlighter. The highlight groups are unchanged, so user overrides keep working.

  • Cookies: every cookie in a headline title or list item is now updated, as in Emacs, not only the first one in a title or one at the end of a list item. The grammar splits [1/2] into several nodes, so they are read from the text.
  • Tangle paths: block parameters are read as source text, since the grammar also splits ./dir/file.lua.
  • Emphasis markers: concealed by the query when org_hide_emphasis_markers is set.
  • Docs: the contributing guide describes how to update orgmode to a new grammar tag.

Orgmode installs tree-sitter-org from a release tag, which the guide
did not mention. List the steps to move orgmode to a new tag.
@seflue
seflue requested a review from kristijanhusak November 9, 2026 21:52
seflue and others added 3 commits November 9, 2026 23:58
Grammar 2.1.0 parses inline markup, so the Lua markup highlighter
is no longer needed. Highlight markup through the treesitter query
and read it from the tree in agenda lines.

Co-authored-by: Kristijan Husak <husakkristijan@gmail.com>
Markup highlighting moved from the Lua highlighter to the treesitter
highlights query, which dropped concealing of emphasis markers. The
org_hide_emphasis_markers option had no effect anymore.

The query now conceals the open and close delimiters of valid markup
when the option is enabled, gated by a predicate that reads it.
The markup grammar splits words at markup characters, so a cookie
like [1/2] or a tangle path like ./dir/file.lua is several nodes.
Cookies were looked up as one node and were no longer updated, and
tangle joined the parameter nodes with spaces and wrote to the wrong
file.

Find statistics cookies in the text like Emacs does: every cookie in
the headline title, and every cookie in a list item's own text, at
any position and on any line. This gives the same result with both
grammars. Read block parameters as the source text they cover.
Joining adjacent nodes would also work, but still depends on how the
grammar splits a word.
@seflue
seflue force-pushed the feat/treesitter-markup branch from ce9f843 to 5723b0f Compare November 9, 2026 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Latex highlighting does not apply to start buffer Improper syntax highlight for dollar sign $

1 participant