Markdown class and id attributes for a blockquote
I wanted to use a <blockquote> to indicate a callout within my Markdown articles so I hacked the Markdown Extra _DoBlockQuotes_callback() function to the following:
function _DoBlockQuotes_callback($matches) {
...cut...
//add id and class details...
$id = $class = '';
if(preg_match_all(
'/\{(?:([#.][-_:a-zA-Z0-9 ]+)+)\}/',
$bq,$matches)) {
foreach ($matches[1] as $match) {
if($match[0]=='#') $type = 'id';
else $type = 'class';
${$type} = ' '.$type.'="'.trim($match,'.# ').'"';
}
foreach ($matches[0] as $match) {
$bq = str_replace($match,'',$bq);
}
}
return _HashBlock(
"<blockquote{$id}{$class}>\n$bq\n</blockquote>"
) . "\n\n";
}
this allows me to do
>{.className}{#id}This is the blockquote
and it will generate
<blockquote id="id" class="className">
<p>This is the blockquote</p>
</blockquote>
This way the RSS feed will still show it as a quote but I can make the quote look a little sexier my site.
0 Comments »
No comments yet.
RSS feed for comments on this post. | TrackBack URI



