Right, I've done it with the small example given.
It's three Search and replaces, Two on the orig markdown text file, then when converted to epub, a S&R done in Sigil
Also, the footnotes have to be seperated by blank lines, instead of on following lines as in example.
Open the original markdown txt file
Search
Replace
Code:
<sup>\1</sup><a id="fn\1" href="#fnr\1">\2<a>
Edit: replacing all occurences
Then
Search
Replace
Code:
\1<sup><a id="#fnr\2" href="#fn\2">\2</a></sup>
Edit: replacing all occurences
Save file, convert with calibre to epub, Using pagebreak in structure detection with default Xpath expression, so each story would the be in their own file.
Then open in Sigil,
Search
Code:
../Text/index_split_000.html
Replace with nothing.
Edit: replacing all occurences in CodeView, and replace in all files
Save, you should then have the correctly done file.