Feat/auto markdown links tags - #81
Conversation
check isAutoSyncMarkdownEnabled first.then check file extension
|
Thanks for this — it's a lot of useful functionality.
Not carried forward: the Leaving this one open for reference; happy to close it once the split PRs are reviewed, or keep it open longer if you'd rather. Attribution is preserved in each PR description. |
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.
|
Heyo! So, I have been thinking about this quite a bit and I have decided to try and enable people to hook the note file conversion process. If this is of interest to you here is an LLM generated prototype that implements some (most?) of what you want on top of the beta hook. https://github.com/philips/supernote-obsidian-ocr-keywords |
|
@philips amazing. |
Markdown export: links, tags, OCR markup, auto-sync and mirror folder
This PR builds on the updated
supernote-typescriptsubmodule (which now parsesinternal links and keyword stars) to surface those features as Obsidian-native
constructs in the exported markdown. It also fixes several bugs in the auto-sync
workflow and adds new settings to control the behaviour.
Supernote keywords → Obsidian tags
Starred keywords from the Supernote app are emitted as Obsidian tags (e.g.
#Supernote_Keyword) on the correct page of the exported markdown, rather thanas a flat list at the top of the document.
1-indexed), matching the LINKO key format. This is more reliable than the
KEYWORDPAGEfield, which can be'0'(invalid).same tag was already embedded in the processed OCR text (see below), it is not
repeated in the page header.
yet indexed in the Obsidian vault — are still recognised as tags rather than
headings during OCR processing.
Supernote links → Wikilinks
Internal links created via the Supernote link feature are emitted as Obsidian
Wikilinks on the correct page.
1-indexed) rather than
OBJPAGE, which is unreliable.(the key encodes the Y coordinate after the page prefix).
textfield already contains#Page N(resolved by the library). For cross-file links the plugin loads thetarget
.notefrom the vault, parses it, and resolves thePAGEIDto a pagenumber — e.g.
[[other-note#Page 2]]. A per-call cache avoids re-parsing thesame file multiple times.
PAGEID: 'none'or where the target file is not in the vaultproduce a plain Wikilink without a page anchor.
OCR markup:
#→ tags/headings,@→ WikilinksA new
processHashtagsAndMentionsfunction post-processes the OCR text of eachpage:
#Wordor# Word: checked against the Obsidian vault tag index. If the tagexists → inline tag (
#Word); otherwise → Markdown heading (# Word). Two-wordcombinations (e.g.
# Existing Tag) are also checked as#existing_tagbeforefalling back to a heading. The note's own keyword stars are checked first so
newly created tags are recognised even before they appear in the vault index.
@ Word(s): everything after the@on the same line becomes a Wikilink(
[[Word(s)]]), supporting multi-word note names.Auto-sync fixes
`${file.parent?.path}/${file.basename}.md`which produces//name.mdforvault-root files (Obsidian returns
"/"as the root folder path). The outputpath is now derived from
file.path.replace(/\.note$/i, '.md'), which Obsidianalways formats correctly.
.notefile syncs, Obsidian fires both'create'and
'modify'events in quick succession. Both handlers calledvault.create, causing a "File already exists" error. Theoverwritepathnow wraps
vault.createin a try/catch and retries withvault.modifywhenthe file appeared between the existence check and the create.
attachMarkdownFilenow properlyawaitswriteMarkdownFileso errorssurface rather than being silently dropped as unhandled promise rejections.
.catch()handlers added to both vault event callbacks so any remaining errorsappear in the developer console instead of as uncaught exceptions.
Markdown mirror folder
A new optional setting lets users save all exported markdown files into a
dedicated vault folder that mirrors the
.notefile structure, instead ofplacing each
.mdfile alongside its.notefile.alongside). Example value:
SupernoteMarkdowns.ensureFolderExistswalks the path segment by segment, creating any missingintermediate folders (with a concurrent-creation guard).
New settings
All new behaviours are opt-out via toggles in the plugin settings:
isAutoSyncMarkdownEnabledfalse.notefile changesisKeywordsAndLinksEnabledtrueisHashtagsMentionsEnabledtrue#and@in OCR textmarkdownMirrorFolder""