Convert accent characters to normal characters in Liquid

510 views Asked by At

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?

2

There are 2 answers

4
DVS On

You can use replace like this.

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

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' %}