Feature request: preserve source line numbers in AST nodes

オープン
#64 コメント 7 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
42/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
clojure, java
領域
tooling

調査の方向性

md/parse エントリポイントから開始し、基盤となる commonmark-java パーサーの SourceSpans がどのように扱われているかを追跡してください。issue では、この情報が現在破棄されていると述べられています。AST ノード上でソース位置をどのように表現すべきかを判断し、その後、パースされたノードが linting ツールで利用できる行情報を公開していることを確認してください。

索引モデルが issue の本文から書いたものです。

説明

Summary

It would be helpful if the parsed AST nodes included source line number information from the original markdown text.

Use case

When building linting tools that check markdown structure (e.g., heading hierarchy validation), error messages are much more useful when they can reference the specific line number:

Line 15: H1 not allowed in blog posts: 'Introduction'

vs just:

H1 not allowed in blog posts: 'Introduction'

Current behavior

The AST nodes only contain content, not source positions:

(require '[nextjournal.markdown :as md])
(md/parse "## Heading\n\nParagraph")
;; => {:content [{:type :heading, :heading-level 2, :content [...], :attrs {...}}
;;               {:type :paragraph, :content [...]}], ...}

Proposed behavior

Include source position information, perhaps as metadata or additional keys:

{:type :heading
 :heading-level 2
 :content [...]
 :attrs {...}
 :source {:line 1 :column 0}}  ;; or similar

Notes

The underlying commonmark-java parser does track source spans (SourceSpans), so this information is available during parsing but currently discarded.

主要言語
Clojure
スター
100
フォーク
11
平均マージ
2時間 3分
マージ済み PR(30日)
2

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

nextjournal/markdown のほかの issue

nextjournal/markdown の issue をすべて見る

似ている issue

Clojure の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。