Path: blob/main/vendor/golang.org/x/net/html/const.go
2880 views
// Copyright 2011 The Go Authors. All rights reserved.1// Use of this source code is governed by a BSD-style2// license that can be found in the LICENSE file.34package html56// Section 12.2.4.2 of the HTML5 specification says "The following elements7// have varying levels of special parsing rules".8// https://html.spec.whatwg.org/multipage/syntax.html#the-stack-of-open-elements9var isSpecialElementMap = map[string]bool{10"address": true,11"applet": true,12"area": true,13"article": true,14"aside": true,15"base": true,16"basefont": true,17"bgsound": true,18"blockquote": true,19"body": true,20"br": true,21"button": true,22"caption": true,23"center": true,24"col": true,25"colgroup": true,26"dd": true,27"details": true,28"dir": true,29"div": true,30"dl": true,31"dt": true,32"embed": true,33"fieldset": true,34"figcaption": true,35"figure": true,36"footer": true,37"form": true,38"frame": true,39"frameset": true,40"h1": true,41"h2": true,42"h3": true,43"h4": true,44"h5": true,45"h6": true,46"head": true,47"header": true,48"hgroup": true,49"hr": true,50"html": true,51"iframe": true,52"img": true,53"input": true,54"keygen": true, // "keygen" has been removed from the spec, but are kept here for backwards compatibility.55"li": true,56"link": true,57"listing": true,58"main": true,59"marquee": true,60"menu": true,61"meta": true,62"nav": true,63"noembed": true,64"noframes": true,65"noscript": true,66"object": true,67"ol": true,68"p": true,69"param": true,70"plaintext": true,71"pre": true,72"script": true,73"section": true,74"select": true,75"source": true,76"style": true,77"summary": true,78"table": true,79"tbody": true,80"td": true,81"template": true,82"textarea": true,83"tfoot": true,84"th": true,85"thead": true,86"title": true,87"tr": true,88"track": true,89"ul": true,90"wbr": true,91"xmp": true,92}9394func isSpecialElement(element *Node) bool {95switch element.Namespace {96case "", "html":97return isSpecialElementMap[element.Data]98case "math":99switch element.Data {100case "mi", "mo", "mn", "ms", "mtext", "annotation-xml":101return true102}103case "svg":104switch element.Data {105case "foreignObject", "desc", "title":106return true107}108}109return false110}111112113