From 5e60d2d3c5b6da5ddeb358940a988cb1fb2e1529 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 ++++++++++++++++++-- docs/_docs/18-history.md | 3 ++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index badb68ac..28438851 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 96bdaa11..434b5997 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 }}, diff --git a/docs/_docs/18-history.md b/docs/_docs/18-history.md index 64f13e0b..d8064727 100644 --- a/docs/_docs/18-history.md +++ b/docs/_docs/18-history.md @@ -4,7 +4,7 @@ permalink: /docs/history/ excerpt: "Change log of enhancements and bug fixes made to the theme." sidebar: nav: docs -last_modified_at: 2018-03-20T11:35:28-04:00 +last_modified_at: 2018-03-20T11:48:04-04:00 toc: true --- @@ -17,6 +17,7 @@ toc: true ### 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)