I use a javascript to convert markdown to html.
If I add <span id="printHello></span>
to the markdown, after conversion, I could still use getElementById()
to get the reference. However, there is one exception:
var abc = true;
<span id="printHello></span>
var def = false;
If the tag is added inside a code block, it will get escaped during the conversion. I can no longer get the element.
So I am thinking if I can add an identifier text, replacing the identifier text after the markdown has been converted to html. Like this:
var abc = true;
I_am_an_identifier
var def = false;
After converting, I get this:
<pre><code>var abc = true;
I_am_an_identifier
var def = false;
</code></pre>
So I can replace I_am_an_identifier
to <span id="printHello></span>
Is it possible to replace by means of contents?