我可以使用Markdown在段落上定义类名吗? [英] Can I define a class name on paragraph using Markdown?
本文介绍了我可以使用Markdown在段落上定义类名吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以使用Markdown在段落上定义类名吗?如果是,如何?
Can I define a class name on paragraph using Markdown? If so, how?
推荐答案
Dupe: How do I set an HTML class attribute in Markdown?
不,Markdown的语法不能。您可以使用Markdown Extra通过设置ID值。
No, Markdown's syntax can't. You can set ID values with Markdown Extra through.
您可以使用常规HTML < a>如果您愿意,并添加属性 markdown =1
,以在HTML元素中继续降价转换。这需要 Markdown Extra 。
<p class='specialParagraph' markdown='1'>
**Another paragraph** which allows *Markdown* within it.
</p>
可能的解决方案:(未经测试且适用于< blockquote>
)
我在网上找到了以下内容:
Possible Solution: (Untested and intended for <blockquote>
)
I found the following online:
/ p>
Function
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";
}
Markdown
>{.className}{#id}This is the blockquote
结果
<blockquote id="id" class="className">
<p>This is the blockquote</p>
</blockquote>
这篇关于我可以使用Markdown在段落上定义类名吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文