Skip to content

Refactor ZknLink and ZknTag parsing#5997

Merged
nathanlesage merged 3 commits into
Zettlr:developfrom
benniekiss:zkn
Jan 15, 2026
Merged

Refactor ZknLink and ZknTag parsing#5997
nathanlesage merged 3 commits into
Zettlr:developfrom
benniekiss:zkn

Conversation

@benniekiss

@benniekiss benniekiss commented Nov 8, 2025

Copy link
Copy Markdown
Collaborator

Description

This PR refactors the ZknLink and ZknTag parsers and node structure, and it implements namespaced subtags, i.e. #org/group creates #org and #org/group tags

Changes

The ZknLink parser was refactored to use delimiters. A ZknLinkMark node was added and applied to the opening and closing brackets.

The ZknTag parser was refactored. The ZknTagContent node was replaced with a ZknTagMark node to better align with the semantics of other nodes. allowedCharsBefore was refactored to a regex test, and tagRe was refactored to a simpler pattern, which I believe still captures the goal of the original. The parser was also refactored to support nested sub tags, as described below.

The Zettelkasten tags now support nested namespaces, as described in #4638. I went forward with this implementation because the diff to implement it was not that large. However, this would be a large change in the syntax and functionality of tags. For that reason, all of the implementation is contained within 26d4be0, so this commit can be dropped if so desired. It also means that the diff for that commit shows all that's required in addition to the base commit. separated out

Finally, a few places throughout the code were updated to match the new link and tag structure. I also organized and deduplicated the list of EMPTY_NODES in parse-children.ts

Additional information

Tested on: macOS 26

@nathanlesage

Copy link
Copy Markdown
Member

Great Initiative, as always! But I'd like to let this one simmer a bit, primarily because I'm worried what might break with this refactor. Also, the 4.0 changelog is ridiculously long already so it wouldn't hurt to push this one a bit further down the line :)

@benniekiss

Copy link
Copy Markdown
Collaborator Author

Totally fine! This is mostly for completeness since these are the last two parsers to be refreshed.

@benniekiss benniekiss force-pushed the zkn branch 3 times, most recently from 4e24afc to b04d477 Compare December 9, 2025 23:23
@nathanlesage

Copy link
Copy Markdown
Member

Since you keep this updated so diligently, would you mind separating the refactoring from the sub tag-support? I don't have the headspace for thinking about sub tags right now, and that way we can already merge your improvements beforehand!

@benniekiss

Copy link
Copy Markdown
Collaborator Author

Definitely. I'll keep this up without the subtags

@nathanlesage

Copy link
Copy Markdown
Member

Thank you so much!!

@nathanlesage nathanlesage merged commit 95cc5f3 into Zettlr:develop Jan 15, 2026
1 check passed
@benniekiss benniekiss deleted the zkn branch January 15, 2026 15:45
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.

2 participants