Feature request: preserve source line numbers in AST nodes
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 42/100
Research direction
Start at the md/parse entry point and trace how the underlying commonmark-java parser's SourceSpans are handled, since the issue says this information is currently discarded. Determine how source positions should be represented on AST nodes, then verify that parsed nodes expose line information usable by linting tools.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Clojure
- Stars
- 100
- Forks
- 11
- Avg merge
- 2h 3m
- Merged PRs (30d)
- 2
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nextjournal/markdown
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
nextjournal/markdown#77 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 87/100
nextjournal/markdown#76 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
nextjournal/markdown#65 · 6 comments ·
All issues in nextjournal/markdown
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
nextjournal/clerk#830 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
IOP tokens release blocker team qa team qa autotests WG adoption
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
penpot/penpot#13540 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
izhangzhihao/intellij-rainbow-brackets#2903 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100