Your sites Log in Sign up Menu

A way to ignore markdown processing

Is there a way to flag a section of markdown to not be processed by blot? For example, let's I wanted to include a section of pure HTML inside the markdown, so it might look like this:

regular markdown
<div class="do-not-process">
    Line
</div>
more regular markdown

As it is currently, blot will process the following and spit out:

<p>regular markdown</p>
<div class="do-not-process">
    <p>Line</p>
</div>
<p>more regular markdown</p>

The extra <p> inside the div is causing problems for the mermaid diagram tool. It looks for a div with the class of mermaid, and inside that div does not expect any <p> tags. When it encounters them, it throws a syntax error.

A workaround right now is uploading pages as HTML files but that isn't a desired workflow. Thanks!


2 years ago, 1 replies   Improve this question

Off the top of my head, I can't think of a way to disable the markdown processor in the middle of a markdown file.

One hack would be something like this:

regular markdown

<pre class="do-not-process">
    Line
    Line
</pre>

more markdown...

<pre class="do-not-process">
    Line
</pre>

and then finally, at the end of your post, a script to swap the <pre>s for <div>s:

<script type="text/javascript">
document.querySelectorAll('.do-not-process').forEach(function(node){
var d = document.createElement('div');
d.innerHTML = node.innerHTML;
node.parentNode.replaceChild(d, node);
});
</script>
Answered 2 years ago · Improve this answer