Use more idiomatic form for set of strings.
This is a better style for a set, since each value can only be present or absent. With bool as value type, each value may be absent, or true or false. It also uses slightly more memory.pull/217/head v1.4
parent
18432fc942
commit
0b647d0506
2
block.go
2
block.go
|
@ -456,7 +456,7 @@ func (p *parser) htmlFindTag(data []byte) (string, bool) {
|
|||
i++
|
||||
}
|
||||
key := string(data[:i])
|
||||
if blockTags[key] {
|
||||
if _, ok := blockTags[key]; ok {
|
||||
return key, true
|
||||
}
|
||||
return "", false
|
||||
|
|
80
markdown.go
80
markdown.go
|
@ -102,49 +102,49 @@ const (
|
|||
TAB_SIZE_EIGHT = 8
|
||||
)
|
||||
|
||||
// These are the tags that are recognized as HTML block tags.
|
||||
// blockTags is a set of tags that are recognized as HTML block tags.
|
||||
// Any of these can be included in markdown text without special escaping.
|
||||
var blockTags = map[string]bool{
|
||||
"blockquote": true,
|
||||
"del": true,
|
||||
"div": true,
|
||||
"dl": true,
|
||||
"fieldset": true,
|
||||
"form": true,
|
||||
"h1": true,
|
||||
"h2": true,
|
||||
"h3": true,
|
||||
"h4": true,
|
||||
"h5": true,
|
||||
"h6": true,
|
||||
"iframe": true,
|
||||
"ins": true,
|
||||
"math": true,
|
||||
"noscript": true,
|
||||
"ol": true,
|
||||
"pre": true,
|
||||
"p": true,
|
||||
"script": true,
|
||||
"style": true,
|
||||
"table": true,
|
||||
"ul": true,
|
||||
var blockTags = map[string]struct{}{
|
||||
"blockquote": struct{}{},
|
||||
"del": struct{}{},
|
||||
"div": struct{}{},
|
||||
"dl": struct{}{},
|
||||
"fieldset": struct{}{},
|
||||
"form": struct{}{},
|
||||
"h1": struct{}{},
|
||||
"h2": struct{}{},
|
||||
"h3": struct{}{},
|
||||
"h4": struct{}{},
|
||||
"h5": struct{}{},
|
||||
"h6": struct{}{},
|
||||
"iframe": struct{}{},
|
||||
"ins": struct{}{},
|
||||
"math": struct{}{},
|
||||
"noscript": struct{}{},
|
||||
"ol": struct{}{},
|
||||
"pre": struct{}{},
|
||||
"p": struct{}{},
|
||||
"script": struct{}{},
|
||||
"style": struct{}{},
|
||||
"table": struct{}{},
|
||||
"ul": struct{}{},
|
||||
|
||||
// HTML5
|
||||
"address": true,
|
||||
"article": true,
|
||||
"aside": true,
|
||||
"canvas": true,
|
||||
"figcaption": true,
|
||||
"figure": true,
|
||||
"footer": true,
|
||||
"header": true,
|
||||
"hgroup": true,
|
||||
"main": true,
|
||||
"nav": true,
|
||||
"output": true,
|
||||
"progress": true,
|
||||
"section": true,
|
||||
"video": true,
|
||||
"address": struct{}{},
|
||||
"article": struct{}{},
|
||||
"aside": struct{}{},
|
||||
"canvas": struct{}{},
|
||||
"figcaption": struct{}{},
|
||||
"figure": struct{}{},
|
||||
"footer": struct{}{},
|
||||
"header": struct{}{},
|
||||
"hgroup": struct{}{},
|
||||
"main": struct{}{},
|
||||
"nav": struct{}{},
|
||||
"output": struct{}{},
|
||||
"progress": struct{}{},
|
||||
"section": struct{}{},
|
||||
"video": struct{}{},
|
||||
}
|
||||
|
||||
// Renderer is the rendering interface.
|
||||
|
|
Loading…
Reference in New Issue