mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-29 22:29:56 +02:00
Make removal of accents in taxonomy and section paths optional
And default off. Fixes #1180
This commit is contained in:
@@ -99,9 +99,16 @@ func UnicodeSanitize(s string) string {
|
||||
}
|
||||
}
|
||||
|
||||
// remove accents - see https://blog.golang.org/normalization
|
||||
t := transform.Chain(norm.NFD, transform.RemoveFunc(isMn), norm.NFC)
|
||||
result, _, _ := transform.String(t, string(target))
|
||||
var result string
|
||||
|
||||
if viper.GetBool("RemovePathAccents") {
|
||||
// remove accents - see https://blog.golang.org/normalization
|
||||
t := transform.Chain(norm.NFD, transform.RemoveFunc(isMn), norm.NFC)
|
||||
result, _, _ = transform.String(t, string(target))
|
||||
} else {
|
||||
result = string(target)
|
||||
}
|
||||
|
||||
return result
|
||||
|
||||
return string(target)
|
||||
|
@@ -17,6 +17,10 @@ import (
|
||||
)
|
||||
|
||||
func TestMakePath(t *testing.T) {
|
||||
viper.Reset()
|
||||
defer viper.Reset()
|
||||
viper.Set("RemovePathAccents", true)
|
||||
|
||||
tests := []struct {
|
||||
input string
|
||||
expected string
|
||||
@@ -717,7 +721,7 @@ func TestGetTempDir(t *testing.T) {
|
||||
{testDir + "FOo/BaR.html", dir + testDir + "FOo/BaR.html" + FilePathSeparator},
|
||||
{testDir + "трям/трям", dir + testDir + "трям/трям" + FilePathSeparator},
|
||||
{testDir + "은행", dir + testDir + "은행" + FilePathSeparator},
|
||||
{testDir + "Банковский кассир", dir + testDir + "Банковскии-кассир" + FilePathSeparator},
|
||||
{testDir + "Банковский кассир", dir + testDir + "Банковский-кассир" + FilePathSeparator},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
Reference in New Issue
Block a user