简体   繁体   English

将重音字符转换为 Liquid 中的普通字符

[英]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?例如 name = Florian Müllner , want name to be Florian MUllner How to cover name with accent 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:这是我非常非常肮脏的解决方案,并且在 Jekyll 中没有插件的情况下远未完成(但可以满足我的需要):

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

and the included file works as a function:并且包含的文件作为 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' %}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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