Color mode

Obsidian Markdown

Obsidian-flavored Markdown support: wikilinks, callouts, inline tags, and block references.

日本語

Overview

obsidianMarkdown() registers remark transforms that convert Obsidian syntax during the build. It runs with order: -20 so it processes content before other Markdown plugins.

Usage

ts
import { defineConfig } from "@riebeckite/core";
import { obsidianMarkdown } from "@riebeckite/plugin-obsidian-markdown";
 
export default defineConfig({
  // ...
  plugins: [obsidianMarkdown()],
});

Syntax

  • [[Note]] → link to the target's resolved canonical permalink (ContentManifestEntry.permalink) with class wikilink, alias with [[Note|Alias]]. The target is looked up by slug; the href is the resolved permalink
  • Fragments: [[Note#Heading]] → #heading-slug, [[Note#^block-id]] → #block-id
  • ![[Note]] → note embed. The core pipeline renders the target note recursively (max depth 3, cycle-safe). Unresolved embeds render a placeholder link or text
  • ![[image.png]] → <img> under assetBase
  • [[image.png]] → link to the asset URL
  • [[file.pdf]] / ![[file.pdf]] → rendered by a plugin that provides renderAttachment (see @riebeckite/plugin-attachment), otherwise a plain download link
  • Unresolvable targets → link with class wikilink wikilink-broken

Callouts

md
> [!note] Optional title
> Callout content.
 
> [!warning]- Collapsed by default
> More content.

Output: div.rr-callout.rr-callout--{type} with data-callout, plus rr-callout--collapsible / rr-callout--collapsed for + / - markers. Titles fall back to built-in defaults (note, tip, warning, danger, bug, quote, ...).

Inline tags

  • #tag, #nested/tag → link to {tagBase}{slugified tag} with class tag and data-tag
  • Purely numeric tags are ignored; trailing / and - are stripped
  • Each tag also triggers the optional onTag callback

Block references

  • A trailing ^block-id on a block is removed from the text and applied to the element as id and data-block-id

Options

Option Type Default Description
assetBase string "/" Base path for image wikilink URLs
callout.defaultTitles Record<string, string> built-in map Override default callout titles
tag.tagBase string "/tags/" Tag page base path
tag.onTag (tag: string) => void — Called for every tag found

Exports

  • obsidianMarkdown(options?) / obsidianMarkdownPlugin — plugin factory
  • Types: ObsidianMarkdownOptions, CalloutOptions, TagOptions, WikilinkOptions, WikilinkFragment

See also

History

1 changesCollapseExpand
1 + <!-- Generated from packages/plugins/obsidian-markdown/README.md. Do not edit this page directly; edit the package README and run `pnpm docs:sync`. -->
2 +
3 + # Obsidian Markdown
4 +
5 + Obsidian-flavored Markdown support: wikilinks, callouts, inline tags, and
6 + block references.
7 +
8 + [日本語](./obsidian-markdown.md)
9 +
10 + ## Overview
11 +
12 + `obsidianMarkdown()` registers remark transforms that convert Obsidian syntax
13 + during the build. It runs with `order: -20` so it processes content before
14 + other Markdown plugins.
15 +
16 + ## Usage
17 +
18 + ```ts
19 + import { defineConfig } from "@riebeckite/core";
20 + import { obsidianMarkdown } from "@riebeckite/plugin-obsidian-markdown";
21 +
22 + export default defineConfig({
23 + // ...
24 + plugins: [obsidianMarkdown()],
25 + });
26 + ```
27 +
28 + ## Syntax
29 +
30 + ### Wikilinks
31 +
32 + - `[[Note]]` → link to the target's resolved canonical permalink
33 + (`ContentManifestEntry.permalink`) with class `wikilink`, alias with
34 + `[[Note|Alias]]`. The target is looked up by slug; the `href` is the resolved
35 + permalink
36 + - Fragments: `[[Note#Heading]]` → `#heading-slug`,
37 + `[[Note#^block-id]]` → `#block-id`
38 + - `![[Note]]` → note embed. The core pipeline renders the target note
39 + recursively (max depth 3, cycle-safe). Unresolved embeds render a
40 + placeholder link or text
41 + - `![[image.png]]` → `<img>` under `assetBase`
42 + - `[[image.png]]` → link to the asset URL
43 + - `[[file.pdf]]` / `![[file.pdf]]` → rendered by a plugin that provides
44 + `renderAttachment` (see `@riebeckite/plugin-attachment`), otherwise a plain
45 + download link
46 + - Unresolvable targets → link with class `wikilink wikilink-broken`
47 +
48 + ### Callouts
49 +
50 + ```md
51 + > [!note] Optional title
52 + > Callout content.
53 +
54 + > [!warning]- Collapsed by default
55 + > More content.
56 + ```
57 +
58 + Output: `div.rr-callout.rr-callout--{type}` with `data-callout`, plus
59 + `rr-callout--collapsible` / `rr-callout--collapsed` for `+` / `-` markers. Titles fall back to
60 + built-in defaults (`note`, `tip`, `warning`, `danger`, `bug`, `quote`, ...).
61 +
62 + ### Inline tags
63 +
64 + - `#tag`, `#nested/tag` → link to `{tagBase}{slugified tag}` with class `tag`
65 + and `data-tag`
66 + - Purely numeric tags are ignored; trailing `/` and `-` are stripped
67 + - Each tag also triggers the optional `onTag` callback
68 +
69 + ### Block references
70 +
71 + - A trailing `^block-id` on a block is removed from the text and applied to
72 + the element as `id` and `data-block-id`
73 +
74 + ## Options
75 +
76 + | Option | Type | Default | Description |
77 + | ------ | ---- | ------- | ----------- |
78 + | `assetBase` | `string` | `"/"` | Base path for image wikilink URLs |
79 + | `callout.defaultTitles` | `Record<string, string>` | built-in map | Override default callout titles |
80 + | `tag.tagBase` | `string` | `"/tags/"` | Tag page base path |
81 + | `tag.onTag` | `(tag: string) => void` | — | Called for every tag found |
82 +
83 + ## Exports
84 +
85 + - `obsidianMarkdown(options?)` / `obsidianMarkdownPlugin` — plugin factory
86 + - Types: `ObsidianMarkdownOptions`, `CalloutOptions`, `TagOptions`,
87 + `WikilinkOptions`, `WikilinkFragment`
88 +
89 + ## See also
90 +
91 + - [Plugin guide](../reference/plugin-api.en.md)
92 + - [`@riebeckite/plugin-attachment`](./attachment.en.md)
93 +