gomarkdown / markdown

markdown parser and HTML renderer for Go
Other
1.36k stars 171 forks source link

How would you find the text from *ast.Link? #270

Closed chelnak closed 1 year ago

chelnak commented 1 year ago

Hey!

I'm writing a custom parser with your library but cannot work out how to get the text part of a link.

[some description](https://mylink.com)
 ^^^^^^^^^^^^^

I originally thought it would be the title property of *ast.Link but after some research realised that was incorrect.

Any pointers would be much appreciated!!

miekg commented 1 year ago

[ Quoting @.***> in "[gomarkdown/markdown] How would you..." ]

Hey!

I'm writing a custom parser with your library but cannot work out how to get the text part of a link.

some description ^^^^^^^^^^^^^

I originally thought it would be the title property of *ast.Link but after some research realised that was incorrect.

Any pointers would be much appreciated!!

ast.Link contains a Container, in there the you find the nodes that make up the link text.

chelnak commented 1 year ago

Thanks. I'll take a look at this now.

chelnak commented 1 year ago

Thank you sir! Iterating over the children of ast.Link was the way to go. 😄