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.
diff --git a/block.go b/block.go
index de84da5..b5b0841 100644
--- a/block.go
+++ b/block.go
@@ -456,7 +456,7 @@
i++
}
key := string(data[:i])
- if blockTags[key] {
+ if _, ok := blockTags[key]; ok {
return key, true
}
return "", false
diff --git a/markdown.go b/markdown.go
index e31e50d..746905b 100644
--- a/markdown.go
+++ b/markdown.go
@@ -102,49 +102,49 @@
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.