From 9a4ea76957f2ffad6b969606ea828ddf927c15f8 Mon Sep 17 00:00:00 2001 From: EricFromCanada Date: Tue, 15 Jan 2019 21:19:37 -0500 Subject: [PATCH] Improve search content generator --- assets/js/search-data.json | 2 +- docs/search.md | 2 +- lib/tasks/search.rake | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/js/search-data.json b/assets/js/search-data.json index e78d186..5dffa7b 100644 --- a/assets/js/search-data.json +++ b/assets/js/search-data.json @@ -4,7 +4,7 @@ {% for page in site.html_pages %}{% if page.search_exclude != true %}"{{ forloop.index0 }}": { "id": "{{ forloop.index0 }}", "title": "{{ page.title | xml_escape }}", - "content": "{{ page.content | newline_to_br | replace: '
', ' ' | replace: '', ' ' | strip_newlines | markdownify | strip_html | remove: 'Table of contents' | xml_excape | escape | replace: '\', ' ' | replace: '```', '' | replace: ' ', ' ' | replace: ' ', ' ' | remove: '---' | remove: '#####' | remove: '####' | remove: '###' | remove: '##' | strip_newlines }}", + "content": "{{ page.content | markdownify | strip_html | escape_once | remove: 'Table of contents' | remove: '```' | remove: '---' | replace: '\', ' ' | normalize_whitespace }}", "url": "{{ page.url | absolute_url | xml_escape }}", "relUrl": "{{ page.url | xml_escape }}" }{% unless forloop.last %},{% endunless %} diff --git a/docs/search.md b/docs/search.md index 33a9555..7584c8b 100644 --- a/docs/search.md +++ b/docs/search.md @@ -40,7 +40,7 @@ This command creates the `search-data.json` file that Jekyll uses to create your {% for page in site.html_pages %}{% if page.search_exclude != true %}"{{ forloop.index0 }}": { "id": "{{ forloop.index0 }}", "title": "{{ page.title | xml_escape }}", - "content": "{{ page.content | markdownify | strip_html | xml_escape | remove: 'Table of contents' | remove: page.title | strip_newlines | replace: '\', ' '}}", + "content": "{{ page.content | markdownify | strip_html | escape_once | remove: 'Table of contents' | remove: '```' | remove: '---' | replace: '\', ' ' | normalize_whitespace }}", "url": "{{ page.url | absolute_url | xml_escape }}", "relUrl": "{{ page.url | xml_escape }}" }{% unless forloop.last %},{% endunless %} diff --git a/lib/tasks/search.rake b/lib/tasks/search.rake index bcb01db..d91462d 100644 --- a/lib/tasks/search.rake +++ b/lib/tasks/search.rake @@ -4,7 +4,7 @@ namespace :search do puts 'Creating search data json file...' mkdir_p 'assets/js' touch 'assets/js/search-data.json' - content = %Q[{{ page.content | markdownify | strip_html | xml_escape | remove: 'Table of contents' | strip_newlines | replace: '\\', ' ' }}] + content = %Q[{{ page.content | markdownify | strip_html | escape_once | remove: 'Table of contents' | remove: '```' | remove: '---' | replace: '\\', ' ' | normalize_whitespace }}] puts 'Done.' puts 'Generating content...'