Refactor ZknLink and ZknTag parsing#5997
Merged
Merged
Conversation
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 :) |
Collaborator
Author
|
Totally fine! This is mostly for completeness since these are the last two parsers to be refreshed. |
4e24afc to
b04d477
Compare
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! |
Collaborator
Author
|
Definitely. I'll keep this up without the subtags |
Member
|
Thank you so much!! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR refactors the ZknLink and ZknTag parsers and node structure, and it implements namespaced subtags, i.e.
#org/groupcreates#organd#org/grouptagsChanges
The ZknLink parser was refactored to use delimiters. A
ZknLinkMarknode was added and applied to the opening and closing brackets.The ZknTag parser was refactored. The
ZknTagContentnode was replaced with aZknTagMarknode to better align with the semantics of other nodes.allowedCharsBeforewas refactored to a regex test, andtagRewas 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 outFinally, a few places throughout the code were updated to match the new link and tag structure.
I also organized and deduplicated the list ofEMPTY_NODESinparse-children.tsAdditional information
Tested on: macOS 26