Access parsed Markdown

I’m looking into a plugin that would let me copy some Markdown from the current note and transform it into Latex. The current Pandoc route seems set for whole documents more than fragments, and I’d like to write something very simple for pasting into Overleaf, but with a bit of control over how citations are handled.

Is it possible to make use of the existing Markdown parser within Obsidian? Is there a way to get an intermediate tree, or will it always work with a DOM?

2 Likes

To answer my own question, I looked at how the Kanban plugin does it, and they use mdast (Markdown Abstract Syntax Tree), specifically: mdast-util-from-markdown - npm

3 Likes

And a follow up - this works, but it doesn’t get everything. The GFM extensions help (GitHub - syntax-tree/mdast-util-gfm: mdast extension to parse and serialize GFM (GitHub Flavored Markdown)), but it still misses useful things like block labels and inline footnotes

3 Likes

There is also an extension to extract wiki links,

landakram/mdast-util-wiki-link: Extensions for mdast to support [[Wiki Links]].