Inside page EmbedReference
in Logseq, put the following code in a javascript code-block:logseq.kits.setStatic(function embedreference(span){
const blockId = span.closest(".ls-block").getAttribute("blockid")
const content = logseq.api.get_block(blockId).content
const macroStart = content.indexOf("{{" + span.closest(".macro").dataset.macroName)
const macroEnd = content.indexOf("}}", macroStart) + 2
const tagname = span.dataset.name
logseq.api.append_block_in_page(tagname, "{{embed ((" + blockId + "))}}")
logseq.api.update_block(blockId, content.slice(0, macroStart) + "#" + tagname + content.slice(macroEnd))
});