时间:2021-07-01 10:21:17 帮助过:18人阅读
那么输出的时候,在遇到时终止输出,只输出摘要。
使用Python Markdown保存了用户原始输入数据,那么这个应该怎么融入进去,同时输出时遇到这个标记时终止,只输出摘要。
希望有人能跟我讲解下这个原理是怎么实现的?需要用到哪些函数方法?
那么输出的时候,在遇到时终止输出,只输出摘要。
使用Python Markdown保存了用户原始输入数据,那么这个应该怎么融入进去,同时输出时遇到这个标记时终止,只输出摘要。
希望有人能跟我讲解下这个原理是怎么实现的?需要用到哪些函数方法?
来,给你看下wordpress恶心的代码
function get_extended($post) {
//Match the new style more links
if ( preg_match('//', $post, $matches) ) {
list($main, $extended) = explode($matches[0], $post, 2);
$more_text = $matches[1];
} else {
$main = $post;
$extended = '';
$more_text = '';
}
// Strip leading and trailing whitespace
$main = preg_replace('/^[\s]*(.*)[\s]*$/', '\\1', $main);
$extended = preg_replace('/^[\s]*(.*)[\s]*$/', '\\1', $extended);
$more_text = preg_replace('/^[\s]*(.*)[\s]*$/', '\\1', $more_text);
return array( 'main' => $main, 'extended' => $extended, 'more_text' => $more_text );
}
wordpress的code @kankana已贴,那么补充一些实现方式
javascript版本
'正文内容截断更多内容'.split('')[0];返回 '正文内容'
php
$errrr=explode('','正文内容截断更多内容');
echo $errrr[0]输出 '正文内容'
lz是想用jekyll么,可以试试postmore.rb这个plugin,创建一个Liquid过滤器过滤掉不需要现实的内容,详情请猛戳 https://github.com/tokkonopapa/jekyll... 。