const.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. // http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.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. "command": 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. "isindex": true,
  55. "li": true,
  56. "link": true,
  57. "listing": true,
  58. "marquee": true,
  59. "menu": true,
  60. "meta": true,
  61. "nav": true,
  62. "noembed": true,
  63. "noframes": true,
  64. "noscript": true,
  65. "object": true,
  66. "ol": true,
  67. "p": true,
  68. "param": true,
  69. "plaintext": true,
  70. "pre": true,
  71. "script": true,
  72. "section": true,
  73. "select": true,
  74. "style": true,
  75. "summary": true,
  76. "table": true,
  77. "tbody": true,
  78. "td": true,
  79. "textarea": true,
  80. "tfoot": true,
  81. "th": true,
  82. "thead": true,
  83. "title": true,
  84. "tr": true,
  85. "ul": true,
  86. "wbr": true,
  87. "xmp": true,
  88. }
  89. func isSpecialElement(element *Node) bool {
  90. switch element.Namespace {
  91. case "", "html":
  92. return isSpecialElementMap[element.Data]
  93. case "svg":
  94. return element.Data == "foreignObject"
  95. }
  96. return false
  97. }