Hi.
This is not a direct answer to your question because I don’t know the limitations in working with markdown syntax inside html… I just know, by experience, that md syntax works inside a <span> tag.
But this is a suggestion: why not working with “Fold heading” or “Fold indent”? (Settings > Editor). With this you don’t need any html code, just .md syntax.