From 1ed736b9bb4838428b164c159f237c67fe72f923 Mon Sep 17 00:00:00 2001 From: Joy Payton Date: Mon, 19 Mar 2018 09:07:58 -0400 Subject: [PATCH] Before stripping html, add whitespace for excerpts When excerpts contain html that has implied whitespace (like a

header followed by a

, but with no spaces in the text), add some whitespace *before* stripping the html, so that we see "Header paragraph" instead of "Headerparagraph" in the excerpt. --- assets/js/search-data.json | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/assets/js/search-data.json b/assets/js/search-data.json index 9e87ff41fda..c336184fa59 100644 --- a/assets/js/search-data.json +++ b/assets/js/search-data.json @@ -13,10 +13,26 @@ var store = [ { "title": {{ doc.title | jsonify }}, "excerpt": - {%- if site.search_full_content == true -%} - {{ doc.content | strip_html | strip_newlines | jsonify }}, + {%- if site.search_full_content == true -%} + {{ doc.content | + replace:"

", " " | + replace:"

", " " | + replace:"", " " | + replace:"", " " | + replace:"", " " | + replace:"", " " | + replace:"", " "| + strip_html | strip_newlines | jsonify }}, {%- else -%} - {{ doc.content | strip_html | strip_newlines | truncatewords: 50 | jsonify }}, + {{ doc.content | + replace:"

", " " | + replace:"", " " | + replace:"", " " | + replace:"", " " | + replace:"", " " | + replace:"", " " | + replace:"", " "| + strip_html | strip_newlines | truncatewords: 50 | jsonify }}, {%- endif -%} "categories": {{ doc.categories | jsonify }}, "tags": {{ doc.tags | jsonify }},