Parse Supernote internal links and keyword stars (rebase of #9) - #24
Merged
Conversation
Adds two new parsing features and exposes ILink/IPage as public types: Links (LINKO): the footer's LINKO_* keys were previously unparsed. Adds _parseLinks/_parseLink to SupernoteX, an ILink interface, and ISupernote.links: Record<string, ILink[]>. LINKFILE is a Base64-encoded device path; _parseLink decodes it into a Wikilink-ready `text` field and, via each link's PAGEID, resolves same-document targets to a `#Page N` anchor (cross-file or unmatched links get no anchor). IPage gains an optional PAGEID for this lookup. Keywords (KEYWORD): KEYWORD_* and LINKO_* footer entries are journaled/append-only, so the same key can repeat; these groups are now parsed separately instead of via extractNestedKeyValue, which silently dropped repeats. Also fixes _parseKeyword misreading KEYWORDSITE as a bitmap address instead of a length-prefixed OCR-text block, which had left KEYWORD empty. ILink and IPage are now exported from the package index. Adds nomad-3.26.40-link-tag-3p.note as a test fixture (3 pages, 3 links on page 2, 3 keyword stars on page 3) plus `links` and `keywords` test suites covering anchor resolution and keyword/page parsing. Originally authored by Floper in #9; rebased onto current main (dependency bumps, SupernoteX refactored to explicit `declare` fields for `implements ISupernote`) and squashed for a clean history.
philips
force-pushed
the
rebase-pr-9-links
branch
from
July 25, 2026 06:32
d7d22e2 to
20241b5
Compare
philips
marked this pull request as ready for review
July 25, 2026 06:34
Owner
Author
|
@Floper WDYT of this squash and rebase? |
# Conflicts: # src/index.ts
This was referenced Jul 27, 2026
pull Bot
pushed a commit
to ben-vargas/supernote-obsidian-plugin
that referenced
this pull request
Jul 27, 2026
Brings in philips/supernote-typescript#24 (internal Supernote links and keyword stars, exported as ILink/sn.links and richer sn.keywords), needed by the keywords-to-tags and links-to-Wikilinks export feature split out of philips#81. No plugin-side code changes; this is purely the submodule pointer bump so that dependent feature branches have something to build on.
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.
Rebase of #9 (originally by @Floper) onto current
main, which had drifted significantly (dependency bumps,SupernoteXrefactored to explicitdeclarefields forimplements ISupernote).Original description
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 correctRebase notes
pin image-js to 1.2.0commit: it became a no-op sincemainalready moved toimage-js ^1.7.0with its own breakage fix (92f9033).declare links: Record<string, ILink[]>;field toSupernoteX—mainhad since refactored the class to explicitly declare fields for theimplements ISupernotepattern, and the rebase merged cleanly but silently dropped this field, breaking the build.linksandkeywordssuites) pass on the rebased branch.Closes #9 (superseding it — original branch had unresolvable merge conflicts with current
main).