You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Current solution is to parse markdown to the simplest HTML, then re-parse that with the standard Go HTML parser into an html.Node that can then be passed into xpath.QueryAll() or something similar. This feels really clunky, and I'm trying to find a better way.
Is there a suggested way to make this work that doesn't involve re-coping or re-parsing the document?
I'm experimenting with forking and refactoring goldmark ast to parse into html.Nodes instead, but my initial approach of "just replace everywhere BaseNode is mentioned with html.Node" is going much slower then expected and is producing more bugs than solving.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm trying create a tool for markdown query like
jq
for JSON files.Specifically, given an XPath-like query string, match the selected nodes in the markdown document.
Libraries like https://github.com/antchfx/xpath and https://github.com/andybalholm/cascadia take an
html.Node
to perform the match, but goldmark uses theast.Node
interface that is very similar but in no way directly compatible.Current solution is to parse markdown to the simplest HTML, then re-parse that with the standard Go HTML parser into an
html.Node
that can then be passed into xpath.QueryAll() or something similar. This feels really clunky, and I'm trying to find a better way.Is there a suggested way to make this work that doesn't involve re-coping or re-parsing the document?
I'm experimenting with forking and refactoring goldmark
ast
to parse intohtml.Node
s instead, but my initial approach of "just replace everywhere BaseNode is mentioned with html.Node" is going much slower then expected and is producing more bugs than solving.Thanks!
Beta Was this translation helpful? Give feedback.
All reactions