Feature request: support YAML front matter
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 45/100
調査の方向性
nextjournal.markdown/parse のエントリーポイントから始め、commonmark-java をどのように設定しているかを調べます。YamlFrontMatterExtension と YamlFrontMatterVisitor の参照を確認し、front matter を除外するのか、メタデータとして公開するのかを判断します。サンプルが front matter を通常の Markdown として解析しなくなり、選択した動作によって実際の見出しとメタデータが保持されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Summary
YAML front matter (delimited by ---) is widely used in static site generators (Hugo, Jekyll, etc.) and documentation tools. Currently, nextjournal/markdown parses front matter as regular markdown content, producing incorrect results.
Current behavior
(require '[nextjournal.markdown :as md])
(md/parse "---
title: My Post
date: 2024-01-01
---
## Actual Heading")
Produces:
- A
:rulernode (from the opening---) - An h2 heading with text "title: My Post" (incorrectly parsed as markdown heading)
- A paragraph with "date: 2024-01-01"
- Another
:rulernode (from the closing---) - The actual h2 heading
Expected behavior
Front matter should be:
- Recognized and excluded from markdown parsing, OR
- Parsed and included as a separate
:front-matternode with the YAML content
Example of option 2:
{:type :doc
:front-matter {:title "My Post" :date "2024-01-01"}
:content [{:type :heading :heading-level 2 :content [...]}]}
Workaround
Users currently need to strip front matter before calling parse, which is error-prone and loses the metadata.
Implementation note
The underlying commonmark-java library already has a YamlFrontMatterExtension in the commonmark-ext-yaml-front-matter artifact with YamlFrontMatterVisitor for extracting metadata. Using this extension at the commonmark-java level (rather than preprocessing the string) would have the advantage that other features like source line numbers (#64) would work correctly for free, since the parser would know where the actual content starts.
References:
- 主要言語
- Clojure
- スター
- 100
- フォーク
- 11
- 平均マージ
- 2時間 3分
- マージ済み PR(30日)
- 2
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
nextjournal/markdown のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
nextjournal/markdown#77 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 87/100
nextjournal/markdown#76 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
nextjournal/markdown#64 · コメント 7 件 · リアクション 1 件 ·
nextjournal/markdown の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
nextjournal/clerk#830 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
IOP tokens release blocker team qa team qa autotests WG adoption
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
penpot/penpot#13540 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
izhangzhihao/intellij-rainbow-brackets#2903 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100