AFAIK strip_html
をカスタマイズする組み込みの方法はありません。
あなたが排他持っている場合は - そう長くはない - あなたの指名手配タグのリストを、あなたはまず、非HTMLのマーカーに置き換えて再びstrip_html
、およびreplace
を使用するために保存しておきたいタグのreplace
を使用することができますhtmlを取得するには:
{% assign preprocessed_content=post.content | replace: '<p>', '__p__' %}
{% assign preprocessed_content=preprocessed_content | replace: '</p>', '__/p__' %}
{% assign truncated_content=preprocessed_content | strip_html | truncatewords:50 %}
{% assign cleaned_content=truncated_content | replace: '__p__', '<p>' %}
{% assign cleaned_content=cleaned_content | replace: '__/p__', '</p>' %}
<p>{{ cleaned_content }}</p>
ありがとう、私はこれを試してみます。 –