Using content blocks would really simplify things.
Here’s a link with the initial announcement of that specification, which were introduced in iA Writer 4 some time ago.
github.com/iainc/Markdown-Content-Blocks
The major distinction is between “online” and “local” embeddings (and I’d guess that what makes more sense here are “online” embeddings).