HTMLコードを埋め込む

markdown-html.png

PHP Markdown Extraでは効かないけど、ただのマークダウンなら効くかんじ。
HTMLコードを埋め込むには、頭とおしりに1行開けなければならない。
そして<div>などのタグの最初と最後</div>には余分なスペースやタブがあってはならない。

These restrictions have been lifted in PHP Markdown Extra, and replaced by these less restrictive two:

  • 空白3つ分以上インデントしてはならない。

もし3個以上インデントしてたらコードブロックとみなされる。

When the block element is found inside a list,
all its content should be indented with the same amount of space as the list item is indented.
(More indentation won’t do any harm as long as the first opening tag is not indented too much and then become a code block — see first rule.)

Markdown Inside HTML Blocks

Previously in Markdown, you couldn’t wrap Markdown-formatted content inside a <div> element. This is because <div> is a block element and plain Markdown does not format the content of such.

PHP Markdown Extra gives you a way to put Markdown-formatted text inside any block-level tag. You do this by adding a markdown attribute to the tag with the value 1 — which gives markdown="1" — like this:

<div markdown="1">
This is *true* markdown text.
</div>

The markdown="1" attribute will be stripped and <div>’s content will be converted from Markdown to HTML. The end result will look like this:

<div>
<p>This is <em>true</em> markdown text.</p>
</div>

PHP Markdown Extra is smart enough to apply the correct formatting depending on the block element you put the markdown attribute on.
If you apply the markdown attribute to a <p> tag for instance, it will only produce span-level elements inside — it won’t allow lists, blockquotes, code blocks.

But these are some cases where this is ambiguous, like this one for instance:

<table>
<tr>
<td markdown="1">This is *true* markdown text.</td>
</tr>
</table>

A table cell can contain both span and block elements. In cases like this one, PHP Markdown Extra will only apply span-level rules. If you wish to enable block constructs, simply write markdown="block" instead.
Bibliography

サポートサイト Wikidot.com