I've been working on something somewhat similar for producing legal documents, called Linked Markdown (https://linked.md). So the section about modules/importing and dynamic references really rang a bell. Very cool stuff, will keep track of progress.