我想创建markdown样式反引号短代码...
...用<span class="inline_code"></span>
对替换反引号对,但没有找到如何在没有[]
符号且没有[/]
结束标记的情况下实现此目的。同样适用于**
到<strong></strong>
。
您能为这种短代码模式提供一些链接/示例吗?如果没有别的办法,我也很满意其他一些(非短码)解决方案。
答案 0 :(得分:2)
添加内容过滤器(至functions.php
或以下):
function add_markdown_tiny($content)
{
$patterns = array
(
'/`([^\*]+)`/',
'/\*\*([^\*]+)\*\*/'
);
$replacements = array
(
'<code>$1</code>',
'<strong>$1</strong>'
);
$replaced = preg_replace($patterns, $replacements, $content);
return $replaced;
}
add_filter( 'the_content', 'add_markdown_tiny', 10);