zfb
GitHub リポジトリ

検索したい単語を入力

いつでも検索バーを開ける

Markdown 機能

zfb の Markdown パイプラインが提供するすべての機能と設定面。Core パイプラインの挙動と opt-in 機能を含みます。

zfb の Markdown パイプラインは階層構造になっています。Core 機能の一群は エンジンのメイン Markdown パイプライン / config surface の中で動作し、見出しアンカー、 サーバーサイドのシンタックスハイライト、CJK フレンドリーな処理などを提供します。 Core の行には常時有効なものもあれば、トップレベルまたは markdown.* config knob として Core パイプラインに実装されているものもあります。下の表は、各 Core / Opt-in サーフェスの デフォルトと設定キーをすべて記載することを目指していますが、config スキーマから生成された ものではなく手作業で保守されているため、新しく追加された構文に追随できていない場合が あります。最新の挙動は、リンク先の機能ページやそれが対応する config 型で確認してください。

このページは全体の地図です。各機能には、使用例・設定キー・順序に関する 注意点をまとめた専用ページがあります。

依存グラフ

zfb-content          — コア機能はここにある。常にコンパイルされる
  └─ zfb-md-extras   — オプトイン機能。コンパイルはされるが実行時にゲートされる
       └─ zfb-md-ast — 共有 AST 型(MdastNode、HastNode、ビジター)

zfb-md-ast クレートは MdastVisitor および HastVisitor トレイトと 共有ノード型を定義します。コアとオプトインの両方の機能がこれらの トレイトを実装します。

ティアの規約

  • Corezfb-content またはトップレベルの Markdown config surface に実装されています。Core は常に「設定不可」を意味するわけではありません。設定キーとデフォルトは表で確認してください。

  • Opt-in — config で有効化されない限り無効です。opt-in feature entry の多くは markdown.features.* 配下にありますが、stripMdExtmarkdown.hardBreaks は opt-in のトップレベルオプションです。

各機能ページでは、タイトル付近に Core または Opt-in のバッジが表示されます。

設定の形

zfb.config.ts
import { defineConfig } from "zfb/config";

export default defineConfig({
  stripMdExt: true,
  markdown: {
    hardBreaks: true,
    features: {
      mermaid: true,
      directives: {
        note: "Note",
        tip: "Tip",
      },
    },
  },
});

Boolean shorthand は普遍ではありません。値の形に boolean を含む行でだけ使えます。codeEnrichmenttocExportimageDimensionslinkValidationtranscludeheadingIds のような object-only の行には object が必要です。未知のキーは config load 時に拒否されます。

機能マップ

FeatureTierConfig keyValue shapeDefault / gating
GFM 構文Coremarkdown.gfmboolean | { strikethrough?: boolean; table?: boolean; autolinkLiteral?: boolean; taskListItem?: boolean; footnoteDefinition?: boolean }省略時は保守的なデフォルト(strikethrough / table / autolinkLiteral が on、残り 2 つは off)。true / false のショートハンドは 5 つすべてを切り替える。
CJK フレンドリーな強調Coremarkdown.cjkFriendlybooleantrue; opt out するには false
見出しリンクCoremarkdown.features.headingIds{ strategy?: "flat" | "hierarchical" }Plugin は常に有効。デフォルト strategy は "flat"
コードブロックのタイトルCorenonen/a常に有効。
外部リンクCoremarkdown.externalLinks{ target?: string; rel?: string[] }指定されない限り off。
リンク解決CoreresolveMarkdownLinks{ enabled?: boolean; docsDir?: string; dirs?: { dir: string; routePrefix: string }[]; onBrokenLinks?: "warn" | "error" | "ignore" }enabled: true でない限り off。
.md 拡張子の除去Opt-instripMdExtbooleanfalse; true のとき .md / .mdx を除去して / を付ける。
ハード改行Opt-inmarkdown.hardBreaksbooleanfalse; true のとき soft line break が <br> になる。
シンタックスハイライトCorecodeHighlight{ theme?: string; themesDir?: string; themeLight?: string; themeDark?: string; mode?: "inline" | "class"; classPrefix?: string; roleClasses?: Partial<Record<CodeHighlightRole, string>>; defaultStylesheet?: boolean }デフォルトの syntect テーマで有効(mode: "inline")。mode: "class" はセマンティックな role class を出力する — 完全な形はリンク先ページを参照。
ディレクティブレジストリCore primitivemarkdown.features.directives or Rust APIRecord<string, DirectiveSpec>レジストリ visitor は指定されたときだけ実行。デフォルト名はゼロ。
ディレクティブOpt-inmarkdown.features.directivesRecord<string, string | { component: string; kind?: "container" | "leaf" | "text"; titleFromLabel?: boolean }>省略時は off。{} は空のレジストリを配線する。
Mermaid ダイアグラムOpt-inmarkdown.features.mermaidboolean | {}省略または false で off。ブロックを <div class="mermaid"> としてマークする。
見出しマーカー TOCOpt-inmarkdown.features.headingMarkerTocboolean | { heading?: string; maxDepth?: number }省略または false で off。
GitHub アラートOpt-inmarkdown.features.githubAlertsboolean | {}省略または false で off。
読了時間Opt-inmarkdown.features.readingTimeboolean | { wpm?: number }省略または false で off。export const readingTimeMinutes を出力。
コードブロックのエンリッチメントOpt-inmarkdown.features.codeEnrichment{ diffMarkers?: boolean; lineHighlight?: boolean; wordHighlight?: boolean }省略時は off。object form で有効化され、すべての subfeature はデフォルトで on。
コードタブOpt-inmarkdown.features.codeTabsboolean | {}省略または false で off。
ルビ注釈Opt-inmarkdown.features.rubyboolean | {}省略または false で off。
TOC エクスポートOpt-inmarkdown.features.tocExport{ maxDepth?: number }省略時は off。デフォルト maxDepth3
画像サイズOpt-inmarkdown.features.imageDimensions{ skipRemote?: boolean }省略時は off。skipRemote のデフォルトは true
リンク検証Opt-inmarkdown.features.linkValidation{ failOnBroken?: boolean }省略時は off。デフォルトは警告、failOnBroken: true でエラー。
トランスクルージョンOpt-inmarkdown.features.transclude{ maxDepth?: number }省略時は off。デフォルト maxDepth5

関連項目

Revision History

作成更新