事实证明,此法不可行,文章内部的回车都被过滤了,所以放弃,增加自行的阅读更多方式,点击展开。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php if (!($this->is('page') || $this->is('post'))): ?>
<script>
  $('.post-content').each(function(){
      if($(this).height() >= 300) {
      var thiz = $(this);
          thiz.addClass('zhedie').parent().append('<div class="read-more"><?php _e('-- 展开剩余部分 --'); ?></div>');
      thiz.find('img').click(function(){
        thiz.removeClass('zhedie');
        thiz.parent().find('.read-more').hide();
      });
 
      };
  });
  $('.read-more').on('click',function(){
    $(this).parent().find('.post-content').removeClass("zhedie");
    $(this).hide();
  });
</script>
<?php endif; ?>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
.zhedie {
    overflow:hidden;
    height: 300px;
}
.read-more {
    background: linear-gradient(-180deg,rgba(255,255,255,0) 0%,#fff 70%);
    position: relative;
    z-index: 1;
    padding-top: 100px;
    margin-top: -100px;
    cursor: pointer;
    text-align:center;
    color:#aaa;
}

使用typecho搭建了一个站点,输出摘要时候。使用了<!-- more -->分隔符,然后首页文章出现了一大片空白,审查元素发现。多了好多<br>标签

解决办法:
/var/hyperDown.php文件1177行。把这一行注释。即可

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/**
 * parseNormal
 *
 * @param array $lines
 * @return string
 */
private function parseNormal(array $lines)
{
    foreach ($lines as &$line) {
        $line = $this->parseInline($line);
    }
 
    $str = trim(implode("\n", $lines));
    $str = preg_replace("/(\n\s*){2,}/", "</p><p>", $str);
    $str = preg_replace("/\n/", "<br>", $str);
 
    return preg_match("/^\s*$/", $str) ? '' : "<p>{$str}</p>";
}

$str = preg_replace("/\n/", "<br>", $str);

2021.04.28再一次事实证明

技术改进是可以改变世界的。这个问题已经在开发版里解决了,所以我更新了开发版。