Feat/keywords links support#9
Draft
Floper wants to merge 7 commits into
Draft
Conversation
Floper
marked this pull request as draft
June 4, 2026 08:11
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.
Parse Supernote internal links and keyword stars
This PR adds two new parsing features to the library: internal link resolution
(with page anchors) and keyword/star text extraction. It also exposes
ILinkand
IPageas public types.Links (
LINKO)The Supernote format stores internal links in the footer under
LINKO_*keys.These were not previously parsed at all.
_parseLinks/_parseLinkmethods toSupernoteX— symmetrical tothe existing keyword and title parsers
ILinkinterface toformat.tsand exposed it onISupernote.linksasRecord<string, ILink[]>LINKFILEfield is a Base64-encoded absolute device path;_parseLinkdecodes it and extracts the filename (without path or
.noteextension) into atextfield ready for use as a WikilinkPAGEIDthat identifies thetarget page.
_parseLinklooks up thatPAGEIDinthis.pages(populatedbefore links are parsed). If matched — i.e. the link points to a page in the
same document — it appends
#Page Ntotext(e.g."my-note#Page 1").Cross-file links where the target is not in this document produce no anchor.
PAGEID?: stringtoIPageso page identity is accessible for the lookupKeywords (
KEYWORD)The
KEYWORD_*andLINKO_*footer entries use a journaled/append-only format,meaning the same key can appear multiple times. The previous footer parser used
extractNestedKeyValuewhich silently drops repeated keys. These two groups arenow extracted separately, preserving every entry as a
stringorstring[].Additionally,
_parseKeywordpreviously leftKEYWORDempty because it misreadKEYWORDSITEas a bitmap address.KEYWORDSITEactually points to alength-prefixed block containing the OCR text of the starred word. This is now
correctly decoded into the
KEYWORDfield.Public API
ILinkandIPageare now exported from the package index, allowing consumersto type link and page data without reaching into internal modules.
Tests
nomad-3.26.40-link-tag-3p.noteas a test fixture (3 pages, 3 links onpage 2, 3 keyword stars on page 3 including a brand-new tag)
linkssuite: verifies same-file links get a#Page Nanchor via PAGEIDlookup; cross-file links with a PAGEID but no matching page in this document
produce no anchor; links with
PAGEID: 'none'produce no anchorkeywordssuite: verifies all 3 keyword stars are parsed with correct OCRtext; verifies that the KEYWORD footer key prefix (first 4 digits, 1-indexed)
reliably encodes the source page — including the known case where
KEYWORDPAGEitself is
'0'(invalid) while the key prefix is correct