我想创建 markdown 风格的反引号短代码...
...用 <span class="inline_code"></span>
替换反引号对一对,但没有找到如何在没有 []
的情况下实现这一点标志和没有[/]
结束标签。 **
也是如此至<strong></strong>
.
您能为这种短代码模式提供一些链接/示例吗?如果没有其他方法,我也对其他一些(非短代码)解决方案感到满意。
最佳答案
通过添加此类内容过滤器(到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);
关于wordpress - 在 WordPress 中创建 markdown 风格 `(反引号)短代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22028256/