const.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // Copyright 2011 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package html
  5. // Section 12.2.3.2 of the HTML5 specification says "The following elements
  6. // have varying levels of special parsing rules".
  7. // https://html.spec.whatwg.org/multipage/syntax.html#the-stack-of-open-elements
  8. var isSpecialElementMap = map[string]bool{
  9. "address": true,
  10. "applet": true,
  11. "area": true,
  12. "article": true,
  13. "aside": true,
  14. "base": true,
  15. "basefont": true,
  16. "bgsound": true,
  17. "blockquote": true,
  18. "body": true,
  19. "br": true,
  20. "button": true,
  21. "caption": true,
  22. "center": true,
  23. "col": true,
  24. "colgroup": true,
  25. "dd": true,
  26. "details": true,
  27. "dir": true,
  28. "div": true,
  29. "dl": true,
  30. "dt": true,
  31. "embed": true,
  32. "fieldset": true,
  33. "figcaption": true,
  34. "figure": true,
  35. "footer": true,
  36. "form": true,
  37. "frame": true,
  38. "frameset": true,
  39. "h1": true,
  40. "h2": true,
  41. "h3": true,
  42. "h4": true,
  43. "h5": true,
  44. "h6": true,
  45. "head": true,
  46. "header": true,
  47. "hgroup": true,
  48. "hr": true,
  49. "html": true,
  50. "iframe": true,
  51. "img": true,
  52. "input": true,
  53. "isindex": true,
  54. "li": true,
  55. "link": true,
  56. "listing": true,
  57. "marquee": true,
  58. "menu": true,
  59. "meta": true,
  60. "nav": true,
  61. "noembed": true,
  62. "noframes": true,
  63. "noscript": true,
  64. "object": true,
  65. "ol": true,
  66. "p": true,
  67. "param": true,
  68. "plaintext": true,
  69. "pre": true,
  70. "script": true,
  71. "section": true,
  72. "select": true,
  73. "source": true,
  74. "style": true,
  75. "summary": true,
  76. "table": true,
  77. "tbody": true,
  78. "td": true,
  79. "template": true,
  80. "textarea": true,
  81. "tfoot": true,
  82. "th": true,
  83. "thead": true,
  84. "title": true,
  85. "tr": true,
  86. "track": true,
  87. "ul": true,
  88. "wbr": true,
  89. "xmp": true,
  90. }
  91. func isSpecialElement(element *Node) bool {
  92. switch element.Namespace {
  93. case "", "html":
  94. return isSpecialElementMap[element.Data]
  95. case "svg":
  96. return element.Data == "foreignObject"
  97. }
  98. return false
  99. }