github.com/anakojm/hugo-katex@v0.0.0-20231023141351-42d6f5de9c0b/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 // Default holds the default Goldmark configuration. 24 var Default = Config{ 25 Extensions: Extensions{ 26 Typographer: Typographer{ 27 Disable: false, 28 LeftSingleQuote: "‘", 29 RightSingleQuote: "’", 30 LeftDoubleQuote: "“", 31 RightDoubleQuote: "”", 32 EnDash: "–", 33 EmDash: "—", 34 Ellipsis: "…", 35 LeftAngleQuote: "«", 36 RightAngleQuote: "»", 37 Apostrophe: "’", 38 }, 39 Footnote: true, 40 DefinitionList: true, 41 Table: true, 42 Strikethrough: true, 43 Linkify: true, 44 LinkifyProtocol: "https", 45 TaskList: true, 46 CJK: CJK{ 47 Enable: false, 48 EastAsianLineBreaks: false, 49 EscapedSpace: false, 50 }, 51 }, 52 Renderer: Renderer{ 53 Unsafe: false, 54 }, 55 Parser: Parser{ 56 AutoHeadingID: true, 57 AutoHeadingIDType: AutoHeadingIDTypeGitHub, 58 WrapStandAloneImageWithinParagraph: true, 59 Attribute: ParserAttribute{ 60 Title: true, 61 Block: false, 62 }, 63 }, 64 Katex: Katex{ 65 Enable: true, 66 Warnings: false, 67 }, 68 } 69 70 // Config configures Goldmark. 71 type Config struct { 72 Renderer Renderer 73 Parser Parser 74 Extensions Extensions 75 Katex Katex 76 } 77 78 type Extensions struct { 79 Typographer Typographer 80 Footnote bool 81 DefinitionList bool 82 83 // GitHub flavored markdown 84 Table bool 85 Strikethrough bool 86 Linkify bool 87 LinkifyProtocol string 88 TaskList bool 89 CJK CJK 90 } 91 92 // Typographer holds typographer configuration. 93 type Typographer struct { 94 // Whether to disable typographer. 95 Disable bool 96 97 // Value used for left single quote. 98 LeftSingleQuote string 99 // Value used for right single quote. 100 RightSingleQuote string 101 // Value used for left double quote. 102 LeftDoubleQuote string 103 // Value used for right double quote. 104 RightDoubleQuote string 105 // Value used for en dash. 106 EnDash string 107 // Value used for em dash. 108 EmDash string 109 // Value used for ellipsis. 110 Ellipsis string 111 // Value used for left angle quote. 112 LeftAngleQuote string 113 // Value used for right angle quote. 114 RightAngleQuote string 115 // Value used for apostrophe. 116 Apostrophe string 117 } 118 119 type CJK struct { 120 // Whether to enable CJK support. 121 Enable bool 122 123 // Whether softline breaks between east asian wide characters should be ignored. 124 EastAsianLineBreaks bool 125 126 // Whether a '\' escaped half-space(0x20) should not be rendered. 127 EscapedSpace bool 128 } 129 130 type Renderer struct { 131 // Whether softline breaks should be rendered as '<br>' 132 HardWraps bool 133 134 // XHTML instead of HTML5. 135 XHTML bool 136 137 // Allow raw HTML etc. 138 Unsafe bool 139 } 140 141 type Parser struct { 142 // Enables custom heading ids and 143 // auto generated heading ids. 144 AutoHeadingID bool 145 146 // The strategy to use when generating heading IDs. 147 // Available options are "github", "github-ascii". 148 // Default is "github", which will create GitHub-compatible anchor names. 149 AutoHeadingIDType string 150 151 // Enables custom attributes. 152 Attribute ParserAttribute 153 154 // Whether to wrap stand-alone images within a paragraph or not. 155 WrapStandAloneImageWithinParagraph bool 156 } 157 158 type ParserAttribute struct { 159 // Enables custom attributes for titles. 160 Title bool 161 // Enables custom attributeds for blocks. 162 Block bool 163 } 164 165 type Katex struct { 166 // Enable the Katex extension. 167 Enable bool 168 // Enables warnings. 169 Warnings bool 170 }