Closed eddiezab closed 2 years ago
I don't think the parser allows for accurate line tracking in any real way. On top of that, Python Markdown is file agnostic. It mainly operates on buffers not files. You can certainly use it from the command line and give it a file, but that just extracts the content and runs the buffer through the API, the API doesn't care about where the buffer came from.
This is absolutely not possible. In addition to the issues mentioned by @facelessuser, there are the preprocessors, which remove various types of content (such as link references) from the buffer before passing it to the block parser. Therefore, by the time the block parser receives the buffer, the lines would not match the lines from the source file. Finally, the block parser steps through the lines by popping them off the top until the buffer is empty. Therefore, as far as the parser is concerned, it is always operating on line 1.
In short, tracking the source lines was never a concern when the parser was designed. Therefore, it would be impossible to add support without completely replacing the parser with a different one.
I'm looking to understand if there is a current option or approach for referencing back to the source markdown from the output HTML.
For example something like:
might render out to something like this: