简体   繁体   中英

Convert accent characters to normal characters in Liquid

For instance name = Florian Müllner , want name to be Florian MUllner How to covert name with accented characters in Liquid?

Read the replace doc , but was not able to figure out. How to use?

You can use replace like this.

{% assign text = 'Florian Müllner' | replace: "ü", "U" %}

This is my very very dirty solution and far from complete (but works for my needs) with no plugins in Jekyll:

{% assign text = 'Müller Pérez' %}
{% include normalize_text.html %}

and the included file works as a function:

{% assign text = text | replace: 'á', 'a' | replace: 'é', 'e'  | replace: 'í', 'i'  | replace: 'ó', 'o'  | replace: 'ú', 'u' %}
{% assign text = text | replace: 'à', 'a' | replace: 'è, 'e'  | replace: 'ì', 'i'  | replace: 'ò', 'o'  | replace: 'ù', 'u' %}
{% assign text = text | replace: 'ä', 'a' | replace: 'ë', 'e'  | replace: 'ï', 'i'  | replace: 'ö', 'o'  | replace: 'ü', 'u' %}
{% assign text = text | replace: 'â', 'a' | replace: 'ê, 'e'  | replace: 'î', 'i'  | replace: 'ô', 'o'  | replace: 'û', 'u' %}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM