Comments (5)
Just delete escape
in _includes/post-description.html
, see here, can solve your problem.
{%- comment -%}
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 -%}
{%- include no-linenos.html content=post.content -%}
{{- content | markdownify | strip_html -}}
{%- endif -%}
{%- endcapture -%}
- {{- description | strip | truncate: max_length | escape -}}
+ {{- description | strip | truncate: max_length -}}
The function of escape
in Liquid can be found here,
Escapes a string by replacing characters with escape sequences (so that the string can be used in a URL, for example). It doesn’t change strings that don’t have anything to escape.
In Jekyll blogs, the 'escape' filter is typically used to HTML-escape the output, ensuring that when rendered on a webpage, it won't be interpreted as HTML tags, thereby mitigating potential security risks such as XSS (Cross-Site Scripting) attacks.
In the above code snippet in _includes/post-description.html
, the 'escape' filter is applied after the 'truncate' filter. This means it ensures that the text after truncation does not contain any unescaped HTML tags. The purpose of this is to maintain the security of the page by ensuring that the truncated text length does not include any unescaped HTML tags.
If you delete escape
, it may lead to potential bugs. I believe this is why the author closed the issues you previously opened.
from jekyll-theme-chirpy.
For example, If you make the last word of the description displayed in home bold, you will find that all other post previews have become bold. Other layouts of the page will also be broken.
This is just one of the bugs I know about.
So I don't suggest you do this
from jekyll-theme-chirpy.
Thanks for the detailed explanation, much appreciated! I am a bit smarter now.
would there be anything wrong with:
{%- capture description -%}
{%- if post.description -%}
{{- post.description | strip | truncate: max_length | markdownify | escape -}}
{%- else -%}
from jekyll-theme-chirpy.
{%- capture description -%} {%- if post.description -%} {{- post.description | strip | truncate: max_length | markdownify | escape -}} {%- else -%}
@steveng57 It doesn't work.
from jekyll-theme-chirpy.
Duplicate of #1739
from jekyll-theme-chirpy.
Related Issues (20)
- Ads personalization consent signals not detected
- Embedded video does not respect the media_subpath Front Matter variable HOT 3
- Add Markdownify processing to description: field Front Matter rendering. HOT 3
- Automated repository README.md as post content HOT 2
- error: Jekyll::Converters::Scss encountered an error while converting 'assets/css/jekyll-theme-chirpy.scss': HOT 12
- can not parse map data in json HOT 2
- All images will be displayed when switching images (including light and dark mode). HOT 4
- Can not parse cpp code sippit in markdown file
- Image displaying feature will be broken when TOC is off
- Hope to add documentation feature similar to Vitepress or Docusaurus
- Videos Improperly Sized in 7.0.0 HOT 1
- Error /assets/js/dist/home.min.js HOT 7
- htmlproofer failed with non-root bash_path HOT 1
- Missing lazysizes.min.js when chooses to self-host assests/lib
- Could this repo worked with username.github.io/project_name HOT 1
- Menu location - located on top instead of sidebar / side menu ? HOT 1
- TypeError: Failed to register a ServiceWorker for scope ('https://username.github.io/') with script ('https://username.github.io/sw.min.js'): A bad HTTP response code (404) was received when fetching the script. HOT 3
- Error: Custom property values may not be empty HOT 1
- Some options for site.lang are incompatible with giscus API HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jekyll-theme-chirpy.