Search code examples
htmlmarkdownrendermathjaxkatex

How to render markdown language in html blocks?


Background: In markdown files, I want to generate some more complex elements, such as this question I posted yesterday. So I am tried to do that by using original html/css.

Problem: But then I notice the markdown language won't be rendered in the html blocks.

My environment setting is:

  • Editor: Atom
  • Markdown Preview/Export: Markdown Preview Enhanced
  • Math render: Katex

Then, I will show examples of markdown language not applied for html.

Math

Input:

<h4>$(\Omega, \mathcal{F}, \mathbb{P})$</h4>

$(\Omega, \mathcal{F}, \mathbb{P})$

The result is:

You can see that the same equation in under the html block is not rendered.

Reference

Input:

<div>
> ABCDEFC
> ABCDEFC
> > ABCDEFC
> ABCDEFC
</div>

> ABCDEFC
> ABCDEFC
> > ABCDEFC
> ABCDEFC

The result is:

Still, the markdown is not rendered.

Question

So, how to render this math equation in html block in Markdown?


Solution

  • This problem is actually very simple, this answer is written for anyone may have similar problem.

    Normally HTML blocks end with a blank line. So the solution for this problem is to add a blank line between HTML and Markdown.

    For instance, in the first example, instead of have

    <h4>$(\Omega, \mathcal{F}, \mathbb{P})$</h4>
    

    write

    <h4>
    
    $(\Omega, \mathcal{F}, \mathbb{P})$
    
    </h4>
    

    and everything will go right.

    Similarly, instead of writing

    <div>
    > ABCDEFC
    > ABCDEFC
    > > ABCDEFC
    > ABCDEFC
    </div>
    

    we should write

    <div>
    
    > ABCDEFC
    > ABCDEFC
    > > ABCDEFC
    > ABCDEFC
    
    </div>
    

    I have been overthinking. Hope this solution can help people with similar problem.