github.com/linchen2chris/hugo@v0.0.0-20230307053224-cec209389705/markup/goldmark/goldmark_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 goldmark_config holds Goldmark related configuration. 15 package goldmark_config 16 17 const ( 18 AutoHeadingIDTypeGitHub = "github" 19 AutoHeadingIDTypeGitHubAscii = "github-ascii" 20 AutoHeadingIDTypeBlackfriday = "blackfriday" 21 ) 22 23 // DefaultConfig holds the default Goldmark configuration. 24 var Default = Config{ 25 Extensions: Extensions{ 26 Typographer: true, 27 Footnote: true, 28 DefinitionList: true, 29 Table: true, 30 Strikethrough: true, 31 Linkify: true, 32 LinkifyProtocol: "https", 33 TaskList: true, 34 }, 35 Renderer: Renderer{ 36 Unsafe: false, 37 }, 38 Parser: Parser{ 39 AutoHeadingID: true, 40 AutoHeadingIDType: AutoHeadingIDTypeGitHub, 41 WrapStandAloneImageWithinParagraph: true, 42 Attribute: ParserAttribute{ 43 Title: true, 44 Block: false, 45 }, 46 }, 47 } 48 49 // Config configures Goldmark. 50 type Config struct { 51 Renderer Renderer 52 Parser Parser 53 Extensions Extensions 54 } 55 56 type Extensions struct { 57 Typographer bool 58 Footnote bool 59 DefinitionList bool 60 61 // GitHub flavored markdown 62 Table bool 63 Strikethrough bool 64 Linkify bool 65 LinkifyProtocol string 66 TaskList bool 67 } 68 69 type Renderer struct { 70 // Whether softline breaks should be rendered as '<br>' 71 HardWraps bool 72 73 // XHTML instead of HTML5. 74 XHTML bool 75 76 // Allow raw HTML etc. 77 Unsafe bool 78 } 79 80 type Parser struct { 81 // Enables custom heading ids and 82 // auto generated heading ids. 83 AutoHeadingID bool 84 85 // The strategy to use when generating heading IDs. 86 // Available options are "github", "github-ascii". 87 // Default is "github", which will create GitHub-compatible anchor names. 88 AutoHeadingIDType string 89 90 // Enables custom attributes. 91 Attribute ParserAttribute 92 93 // Whether to wrap stand-alone images within a paragraph or not. 94 WrapStandAloneImageWithinParagraph bool 95 } 96 97 type ParserAttribute struct { 98 // Enables custom attributes for titles. 99 Title bool 100 // Enables custom attributeds for blocks. 101 Block bool 102 }