ÅA¡ñÍHTML5ÅoÍ·éí¯¾¯ÇAÀÛÌǤᤩïÌIÈR[hÅ©ÄÝéBá¦Î�}ñÈ�L��ÌmarkdownÌeLXgª Á½Æ·éÆ
# 1
ÈÉ©
## 1.1
hoge
## 1.2
fuga
> øpÆ©
# 2
## 2.1
### 2.1.1
HTML4(default)ÅÍ�}ñÈ�L��ÅoͳêéB
<h1>1</h1>
<h2>1.1</h2>
<p>hoge</p>
<h2>1.2</h2>
<p>fuga</p>
<blockquote><p>øpÆ©</p></blockquote>
<h1>2</h1>
<h2>2.1</h2>
<h3>2.1.1</h3>
HTML5¾Æ�}ñÈ�L��B
<section>
<h1>1</h1>
<section>
<h1>1.1</h1>
<p>hoge</p>
</section>
<section>
<h1>1.2</h1>
<p>fuga</p>
<blockquote>
<p>øpÆ©</p>
</blockquote>
</section>
</section>
<section>
<h1>2</h1>
<section>
<h1>2.1</h1>
<section>
<h1>2.1.1</h1>
</section>
</section>
</section>
�}Ìæ¤ÉHTML5Å}[NAbv·éêÍesection²ÆÉh1ðg¦éBá¦ÎuOÌLÌ^Cg¾¯ÊÌtH[ÅüêÄA{��ÍmarkdownÅæ¤Èê¾ÆAí�Lí�L#Ìð²®¹¸Ég¦éÌÅÖ¾µAã©ç�}¤µ½©Á½[ÁÄ��¤Æ«àh1µ©gÁÄ��È��ÌÅC³ày©Æv¤BcssÍ¿åÁƾ¯Ê|©ÈHÅàA¡ÍsassÆ© é©ç½C¾æI½ªI
\[XR[h:https://gist.github.com/2879128
markdown.toHTML5 = function(source, dialect, options) {
return markdown.renderJsonML((function to5(tree, level) {
var i, m,
indices = [],
hx = 'h' + level,
n = tree.length,
blocks = [];
if(!n) return [];
function set(start, end) {
blocks.push(['section', ['h1', tree[start][1]]].concat(to5(tree.slice(start + 1, end), level + 1)));
}
for(i = 0; i < n && hx !== tree[i][0]; ++i) blocks.push(tree[i]);
for(i = 0; i < n; ++i) if(hx === tree[i][0]) indices.push(i);
for(i = 0, m = indices.length - 1; i < m; ++i) set(indices[i], indices[i + 1]);
if(indices.length) set(indices[m], n);
return blocks;
})(markdown.toHTMLTree(source, dialect, options), 1));
};