mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-12 20:13:59 +02:00
Make the title case style guide configurable
This works for the `title` func and the other places where Hugo makes title case. * AP style (new default) * Chicago style * Go style (what we have today) Fixes #989
This commit is contained in:
@@ -19,6 +19,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestGuessType(t *testing.T) {
|
||||
@@ -173,6 +174,20 @@ func TestReaderContains(t *testing.T) {
|
||||
assert.False(t, ReaderContains(nil, nil))
|
||||
}
|
||||
|
||||
func TestGetTitleFunc(t *testing.T) {
|
||||
title := "somewhere over the rainbow"
|
||||
assert := require.New(t)
|
||||
|
||||
assert.Equal("Somewhere Over The Rainbow", GetTitleFunc("go")(title))
|
||||
assert.Equal("Somewhere over the Rainbow", GetTitleFunc("chicago")(title), "Chicago style")
|
||||
assert.Equal("Somewhere over the Rainbow", GetTitleFunc("Chicago")(title), "Chicago style")
|
||||
assert.Equal("Somewhere Over the Rainbow", GetTitleFunc("ap")(title), "AP style")
|
||||
assert.Equal("Somewhere Over the Rainbow", GetTitleFunc("ap")(title), "AP style")
|
||||
assert.Equal("Somewhere Over the Rainbow", GetTitleFunc("")(title), "AP style")
|
||||
assert.Equal("Somewhere Over the Rainbow", GetTitleFunc("unknown")(title), "AP style")
|
||||
|
||||
}
|
||||
|
||||
func BenchmarkReaderContains(b *testing.B) {
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
|
Reference in New Issue
Block a user