Markdown記法でのStyle要素の扱い

ウェブログを運営している人で、Markdown記法を利用している人は多いと思います。私もWordPressでプラグインを入れて、この記法を利用してます。マークアップする手間が省けてとても重宝してます。

ただ、エントリーでその場限りのスタイルシートを適用したい時に、インラインで書くにはプロパティが多すぎて見渡しにくかったりスタイルを適用できないなどがあってエントリー中にstyle要素をたまに使うことがあるのですが、style要素をブロック要素と認識できなくてp要素で括られることになってしまいます。

<p><style type="text/css">
<!--
    style {}
    -->
</style></p>

そこで、p要素で括られないようにプラグインをカスタマイズしてみました。

# Tags that are always treated as block tags:
var $block_tags_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|form|fieldset|iframe|hr|legend|style';

1748行目の$block_tags_reに「style」を書き加えたところ、p要素で括られることがなくなりました。

This entry was posted in HTML/CSS, Web, WordPress and tagged , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">