OCR markup: # to tags/headings, @ to Wikilinks - #123
Closed
philips-clanker wants to merge 1 commit into
Closed
Conversation
Supernote's handwriting recognition renders starred keywords in OCR text as "#Word" and its own internal-link mentions as "@word(s)". A new processHashtagsAndMentions() post-processes each page's OCR text: - "#Word" (or "# Word", two-word combos also checked as "#word_otherword"): an inline tag if Word is a known vault tag or one of this note's own keyword-star tags (see the noteKeywordTags map built in writeMarkdownFile, stacked on #122's keyword-page-mapping work), otherwise a Markdown heading. - "@word(s)": takes the rest of the line as a Wikilink, so multi-word note names work. Gated behind a new "Convert # and @ in recognized text to tags and wikilinks" setting, on by default. Wrapped in try/catch at the call site so a pathological page's OCR text can't break the whole export. Split out of #81 (by @Floper), ported onto the current processSupernoteText/VaultWriter shape.
This was referenced Jul 29, 2026
pull Bot
pushed a commit
to ben-vargas/supernote-obsidian-plugin
that referenced
this pull request
Jul 29, 2026
…gins Extends PageTextProcessorContext (registerPageTextProcessor's hook, see ocr-plugins.md) with per-page fields an external companion plugin has had no way to see until now: starred keywords, internal links, PAGEID, orientation, and recognition status. Previously the hook only exposed a flat OCR-text string and rasterized image bytes, which was enough to reproduce the OCR-text-pattern half of philips#123 but not philips#122's genuine keyword-star/link handling - see the discussion on philips#145. sn.keywords/sn.links are grouped per page using the same first-4-characters-of-the-Record-key convention supernote-typescript's _parseLinks documents (more reliable than IKeyword.KEYWORDPAGE, which can be '0'/invalid). Verified against a real device-created fixture (supernote-typescript/tests/input/nomad-3.26.40-link-tag-3p.note). Titles were considered too (same "device-native structured signal" category as keywords/links) but dropped from this pass: ITitle has no decoded text, only a bounding box + bitmap, so getting title text needs correlating that box against page.recognitionElements' word boxes - real new logic, not just wiring through an existing field. Bumps the supernote-typescript submodule pointer to a branch (not yet merged) that exports RecognitionStatuses from its index, needed to type the new recognitionStatus field as that enum rather than a bare string - see supernote-typescript#38.
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.
Summary
Split out of #81 (by @Floper), stacked on #122 (needs the
noteKeywordTagsmap built there so this note's own brand-new keyword stars are recognised before they're indexed as vault tags).Supernote's handwriting recognition renders starred keywords in OCR text as
#Wordand its own internal-link mentions as@Word(s). A newprocessHashtagsAndMentions()post-processes each page's OCR text:#Word(or# Word; two-word combos also checked as#word_otherword): becomes an inline tag ifWordis a known vault tag or one of this note's own keyword-star tags, otherwise a Markdown heading.@Word(s): takes the rest of the line as a Wikilink ([[Word(s)]]), so multi-word note names work.Gated behind a new "Convert # and @ in recognized text to tags and wikilinks" setting, on by default. Wrapped in try/catch at the call site so a pathological page's OCR text can't break the whole export.
Test plan
npm run build- cleannpx eslint src/main.ts src/settings.ts- 0 errorsnpx vitest run- 22 passed.notefile whose OCR text contains#SomeTag(both a known vault tag and a novel one) and@Some Note, confirming tag/heading/Wikilink output