Replies: 2 comments 1 reply
-
What a timely discussion, I encountered the same problem today! For an additional use case, I wanted to locate a particular section of a Markdown document before extracting it from the original source (no AST modification). But I couldn't find a reliable way to get the node indices ( Apart from this, I really enjoyed working with this well-crafted library 👍 |
Beta Was this translation helpful? Give feedback.
-
@yuin would you be interested in a PR that attempts to implement this functionality? I'm trying to implement a basic markdown modification interface and this would make it much more feasible. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I was disappointed to see that the parser drops most of the source position information - it only seems to be preserving positional information for text nodes. I would have expected e.g.
ast.Link
to have atext.Segment
field withStart
pointing at the[
andStop
pointing at the)
. These would be nested, so theSegment
of a child node would alwaysStart
andStop
inside theSegment
(just as, for example, theLink
has a childText
node, which already points at the text in-between the[]
). i.e. all of this would work very similar to howgo/ast.Node.{Pos,End}
behaves.Note, in particular, that this should make it trivial to implement #119, preserving the original markdown source. And personally, I want to be able to refer back and forth between HTML elements and the markdown that created them - I thought I would just need a custom
Renderer
that adds the relevant information todata
attributes (which is already significant work). But without source positions, even that is futile.In short: I think it would be great, if this information was preserved and reflected in
ast.Node
:)Beta Was this translation helpful? Give feedback.
All reactions