-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
connect collapse whitespace func to tag type map
- Loading branch information
1 parent
f0108bb
commit c37ad42
Showing
6 changed files
with
99 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package collapse | ||
|
||
import ( | ||
"github.com/JohannesKaufmann/dom" | ||
"golang.org/x/net/html" | ||
) | ||
|
||
var blockElements = []string{ | ||
"address", "article", "aside", "audio", "blockquote", "body", "canvas", "center", "dd", "dir", "div", "dl", "dt", "fieldset", "figcaption", "figure", "footer", "form", "frameset", "h1", "h2", "h3", "h4", "h5", "h6", "header", "hgroup", "hr", "html", "isindex", "li", "main", "menu", "nav", "noframes", "noscript", "ol", "output", "p", "pre", "section", "table", "tbody", "td", "tfoot", "th", "thead", "tr", "ul", | ||
} | ||
|
||
var voidElements = []string{ | ||
// Note: Compared to the javascript implementation, I removed "source" | ||
"area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "meta", "param" /* "source, "*/, "track", "wbr", | ||
} | ||
|
||
var defaultIsBlockNode = func(node *html.Node) bool { | ||
name := dom.NodeName(node) | ||
|
||
for _, elem := range blockElements { | ||
if elem == name { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
var defaultIsVoidNode = func(node *html.Node) bool { | ||
name := dom.NodeName(node) | ||
|
||
for _, elem := range voidElements { | ||
if elem == name { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
var defaultIsPreformattedNode = func(node *html.Node) bool { | ||
// Note: Originally in the javascript version, this just checked for "pre". | ||
// I changed it, to also return true for "code" | ||
name := dom.NodeName(node) | ||
|
||
return name == "pre" || name == "code" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters