From 7615d72e9300a1514ef2fc8ec941ab2974ba7eb4 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Sat, 26 Jul 2025 20:22:30 +0800 Subject: [PATCH 1/2] fix: escape special JSON characters in search results (#2481) Also restore full-text search --- _includes/post-description.html | 37 +++++++++++++++++++-------------- assets/js/data/search.json | 7 ++----- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/_includes/post-description.html b/_includes/post-description.html index c00e516..48bb03b 100644 --- a/_includes/post-description.html +++ b/_includes/post-description.html @@ -2,24 +2,29 @@ Get post description or generate it from the post content. {%- endcomment -%} -{%- assign max_length = include.max_length | default: 200 -%} - {%- capture description -%} -{%- if post.description -%} - {{- post.description -}} -{%- else -%} - {% comment %} - Remove the line number of the code snippet. - {% endcomment %} - {% assign content = post.content %} + {%- if post.description -%} + {{- post.description -}} + {%- else -%} + {% comment %} + Remove the line number of the code snippet. + {% endcomment %} + {%- assign content = post.content -%} - {% if content contains '
' %}
- {% assign content = content | replace: '', '' %}
- {% endif %}
+ {%- if content contains ' ' -%}
+ {%- assign content = content | replace: '', '' -%}
+ {%- endif -%}
- {{- content | markdownify | strip_html | newline_to_br | replace: '
', ' ' | strip_newlines -}}
-{%- endif -%}
+ {{- content | strip_html | newline_to_br | replace: '
', ' ' | strip_newlines -}}
+ {%- endif -%}
{%- endcapture -%}
-{{- description | strip | truncate: max_length | escape -}}
+{%- if include.json -%}
+ {%- assign description = description | jsonify -%}
+{%- else -%}
+ {%- assign max_length = include.max_length | default: 200 -%}
+ {%- assign description = description | strip | truncate: max_length -%}
+{%- endif -%}
+
+{{- description -}}
diff --git a/assets/js/data/search.json b/assets/js/data/search.json
index 32bcff9..5003e51 100644
--- a/assets/js/data/search.json
+++ b/assets/js/data/search.json
@@ -5,16 +5,13 @@ swcache: true
[
{% for post in site.posts %}
- {%- capture description -%}
- {% include post-description.html %}
- {%- endcapture -%}
{
"title": {{ post.title | jsonify }},
"url": {{ post.url | relative_url | jsonify }},
"categories": {{ post.categories | join: ', ' | jsonify }},
"tags": {{ post.tags | join: ', ' | jsonify }},
- "date": "{{ post.date }}",
- "content": "{{ description }}"
+ "date": {{ post.date | jsonify }},
+ "content": {% include post-description.html json=true %}
}{% unless forloop.last %},{% endunless %}
{% endfor %}
]
From c0e47562001026319ee2740594e0344ce36c222e Mon Sep 17 00:00:00 2001
From: semantic-release-bot
Date: Sat, 26 Jul 2025 12:24:47 +0000
Subject: [PATCH 2/2] chore(release): 7.3.1
## [7.3.1](https://github.com/cotes2020/jekyll-theme-chirpy/compare/v7.3.0...v7.3.1) (2025-07-26)
### Bug Fixes
* escape special JSON characters in search results ([#2481](https://github.com/cotes2020/jekyll-theme-chirpy/issues/2481)) ([7615d72](https://github.com/cotes2020/jekyll-theme-chirpy/commit/7615d72e9300a1514ef2fc8ec941ab2974ba7eb4))
---
docs/CHANGELOG.md | 6 ++++++
jekyll-theme-chirpy.gemspec | 2 +-
package.json | 2 +-
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 24afe66..b9a4172 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -1,5 +1,11 @@
# Changelog
+## [7.3.1](https://github.com/cotes2020/jekyll-theme-chirpy/compare/v7.3.0...v7.3.1) (2025-07-26)
+
+### Bug Fixes
+
+* escape special JSON characters in search results ([#2481](https://github.com/cotes2020/jekyll-theme-chirpy/issues/2481)) ([7615d72](https://github.com/cotes2020/jekyll-theme-chirpy/commit/7615d72e9300a1514ef2fc8ec941ab2974ba7eb4))
+
## [7.3.0](https://github.com/cotes2020/jekyll-theme-chirpy/compare/v7.2.4...v7.3.0) (2025-05-18)
### Features
diff --git a/jekyll-theme-chirpy.gemspec b/jekyll-theme-chirpy.gemspec
index 07d64e4..a4d3679 100644
--- a/jekyll-theme-chirpy.gemspec
+++ b/jekyll-theme-chirpy.gemspec
@@ -2,7 +2,7 @@
Gem::Specification.new do |spec|
spec.name = "jekyll-theme-chirpy"
- spec.version = "7.3.0"
+ spec.version = "7.3.1"
spec.authors = ["Cotes Chung"]
spec.email = ["cotes.chung@gmail.com"]
diff --git a/package.json b/package.json
index 6f2cfb0..ceed028 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "jekyll-theme-chirpy",
- "version": "7.3.0",
+ "version": "7.3.1",
"description": "A minimal, responsive, and feature-rich Jekyll theme for technical writing.",
"repository": {
"type": "git",