You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

131 lines
4.1 KiB

4 years ago
  1. # FIXME: this should all be confirmed against what a DTD says
  2. # (probably in a test; this may not match the DTD exactly, but we
  3. # should document just how it differs).
  4. # Data taken from http://www.w3.org/TR/html401/index/elements.html
  5. # and http://www.w3.org/community/webed/wiki/HTML/New_HTML5_Elements
  6. # for html5_tags.
  7. empty_tags = frozenset([
  8. 'area', 'base', 'basefont', 'br', 'col', 'frame', 'hr',
  9. 'img', 'input', 'isindex', 'link', 'meta', 'param'])
  10. deprecated_tags = frozenset([
  11. 'applet', 'basefont', 'center', 'dir', 'font', 'isindex',
  12. 'menu', 's', 'strike', 'u'])
  13. # archive actually takes a space-separated list of URIs
  14. link_attrs = frozenset([
  15. 'action', 'archive', 'background', 'cite', 'classid',
  16. 'codebase', 'data', 'href', 'longdesc', 'profile', 'src',
  17. 'usemap',
  18. # Not standard:
  19. 'dynsrc', 'lowsrc',
  20. ])
  21. # Not in the HTML 4 spec:
  22. # onerror, onresize
  23. event_attrs = frozenset([
  24. 'onblur', 'onchange', 'onclick', 'ondblclick', 'onerror',
  25. 'onfocus', 'onkeydown', 'onkeypress', 'onkeyup', 'onload',
  26. 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover',
  27. 'onmouseup', 'onreset', 'onresize', 'onselect', 'onsubmit',
  28. 'onunload',
  29. ])
  30. safe_attrs = frozenset([
  31. 'abbr', 'accept', 'accept-charset', 'accesskey', 'action', 'align',
  32. 'alt', 'axis', 'border', 'cellpadding', 'cellspacing', 'char', 'charoff',
  33. 'charset', 'checked', 'cite', 'class', 'clear', 'cols', 'colspan',
  34. 'color', 'compact', 'coords', 'datetime', 'dir', 'disabled', 'enctype',
  35. 'for', 'frame', 'headers', 'height', 'href', 'hreflang', 'hspace', 'id',
  36. 'ismap', 'label', 'lang', 'longdesc', 'maxlength', 'media', 'method',
  37. 'multiple', 'name', 'nohref', 'noshade', 'nowrap', 'prompt', 'readonly',
  38. 'rel', 'rev', 'rows', 'rowspan', 'rules', 'scope', 'selected', 'shape',
  39. 'size', 'span', 'src', 'start', 'summary', 'tabindex', 'target', 'title',
  40. 'type', 'usemap', 'valign', 'value', 'vspace', 'width'])
  41. # From http://htmlhelp.com/reference/html40/olist.html
  42. top_level_tags = frozenset([
  43. 'html', 'head', 'body', 'frameset',
  44. ])
  45. head_tags = frozenset([
  46. 'base', 'isindex', 'link', 'meta', 'script', 'style', 'title',
  47. ])
  48. general_block_tags = frozenset([
  49. 'address',
  50. 'blockquote',
  51. 'center',
  52. 'del',
  53. 'div',
  54. 'h1',
  55. 'h2',
  56. 'h3',
  57. 'h4',
  58. 'h5',
  59. 'h6',
  60. 'hr',
  61. 'ins',
  62. 'isindex',
  63. 'noscript',
  64. 'p',
  65. 'pre',
  66. ])
  67. list_tags = frozenset([
  68. 'dir', 'dl', 'dt', 'dd', 'li', 'menu', 'ol', 'ul',
  69. ])
  70. table_tags = frozenset([
  71. 'table', 'caption', 'colgroup', 'col',
  72. 'thead', 'tfoot', 'tbody', 'tr', 'td', 'th',
  73. ])
  74. # just this one from
  75. # http://www.georgehernandez.com/h/XComputers/HTML/2BlockLevel.htm
  76. block_tags = general_block_tags | list_tags | table_tags | frozenset([
  77. # Partial form tags
  78. 'fieldset', 'form', 'legend', 'optgroup', 'option',
  79. ])
  80. form_tags = frozenset([
  81. 'form', 'button', 'fieldset', 'legend', 'input', 'label',
  82. 'select', 'optgroup', 'option', 'textarea',
  83. ])
  84. special_inline_tags = frozenset([
  85. 'a', 'applet', 'basefont', 'bdo', 'br', 'embed', 'font', 'iframe',
  86. 'img', 'map', 'area', 'object', 'param', 'q', 'script',
  87. 'span', 'sub', 'sup',
  88. ])
  89. phrase_tags = frozenset([
  90. 'abbr', 'acronym', 'cite', 'code', 'del', 'dfn', 'em',
  91. 'ins', 'kbd', 'samp', 'strong', 'var',
  92. ])
  93. font_style_tags = frozenset([
  94. 'b', 'big', 'i', 's', 'small', 'strike', 'tt', 'u',
  95. ])
  96. frame_tags = frozenset([
  97. 'frameset', 'frame', 'noframes',
  98. ])
  99. html5_tags = frozenset([
  100. 'article', 'aside', 'audio', 'canvas', 'command', 'datalist',
  101. 'details', 'embed', 'figcaption', 'figure', 'footer', 'header',
  102. 'hgroup', 'keygen', 'mark', 'math', 'meter', 'nav', 'output',
  103. 'progress', 'rp', 'rt', 'ruby', 'section', 'source', 'summary',
  104. 'svg', 'time', 'track', 'video', 'wbr'
  105. ])
  106. # These tags aren't standard
  107. nonstandard_tags = frozenset(['blink', 'marquee'])
  108. tags = (top_level_tags | head_tags | general_block_tags | list_tags
  109. | table_tags | form_tags | special_inline_tags | phrase_tags
  110. | font_style_tags | nonstandard_tags | html5_tags)