github.com/graemephi/kahugo@v0.62.3-0.20211121071557-d78c0423784d/markup/blackfriday/blackfriday_config/config.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 helpers implements general utility functions that work with 15 // and on content. The helper functions defined here lay down the 16 // foundation of how Hugo works with files and filepaths, and perform 17 // string operations on content. 18 19 package blackfriday_config 20 21 import ( 22 "github.com/mitchellh/mapstructure" 23 "github.com/pkg/errors" 24 ) 25 26 // Default holds the default BlackFriday config. 27 // Do not change! 28 var Default = Config{ 29 Smartypants: true, 30 AngledQuotes: false, 31 SmartypantsQuotesNBSP: false, 32 Fractions: true, 33 HrefTargetBlank: false, 34 NofollowLinks: false, 35 NoreferrerLinks: false, 36 SmartDashes: true, 37 LatexDashes: true, 38 PlainIDAnchors: true, 39 TaskLists: true, 40 SkipHTML: false, 41 } 42 43 // Config holds configuration values for BlackFriday rendering. 44 // It is kept here because it's used in several packages. 45 type Config struct { 46 Smartypants bool 47 SmartypantsQuotesNBSP bool 48 AngledQuotes bool 49 Fractions bool 50 HrefTargetBlank bool 51 NofollowLinks bool 52 NoreferrerLinks bool 53 SmartDashes bool 54 LatexDashes bool 55 TaskLists bool 56 PlainIDAnchors bool 57 Extensions []string 58 ExtensionsMask []string 59 SkipHTML bool 60 61 FootnoteAnchorPrefix string 62 FootnoteReturnLinkContents string 63 } 64 65 func UpdateConfig(b Config, m map[string]interface{}) (Config, error) { 66 if err := mapstructure.Decode(m, &b); err != nil { 67 return b, errors.WithMessage(err, "failed to decode rendering config") 68 } 69 return b, nil 70 }