How could I mix Markdown and HTML together?

Hi, can I mix Markdown and HTML together?
For a example:
I want such source

<div id="__block_01">

# First title
## Second title
> quotes


renders as

<div id="__block_01">
    <h1>First title</h1>
    <h2>Second title</h2>

but it actually comes like this

<div id=__block_01>

# First title
## Second title
> quotes


The markdown in HTML block didn’t been rendered.It is provided as is.
I want Markdown and HTML can mix together.

Some system information

> caddy -version
Caddy 0.10.3
> uname -a
Linux ubuntu 4.12.0-041200rc2-lowlatency #201705212331 SMP PREEMPT Mon May 22 03:38:18 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
> lsb_release -ds
Ubuntu 17.04

Sorry for my bad English. :wink:

You may want to read the CommonMark specification.

Specifically, that <div> is an HTML block:

An HTML block is a group of lines that is treated as raw HTML (and will not be escaped in HTML output).

Simply put, the Markdown content inside that <div> tag will be treated as raw HTML. The only solution is to modify your site so that HTML blocks are not employed, or convert that specific section to HTML tags (defeating the point of using Markdown).

Thank you for your help. In the link your posted I found a example exactly what I need:Example 133
It says that if the HTML tag ends with the following blank line, the contents get interpreted as CommonMark.
Seems good.This is my example in first post.That’s what I want.
But when I modify my site like this. It still cant’ work as I expect.
You can simply try to let caddy render a markdown file with the content I just provided. The you can find the difference.

Maybe I should @matt ? Could you please tell me why and how to solve it?

You’ll have to use only HTML within HTML tags, as Caddy doesn’t support the CommonMark spec. The upstream markdown library doesn’t support it (yet).

Thank you for your reply. Maybe I should make an issue to the upstream markdown library.
Hoping this feature can be used.

Seems caddy is using blackfriday as its markdown processor. Maybe I should make an issue there.

After looking through the source code of caddy and its markdown processor blackfriday. I find blackfriday actually support CommonMark spec or something like. At the bottom of this page I find the thing exactly what I want. But after I tested caddy 0.10.3, it still can’t work. I think you can change the call at there to blackfriday.MarkdownCommon() may work. @matt

I think this will be changing when v2 of BlackFriday comes out.

OK, I will wait. Thank you for your reply.
Maybe you can use import "".

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.