1// Copyright 2021 The Go Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style 3// license that can be found in the LICENSE file. 4 5package markdown 6 7import "strings" 8 9// htmlTags lists the known HTML tags for HTML blocks. 10var htmlTags = []string{ 11 "address", 12 "article", 13 "aside", 14 "base", 15 "basefont", 16 "blockquote", 17 "body", 18 "caption", 19 "center", 20 "col", 21 "colgroup", 22 "dd", 23 "details", 24 "dialog", 25 "dir", 26 "div", 27 "dl", 28 "dt", 29 "fieldset", 30 "figcaption", 31 "figure", 32 "footer", 33 "form", 34 "frame", 35 "frameset", 36 "h1", 37 "h2", 38 "h3", 39 "h4", 40 "h5", 41 "h6", 42 "head", 43 "header", 44 "hr", 45 "html", 46 "iframe", 47 "legend", 48 "li", 49 "link", 50 "main", 51 "menu", 52 "menuitem", 53 "nav", 54 "noframes", 55 "ol", 56 "optgroup", 57 "option", 58 "p", 59 "param", 60 "section", 61 "source", 62 "summary", 63 "table", 64 "tbody", 65 "td", 66 "tfoot", 67 "th", 68 "thead", 69 "title", 70 "tr", 71 "track", 72 "ul", 73} 74 75var htmlEscaper = strings.NewReplacer( 76 "\"", """, 77 "&", "&", 78 "<", "<", 79 ">", ">", 80) 81 82var htmlQuoteEscaper = strings.NewReplacer( 83 "\"", """, 84 "&", "&", 85 "<", "<", 86 ">", ">", 87) 88 89var htmlLinkEscaper = strings.NewReplacer( 90 "\"", "%22", 91 "&", "&", 92 "<", "%3C", 93 ">", "%3E", 94 "\\", "%5C", 95 " ", "%20", 96 "`", "%60", 97 "[", "%5B", 98 "]", "%5D", 99 "^", "%5E", 100 "{", "%7B", 101 "}", "%7D", 102 "\x00", "%00", 103 "\x01", "%01", 104 "\x02", "%02", 105 "\x03", "%03", 106 "\x04", "%04", 107 "\x05", "%05", 108 "\x06", "%06", 109 "\x07", "%07", 110 "\x08", "%08", 111 // "\x09", "%09", 112 // "\x0A", "%0A", 113 "\x0B", "%0B", 114 "\x0C", "%0C", 115 // "\x0D", "%0D", 116 "\x0E", "%0E", 117 "\x0F", "%0F", 118 "\x10", "%10", 119 "\x11", "%11", 120 "\x12", "%12", 121 "\x13", "%13", 122 "\x14", "%14", 123 "\x15", "%15", 124 "\x16", "%16", 125 "\x17", "%17", 126 "\x18", "%18", 127 "\x19", "%19", 128 "\x1A", "%1A", 129 "\x1B", "%1B", 130 "\x1C", "%1C", 131 "\x1D", "%1D", 132 "\x1E", "%1E", 133 "\x1F", "%1F", 134 "\x7F", "%7F", 135 "\x80", "%80", 136 "\x81", "%81", 137 "\x82", "%82", 138 "\x83", "%83", 139 "\x84", "%84", 140 "\x85", "%85", 141 "\x86", "%86", 142 "\x87", "%87", 143 "\x88", "%88", 144 "\x89", "%89", 145 "\x8A", "%8A", 146 "\x8B", "%8B", 147 "\x8C", "%8C", 148 "\x8D", "%8D", 149 "\x8E", "%8E", 150 "\x8F", "%8F", 151 "\x90", "%90", 152 "\x91", "%91", 153 "\x92", "%92", 154 "\x93", "%93", 155 "\x94", "%94", 156 "\x95", "%95", 157 "\x96", "%96", 158 "\x97", "%97", 159 "\x98", "%98", 160 "\x99", "%99", 161 "\x9A", "%9A", 162 "\x9B", "%9B", 163 "\x9C", "%9C", 164 "\x9D", "%9D", 165 "\x9E", "%9E", 166 "\x9F", "%9F", 167 "\xA0", "%A0", 168 "\xA1", "%A1", 169 "\xA2", "%A2", 170 "\xA3", "%A3", 171 "\xA4", "%A4", 172 "\xA5", "%A5", 173 "\xA6", "%A6", 174 "\xA7", "%A7", 175 "\xA8", "%A8", 176 "\xA9", "%A9", 177 "\xAA", "%AA", 178 "\xAB", "%AB", 179 "\xAC", "%AC", 180 "\xAD", "%AD", 181 "\xAE", "%AE", 182 "\xAF", "%AF", 183 "\xB0", "%B0", 184 "\xB1", "%B1", 185 "\xB2", "%B2", 186 "\xB3", "%B3", 187 "\xB4", "%B4", 188 "\xB5", "%B5", 189 "\xB6", "%B6", 190 "\xB7", "%B7", 191 "\xB8", "%B8", 192 "\xB9", "%B9", 193 "\xBA", "%BA", 194 "\xBB", "%BB", 195 "\xBC", "%BC", 196 "\xBD", "%BD", 197 "\xBE", "%BE", 198 "\xBF", "%BF", 199 "\xC0", "%C0", 200 "\xC1", "%C1", 201 "\xC2", "%C2", 202 "\xC3", "%C3", 203 "\xC4", "%C4", 204 "\xC5", "%C5", 205 "\xC6", "%C6", 206 "\xC7", "%C7", 207 "\xC8", "%C8", 208 "\xC9", "%C9", 209 "\xCA", "%CA", 210 "\xCB", "%CB", 211 "\xCC", "%CC", 212 "\xCD", "%CD", 213 "\xCE", "%CE", 214 "\xCF", "%CF", 215 "\xD0", "%D0", 216 "\xD1", "%D1", 217 "\xD2", "%D2", 218 "\xD3", "%D3", 219 "\xD4", "%D4", 220 "\xD5", "%D5", 221 "\xD6", "%D6", 222 "\xD7", "%D7", 223 "\xD8", "%D8", 224 "\xD9", "%D9", 225 "\xDA", "%DA", 226 "\xDB", "%DB", 227 "\xDC", "%DC", 228 "\xDD", "%DD", 229 "\xDE", "%DE", 230 "\xDF", "%DF", 231 "\xE0", "%E0", 232 "\xE1", "%E1", 233 "\xE2", "%E2", 234 "\xE3", "%E3", 235 "\xE4", "%E4", 236 "\xE5", "%E5", 237 "\xE6", "%E6", 238 "\xE7", "%E7", 239 "\xE8", "%E8", 240 "\xE9", "%E9", 241 "\xEA", "%EA", 242 "\xEB", "%EB", 243 "\xEC", "%EC", 244 "\xED", "%ED", 245 "\xEE", "%EE", 246 "\xEF", "%EF", 247 "\xF0", "%F0", 248 "\xF1", "%F1", 249 "\xF2", "%F2", 250 "\xF3", "%F3", 251 "\xF4", "%F4", 252 "\xF5", "%F5", 253 "\xF6", "%F6", 254 "\xF7", "%F7", 255 "\xF8", "%F8", 256 "\xF9", "%F9", 257 "\xFA", "%FA", 258 "\xFB", "%FB", 259 "\xFC", "%FC", 260 "\xFD", "%FD", 261 "\xFE", "%FE", 262 "\xFF", "%FF", 263) 264