diff --git a/assets/js/search-data.json b/assets/js/search-data.json
index e78d186032d66e09491fafcf559d572b0cdeb884..5dffa7bd86340c30e4b5ce93b749d7f63729dec7 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: '<br />', ' ' | replace: '</h1>', ' ' | 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 33a9555d897b524c6f9964a3a39525744cd7dbe8..7584c8bfd39314417bf2f3d7cce2f590a7db5072 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 bcb01db59ea8e3387e229cce71732c22419ff507..d91462d22747b74c2079d55b0e666a39c9b61578 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...'