github.com/graemephi/kahugo@v0.62.3-0.20211121071557-d78c0423784d/markup/markup_config/config_test.go (about) 1 // Copyright 2019 The Hugo Authors. All rights reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // http://www.apache.org/licenses/LICENSE-2.0 7 // 8 // Unless required by applicable law or agreed to in writing, software 9 // distributed under the License is distributed on an "AS IS" BASIS, 10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 package markup_config 15 16 import ( 17 "testing" 18 19 "github.com/gohugoio/hugo/config" 20 21 qt "github.com/frankban/quicktest" 22 ) 23 24 func TestConfig(t *testing.T) { 25 c := qt.New(t) 26 27 c.Run("Decode", func(c *qt.C) { 28 c.Parallel() 29 v := config.New() 30 31 v.Set("markup", map[string]interface{}{ 32 "goldmark": map[string]interface{}{ 33 "renderer": map[string]interface{}{ 34 "unsafe": true, 35 }, 36 }, 37 "asciidocext": map[string]interface{}{ 38 "workingFolderCurrent": true, 39 "safeMode": "save", 40 "extensions": []string{"asciidoctor-html5s"}, 41 }, 42 }) 43 44 conf, err := Decode(v) 45 46 c.Assert(err, qt.IsNil) 47 c.Assert(conf.Goldmark.Renderer.Unsafe, qt.Equals, true) 48 c.Assert(conf.BlackFriday.Fractions, qt.Equals, true) 49 c.Assert(conf.Goldmark.Parser.Attribute.Title, qt.Equals, true) 50 c.Assert(conf.Goldmark.Parser.Attribute.Block, qt.Equals, false) 51 52 c.Assert(conf.AsciidocExt.WorkingFolderCurrent, qt.Equals, true) 53 c.Assert(conf.AsciidocExt.Extensions[0], qt.Equals, "asciidoctor-html5s") 54 }) 55 56 c.Run("legacy", func(c *qt.C) { 57 c.Parallel() 58 v := config.New() 59 60 v.Set("blackfriday", map[string]interface{}{ 61 "angledQuotes": true, 62 }) 63 64 v.Set("footnoteAnchorPrefix", "myprefix") 65 v.Set("footnoteReturnLinkContents", "myreturn") 66 v.Set("pygmentsStyle", "hugo") 67 v.Set("pygmentsCodefencesGuessSyntax", true) 68 69 v.Set("markup", map[string]interface{}{ 70 "goldmark": map[string]interface{}{ 71 "parser": map[string]interface{}{ 72 "attribute": false, // Was changed to a struct in 0.81.0 73 }, 74 }, 75 }) 76 conf, err := Decode(v) 77 78 c.Assert(err, qt.IsNil) 79 c.Assert(conf.BlackFriday.AngledQuotes, qt.Equals, true) 80 c.Assert(conf.BlackFriday.FootnoteAnchorPrefix, qt.Equals, "myprefix") 81 c.Assert(conf.BlackFriday.FootnoteReturnLinkContents, qt.Equals, "myreturn") 82 c.Assert(conf.Highlight.Style, qt.Equals, "hugo") 83 c.Assert(conf.Highlight.CodeFences, qt.Equals, true) 84 c.Assert(conf.Highlight.GuessSyntax, qt.Equals, true) 85 c.Assert(conf.Goldmark.Parser.Attribute.Title, qt.Equals, false) 86 c.Assert(conf.Goldmark.Parser.Attribute.Block, qt.Equals, false) 87 88 }) 89 }