Embarrassingly, a horrible little script for converting Pandoc's Markdown endnotes to inline format remains my most-starred GitHub repo: https://github.com/ltrgoddard/inliner/
If you are using markdown, you already understand the conceptual basis for it, so you just need to understand how it's implemented over there.
I'm not arguing that it is something you should do, just rolling my eyes at "I would be lost".