You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Crozzers edited this page May 4, 2026
·
6 revisions
markdown-in-html extra
The markdown-in-html extra allows for the use of the markdown="1" attribute in a block HTML tag, to have markdown processing be done on its contents. It is similar to the PHP Markdown-Attr Extra but with some limitations.
From version 2.4.13, putting Markdown syntax on the same line as the block-level HTML is supported. Prior to this, the HTML tags had to be on separate lines to the Markdown for this to work.
API Usage
importmarkdown2markdown2.markdown('<span markdown="1">_some text_</span>', extras=['markdown-in-html']) # <span><em>some text</em></span># can also use the shorter boolean attribute syntaxmarkdown2.markdown('<span markdown>_some text_</span>', extras=['markdown-in-html']) # <span><em>some text</em></span>
command-line usage
$ cat foo.txt
<div markdown='1'>
This is a **bold statement**.
</div>
$ markdown2 -x markdown-in-html foo.txt
<div>
<p>This is a <strong>bold statement</strong>.</p>
</div>