如何去除jekyll中的换行符?

问题描述:

我知道strip_newlines但它不这样做我想要的东西:如何去除jekyll中的换行符?

{% capture string %} 
Hello 
there 
{% endcapture %} 

{{ string | strip_newlines }} 

输出Hellothere,但我需要Hello there INSEAD。

替换不能工作,因为你不能把换行字符。

{{ string | replace: '\n', ' ' }} 

如何用空格替换所有换行符?例如用于元标记中。

这里是特技:

{% assign description = page.excerpt | newline_to_br | strip_newlines | replace: '<br />', ' ' | strip_html | strip | truncatewords: 30 %} 

<meta name="description" content="{{ description }}"> 

与BR代码替换换行符,然后剥去换行符,然后用空间替换<br />。剥离html并在元描述中截断使用。