Obsidian: Obsidian Flavored Markdown for Racket
| (require obsidian) | package: obsidian |
Parses and renders Obsidian Flavored Markdown: YAML frontmatter, [[wikilinks]], ![[embeds]], callouts, inline tags, highlights and task lists.
Why this package exists: Obsidian’s dialect is the de-facto note format of a large ecosystem, yet every renderer for it lives in JavaScript. This package is a Racket implementation built on top of the markdown package — CommonMark parsing stays there; everything here is the dialect layer. It is editor-neutral by design: frontmatter is tolerated, never required, and no dialect feature is load-bearing, so plain Markdown renders identically.
Invariants:
Code never lies about content: [[links]], ==marks== and #tags inside code blocks and inline code are always left literal.
Unresolvable [[wikilinks]] degrade to their label text — no dead links are ever rendered.
Unresolvable non-image ![[embeds]] degrade to their plain wikilink form — nothing is silently dropped.
1 Frontmatter
procedure
(strip-frontmatter src) → string?
src : string?
2 Rendering
parameter
(current-resolve-wikilink) → (-> string? (or/c string? #f))
(current-resolve-wikilink resolve-wikilink) → void? resolve-wikilink : (-> string? (or/c string? #f))
parameter
→ (-> string? (or/c (listof any/c) #f)) (current-resolve-embed resolve-embed) → void? resolve-embed : (-> string? (or/c (listof any/c) #f))
procedure
(obsidian->xexprs src) → (listof any/c)
src : string?
procedure
(obsidian->html src) → string?
src : string?
procedure
(document-title src) → (or/c string? #f)
src : string?
procedure
(document-tags src) → (listof string?)
src : string?
3 AST transforms
procedure
(rewrite-embeds elements resolve-embed) → (listof any/c)
elements : (listof any/c) resolve-embed : (-> string? (or/c #f (listof any/c)))
procedure
(rewrite-wikilinks elements resolve-wikilink) → (listof any/c) elements : (listof any/c) resolve-wikilink : (-> string? (or/c string? #f))
procedure
(rewrite-highlights elements) → (listof any/c)
elements : (listof any/c)
procedure
(rewrite-tags elements) → (listof any/c)
elements : (listof any/c)
procedure
(rewrite-callouts elements) → (listof any/c)
elements : (listof any/c)
procedure
(rewrite-task-lists elements) → (listof any/c)
elements : (listof any/c)
Source-level passes (needed because the underlying parser eats the ! of embeds and merges blockquote lines, both fatal to embeds and callouts) are exposed too.
procedure
(mark-embeds src) → string?
src : string?
procedure
(mark-callouts src) → string?
src : string?
procedure
(mark-dashes src) → string?
src : string?
4 Known limitations
Callout titles are plain text; inline markup inside a title is not rendered.
Indented (four-space) code blocks are not protected by source passes; Obsidian-authored content uses fenced blocks.
Smart typography of the underlying parser is partially neutralized: hyphen-digit sequences (#tag-2) are un-escaped to literal hyphens so tags and slugs survive; quote styling is left as the parser produces it.