- {{ post.content | strip_html | truncate: 200 | replace: '&', '&' }} + {% assign _content = post.content %} + {% include no-linenos.html %} + {{ _content | markdownify | strip_html | truncate: 200 }}
diff --git a/_includes/no-linenos.html b/_includes/no-linenos.html new file mode 100644 index 0000000..0b55105 --- /dev/null +++ b/_includes/no-linenos.html @@ -0,0 +1,12 @@ +{% comment %} + Remove line numbers from code snippets. + v2.2 + https://github.com/cotes2020/jekyll-theme-chirpy + © 2020 Cotes Chung + Published under the MIT License +{% endcomment %} + +{% if _content contains '
' %} + {% assign _content = _content | replace: ' ', '' %} +{% endif %} diff --git a/_includes/related-posts.html b/_includes/related-posts.html index ae34eb9..dcb7992 100644 --- a/_includes/related-posts.html +++ b/_includes/related-posts.html @@ -58,7 +58,9 @@ {{ post.title }}
-diff --git a/_layouts/home.html b/_layouts/home.html index 3c05220..f549c17 100644 --- a/_layouts/home.html +++ b/_layouts/home.html @@ -15,7 +15,9 @@ layout: page{{ post.content | markdownify | strip_html | truncate: 200 | replace: '&', '&' }}
+ {% assign content = post.content %} + {% include no-linenos.html %} +{{ content | markdownify | strip_html | truncate: 200 | replace: '&', '&' }}
diff --git a/assets/data/search.json b/assets/data/search.json index 5627dca..93ef912 100644 --- a/assets/data/search.json +++ b/assets/data/search.json @@ -10,7 +10,9 @@ layout: compress "categories": "{{ post.categories | join: ', '}}", "tags": "{{ post.tags | join: ', ' }}", "date": "{{ post.date }}", - "snippet": "{{ post.content | strip_html | strip_newlines | remove_chars | escape | truncate: 300 | replace: '\', '\\\\' }}" + {% assign content = post.content %} + {% include no-linenos.html %} + "snippet": "{{ content | strip_html | strip_newlines | remove_chars | escape | truncate: 300 | replace: '\', '\\\\' }}" }{% unless forloop.last %},{% endunless %} {% endfor %} ] diff --git a/feed.xml b/feed.xml index 7701795..30e01fc 100644 --- a/feed.xml +++ b/feed.xml @@ -50,7 +50,10 @@ layout: compress {% if post.summary %}- {{ post.content | strip_html | truncate: 200 | replace: '&', '&' }} + {% assign _content = post.content %} + {% include no-linenos.html %} + {{ _content | markdownify | strip_html | truncate: 200 }}
{{ post.summary | strip }} {% else %} -{{ post.content | strip_html | truncate: 200 }} ++ {% assign content = post.content %} + {% include no-linenos.html %} + {{ content | strip_html | truncate: 200 }} {% endif %}