mirror of
https://github.com/danog/blackfriday.git
synced 2025-01-22 13:21:36 +01:00
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.
This commit is contained in:
parent
18432fc942
commit
0b647d0506
2
block.go
2
block.go
@ -456,7 +456,7 @@ func (p *parser) htmlFindTag(data []byte) (string, bool) {
|
|||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
key := string(data[:i])
|
key := string(data[:i])
|
||||||
if blockTags[key] {
|
if _, ok := blockTags[key]; ok {
|
||||||
return key, true
|
return key, true
|
||||||
}
|
}
|
||||||
return "", false
|
return "", false
|
||||||
|
80
markdown.go
80
markdown.go
@ -102,49 +102,49 @@ const (
|
|||||||
TAB_SIZE_EIGHT = 8
|
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.
|
// Any of these can be included in markdown text without special escaping.
|
||||||
var blockTags = map[string]bool{
|
var blockTags = map[string]struct{}{
|
||||||
"blockquote": true,
|
"blockquote": struct{}{},
|
||||||
"del": true,
|
"del": struct{}{},
|
||||||
"div": true,
|
"div": struct{}{},
|
||||||
"dl": true,
|
"dl": struct{}{},
|
||||||
"fieldset": true,
|
"fieldset": struct{}{},
|
||||||
"form": true,
|
"form": struct{}{},
|
||||||
"h1": true,
|
"h1": struct{}{},
|
||||||
"h2": true,
|
"h2": struct{}{},
|
||||||
"h3": true,
|
"h3": struct{}{},
|
||||||
"h4": true,
|
"h4": struct{}{},
|
||||||
"h5": true,
|
"h5": struct{}{},
|
||||||
"h6": true,
|
"h6": struct{}{},
|
||||||
"iframe": true,
|
"iframe": struct{}{},
|
||||||
"ins": true,
|
"ins": struct{}{},
|
||||||
"math": true,
|
"math": struct{}{},
|
||||||
"noscript": true,
|
"noscript": struct{}{},
|
||||||
"ol": true,
|
"ol": struct{}{},
|
||||||
"pre": true,
|
"pre": struct{}{},
|
||||||
"p": true,
|
"p": struct{}{},
|
||||||
"script": true,
|
"script": struct{}{},
|
||||||
"style": true,
|
"style": struct{}{},
|
||||||
"table": true,
|
"table": struct{}{},
|
||||||
"ul": true,
|
"ul": struct{}{},
|
||||||
|
|
||||||
// HTML5
|
// HTML5
|
||||||
"address": true,
|
"address": struct{}{},
|
||||||
"article": true,
|
"article": struct{}{},
|
||||||
"aside": true,
|
"aside": struct{}{},
|
||||||
"canvas": true,
|
"canvas": struct{}{},
|
||||||
"figcaption": true,
|
"figcaption": struct{}{},
|
||||||
"figure": true,
|
"figure": struct{}{},
|
||||||
"footer": true,
|
"footer": struct{}{},
|
||||||
"header": true,
|
"header": struct{}{},
|
||||||
"hgroup": true,
|
"hgroup": struct{}{},
|
||||||
"main": true,
|
"main": struct{}{},
|
||||||
"nav": true,
|
"nav": struct{}{},
|
||||||
"output": true,
|
"output": struct{}{},
|
||||||
"progress": true,
|
"progress": struct{}{},
|
||||||
"section": true,
|
"section": struct{}{},
|
||||||
"video": true,
|
"video": struct{}{},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Renderer is the rendering interface.
|
// Renderer is the rendering interface.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user