Obsidian Markdown Parser

Has there been discussion about or interest in surfacing an API to access the Obsidian underlying markdown parser? What I have in mind for my use case is something like:

const result = await plugin.app.workspace.parse("Hello *world*");
console.log(result);
/**
[
  { text: "Hello ", type: "text"},
  { text: "world", type: "italics"},
]
*/

Obviously, the actual schema of the result array could resemble what Obsidian actually uses under the hood.

Up to this point, I have been using the recommendations found in Format your notes - Obsidian Help, but there are several undocumented nuances that could cause issues. For example, unlike the common mark spec, the string **Hello actually results in Hello bolded instead of rendering that full line as text. For these cases, it would simplify our use case immensely to be able to access the output of the parser directly.

Happy to expand on more if needed!

2 Likes

Yes it would be nice from the developers to give access to the parser and the grammar ! Especially if they use a parser-generator because that would make it really easy.

1 Like