ref: 4b7c1342fd6d7eea216ff9de22f94a195d620414
parent: 847ad36e45bc3d2bd486a33144aa7dccfa5aacb3
author: Bjørn Erik Pedersen <[email protected]>
date: Tue Jun 16 15:25:48 EDT 2015
Make removal of accents in taxonomy and section paths optional And default off. Fixes #1180
--- a/commands/hugo.go
+++ b/commands/hugo.go
@@ -141,6 +141,7 @@
viper.SetDefault("IgnoreCache", false)
viper.SetDefault("CanonifyURLs", false)
viper.SetDefault("RelativeURLs", false)
+ viper.SetDefault("RemovePathAccents", false)
viper.SetDefault("Taxonomies", map[string]string{"tag": "tags", "category": "categories"})
viper.SetDefault("Permalinks", make(hugolib.PermalinkOverrides, 0))
viper.SetDefault("Sitemap", hugolib.Sitemap{Priority: -1})
@@ -192,7 +193,7 @@
if hugoCmdV.PersistentFlags().Lookup("disableSitemap").Changed {
viper.Set("DisableSitemap", DisableSitemap)
}
-
+
if hugoCmdV.PersistentFlags().Lookup("verbose").Changed {
viper.Set("Verbose", Verbose)
}
--- a/helpers/path.go
+++ b/helpers/path.go
@@ -99,9 +99,16 @@
}
}
- // 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)
--- a/helpers/path_test.go
+++ b/helpers/path_test.go
@@ -17,6 +17,10 @@
)
func TestMakePath(t *testing.T) {
+ viper.Reset()
+ defer viper.Reset()
+ viper.Set("RemovePathAccents", true)
+
tests := []struct {
input string
expected string
@@ -717,7 +721,7 @@
{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 {