Obsidian:   Obsidian Flavored Markdown for Racket
1 Frontmatter
split-frontmatter
strip-frontmatter
frontmatter->alist
2 Rendering
current-resolve-wikilink
current-resolve-embed
obsidian->xexprs
obsidian->html
document-title
document-tags
3 AST transforms
rewrite-embeds
rewrite-wikilinks
rewrite-highlights
rewrite-tags
rewrite-callouts
rewrite-task-lists
map-source-text
mark-embeds
mark-callouts
mark-dashes
4 Known limitations
9.3

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

(split-frontmatter src) → 
(or/c #f (alist/c string? string?))
string?
  src : string?
Splits an optional leading — fence into naive top-level key: value pairs and the body. The fence must start on line one; an unclosed fence is ordinary content.

procedure

(strip-frontmatter src) → string?

  src : string?
Returns the body without the frontmatter block. Documents without frontmatter pass through unchanged.

procedure

(frontmatter->alist lines)

 → (or/c #f (alist/c string? string?))
  lines : (listof string?)
Naive top-level key: value extraction. Nested structures are skipped on purpose — frontmatter is a hint, never structure the pipeline depends on.

2 Rendering🔗ℹ

parameter

(current-resolve-wikilink) → (-> string? (or/c string? #f))

(current-resolve-wikilink resolve-wikilink) → void?
  resolve-wikilink : (-> string? (or/c string? #f))
Maps a trimmed [[wikilink]] target to a URL. #f degrades the link to its label text.

parameter

(current-resolve-embed)

 → (-> string? (or/c (listof any/c) #f))
(current-resolve-embed resolve-embed) → void?
  resolve-embed : (-> string? (or/c (listof any/c) #f))
Maps a trimmed ![[embed]] target to elements to splice in. When it returns #f, image targets get a default <img> and everything else degrades to the plain wikilink form.

procedure

(obsidian->xexprs src) → (listof any/c)

  src : string?
Parses source (stripping frontmatter) and applies every dialect rewrite, returning xexpr elements — the same AST shape the markdown package produces.

procedure

(obsidian->html src) → string?

  src : string?
Convenience wrapper rendering obsidian->xexprs to an HTML string.

procedure

(document-title src) → (or/c string? #f)

  src : string?
The first H1’s text, or #f. This is the editor-neutral replacement for frontmatter titles: the title lives in the body, not in metadata.

procedure

(document-tags src) → (listof string?)

  src : string?
All inline tags in document order, deduplicated.

3 AST transforms🔗ℹ

Each rewrite-* function takes the element list produced by parse-markdown (or another rewrite) and can be used à la carte:

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

(map-source-text src fn) → string?

  src : string?
  fn : (-> string? string?)
Applies fn to ordinary text of src; fenced code blocks and inline code spans pass through byte-for-byte.

procedure

(mark-embeds src) → string?

  src : string?
Code-safe source pass replacing ![[target]] with a marker form that survives the upstream parser.

procedure

(mark-callouts src) → string?

  src : string?
Code-safe source pass rewriting callout blockquotes into marker-delimited plain Markdown that rewrite-callouts collects.

procedure

(mark-dashes src) → string?

  src : string?
Code-safe source pass escaping hyphen-digit sequences so the upstream parser’s smart dashes cannot corrupt tags and slugs.

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.