From 28c33e98010d85f8a25e3d9101dfa38bbbf472d0 Mon Sep 17 00:00:00 2001 From: Michael Rose Date: Tue, 20 Mar 2018 11:48:30 -0400 Subject: [PATCH] Fix search excerpts that run together --- CHANGELOG.md | 1 + assets/js/lunr/lunr-store.js | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index badb68a..2843885 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ ### Bug Fixes * Replace `absolute_url` filter with `relative_url` where it makes sense (asset/nagivation related paths). [#1588](https://github.com/mmistakes/minimal-mistakes/issues/1588) +* Fix search excerpts that run together because of implied spaces. ## [4.10.1](https://github.com/mmistakes/minimal-mistakes/releases/tag/4.10.1) diff --git a/assets/js/lunr/lunr-store.js b/assets/js/lunr/lunr-store.js index 96bdaa1..434b599 100644 --- a/assets/js/lunr/lunr-store.js +++ b/assets/js/lunr/lunr-store.js @@ -18,9 +18,25 @@ var store = [ "title": {{ doc.title | jsonify }}, "excerpt": {%- if site.search_full_content == true -%} - {{ doc.content | strip_html | strip_newlines | jsonify }}, + {{ 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 }}, -- 2.45.2