Convert entire vault into a single file using knowledge graph

I’d like to convert my an entire vault into a single .md file while respecting the structure of the knowledge graph.

Here’s how I would do it in theory:

  1. convert general knowledge graph into an acyclic graph (this requires some mild choices)
  2. recursively process the linked files by embedding generated text from a link in place of the string “[[link]]”

I imagine one could actually do this without obsidian at all, and just the system of .md files associated to a vault. But I like obsidian, a button to output work into something that can convert to a single pdf or latex file etc would prove useful for writing books or academic papers.

If this exists please let me know, and if not I would appreciate some advice to get started!

Thank you!