From 60c82cb518a25f43f7c5adbee2b81807115b779e Mon Sep 17 00:00:00 2001
From: EricFromCanada <enk3@outlook.com>
Date: Wed, 16 Jan 2019 00:31:30 -0500
Subject: [PATCH] Allow for ampersand in title or URL

Because `page.title` (and `page.url`) is already escaped and page titles served by lunrjs do not need escaping, ampersands need to be unescaped to display properly in search results.
---
 assets/js/search-data.json | 6 +++---
 docs/search.md             | 6 +++---
 lib/tasks/search.rake      | 6 +++---
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/assets/js/search-data.json b/assets/js/search-data.json
index 5dffa7bd..49cbc9dc 100644
--- a/assets/js/search-data.json
+++ b/assets/js/search-data.json
@@ -3,10 +3,10 @@
 {
   {% for page in site.html_pages %}{% if page.search_exclude != true %}"{{ forloop.index0 }}": {
     "id": "{{ forloop.index0 }}",
-    "title": "{{ page.title | xml_escape }}",
+    "title": "{{ page.title | replace: '&amp;', '&' }}",
     "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 }}"
+    "url": "{{ page.url | absolute_url }}",
+    "relUrl": "{{ page.url }}"
   }{% unless forloop.last %},{% endunless %}
   {% endif %}{% endfor %}
 }
diff --git a/docs/search.md b/docs/search.md
index 7584c8bf..134e3997 100644
--- a/docs/search.md
+++ b/docs/search.md
@@ -39,10 +39,10 @@ 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 }}",
+    "title": "{{ page.title | replace: '&amp;', '&' }}",
     "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 }}"
+    "url": "{{ page.url | absolute_url }}",
+    "relUrl": "{{ page.url }}"
   }{% unless forloop.last %},{% endunless %}
   {% endif %}{% endfor %}
 }{% endraw %}
diff --git a/lib/tasks/search.rake b/lib/tasks/search.rake
index d91462d2..50ef275c 100644
--- a/lib/tasks/search.rake
+++ b/lib/tasks/search.rake
@@ -14,10 +14,10 @@ namespace :search do
 {
   {% for page in site.html_pages %}{% if page.search_exclude != true %}"{{ forloop.index0 }}": {
     "id": "{{ forloop.index0 }}",
-    "title": "{{ page.title | xml_escape }}",
+    "title": "{{ page.title | replace: '&amp;', '&' }}",
     "content": "'+content+'",
-    "url": "{{ page.url | absolute_url | xml_escape }}",
-    "relUrl": "{{ page.url | xml_escape }}"
+    "url": "{{ page.url | absolute_url }}",
+    "relUrl": "{{ page.url }}"
   }{% unless forloop.last %},{% endunless %}
   {% endif %}{% endfor %}
 }'
-- 
GitLab