RobertDober / earmark_parser

The Markdown to AST part of Earmark.
Apache License 2.0
68 stars 26 forks source link

Include original line number in AST #42

Closed colinsmetz closed 3 years ago

colinsmetz commented 3 years ago

Hello,

I am trying to use EarmarkParser in order to do some analysis of Markdown files, like spellchecking and other checks. I am not interested in converting the AST to some other format, but instead I would like to be able to refer back to the original Markdown content.

For this reason I'd like to have the original line (and ideally column) for each part of the AST. I understand that the information is displayed when there are errors only. Would it be possible to have it in any case (with an option)?

I have checked the options, but it seems the line option is only an offset added to the line on errors, right?

colinsmetz commented 3 years ago

I looked at the code a bit, and EarmarkParser.Parser.parse_markdown is close enough to what I needed. Even though it's in a internal module, that'll be good for me now.