PageRenderTime 53ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/tools/drillbit/Resources/tests/ruby/markaby/lib/markaby/tags.rb

http://github.com/appcelerator/titanium_desktop
Ruby | 165 lines | 153 code | 8 blank | 4 comment | 0 complexity | f33f9b008a1ea9e8e45b5b004aab6795 MD5 | raw file
Possible License(s): Apache-2.0
  1. module Markaby
  2. FORM_TAGS = [ :form, :input, :select, :textarea ]
  3. SELF_CLOSING_TAGS = [ :base, :meta, :link, :hr, :br, :param, :img, :area, :input, :col ]
  4. NO_PROXY = [ :hr, :br ]
  5. # Common sets of attributes.
  6. AttrCore = [:id, :class, :style, :title]
  7. AttrI18n = [:lang, 'xml:lang'.intern, :dir]
  8. AttrEvents = [:onclick, :ondblclick, :onmousedown, :onmouseup, :onmouseover, :onmousemove,
  9. :onmouseout, :onkeypress, :onkeydown, :onkeyup]
  10. AttrFocus = [:accesskey, :tabindex, :onfocus, :onblur]
  11. AttrHAlign = [:align, :char, :charoff]
  12. AttrVAlign = [:valign]
  13. Attrs = AttrCore + AttrI18n + AttrEvents
  14. # All the tags and attributes from XHTML 1.0 Strict
  15. class XHTMLStrict
  16. class << self
  17. attr_accessor :tags, :tagset, :forms, :self_closing, :doctype
  18. end
  19. @doctype = ["-//W3C//DTD XHTML 1.0 Strict//EN", "DTD/xhtml1-strict.dtd"]
  20. @tagset = {
  21. :html => AttrI18n + [:id, :xmlns],
  22. :head => AttrI18n + [:id, :profile],
  23. :title => AttrI18n + [:id],
  24. :base => [:href, :id],
  25. :meta => AttrI18n + [:id, :http, :name, :content, :scheme, 'http-equiv'.intern],
  26. :link => Attrs + [:charset, :href, :hreflang, :type, :rel, :rev, :media],
  27. :style => AttrI18n + [:id, :type, :media, :title, 'xml:space'.intern],
  28. :script => [:id, :charset, :type, :src, :defer, 'xml:space'.intern],
  29. :noscript => Attrs,
  30. :body => Attrs + [:onload, :onunload],
  31. :div => Attrs,
  32. :p => Attrs,
  33. :ul => Attrs,
  34. :ol => Attrs,
  35. :li => Attrs,
  36. :dl => Attrs,
  37. :dt => Attrs,
  38. :dd => Attrs,
  39. :address => Attrs,
  40. :hr => Attrs,
  41. :pre => Attrs + ['xml:space'.intern],
  42. :blockquote => Attrs + [:cite],
  43. :ins => Attrs + [:cite, :datetime],
  44. :del => Attrs + [:cite, :datetime],
  45. :a => Attrs + AttrFocus + [:charset, :type, :name, :href, :hreflang, :rel, :rev, :shape, :coords],
  46. :span => Attrs,
  47. :bdo => AttrCore + AttrEvents + [:lang, 'xml:lang'.intern, :dir],
  48. :br => AttrCore,
  49. :em => Attrs,
  50. :strong => Attrs,
  51. :dfn => Attrs,
  52. :code => Attrs,
  53. :samp => Attrs,
  54. :kbd => Attrs,
  55. :var => Attrs,
  56. :cite => Attrs,
  57. :abbr => Attrs,
  58. :acronym => Attrs,
  59. :q => Attrs + [:cite],
  60. :sub => Attrs,
  61. :sup => Attrs,
  62. :tt => Attrs,
  63. :i => Attrs,
  64. :b => Attrs,
  65. :big => Attrs,
  66. :small => Attrs,
  67. :object => Attrs + [:declare, :classid, :codebase, :data, :type, :codetype, :archive, :standby, :height, :width, :usemap, :name, :tabindex],
  68. :param => [:id, :name, :value, :valuetype, :type],
  69. :img => Attrs + [:src, :alt, :longdesc, :height, :width, :usemap, :ismap],
  70. :map => AttrI18n + AttrEvents + [:id, :class, :style, :title, :name],
  71. :area => Attrs + AttrFocus + [:shape, :coords, :href, :nohref, :alt],
  72. :form => Attrs + [:action, :method, :enctype, :onsubmit, :onreset, :accept, :accept],
  73. :label => Attrs + [:for, :accesskey, :onfocus, :onblur],
  74. :input => Attrs + AttrFocus + [:type, :name, :value, :checked, :disabled, :readonly, :size, :maxlength, :src, :alt, :usemap, :onselect, :onchange, :accept],
  75. :select => Attrs + [:name, :size, :multiple, :disabled, :tabindex, :onfocus, :onblur, :onchange],
  76. :optgroup => Attrs + [:disabled, :label],
  77. :option => Attrs + [:selected, :disabled, :label, :value],
  78. :textarea => Attrs + AttrFocus + [:name, :rows, :cols, :disabled, :readonly, :onselect, :onchange],
  79. :fieldset => Attrs,
  80. :legend => Attrs + [:accesskey],
  81. :button => Attrs + AttrFocus + [:name, :value, :type, :disabled],
  82. :table => Attrs + [:summary, :width, :border, :frame, :rules, :cellspacing, :cellpadding],
  83. :caption => Attrs,
  84. :colgroup => Attrs + AttrHAlign + AttrVAlign + [:span, :width],
  85. :col => Attrs + AttrHAlign + AttrVAlign + [:span, :width],
  86. :thead => Attrs + AttrHAlign + AttrVAlign,
  87. :tfoot => Attrs + AttrHAlign + AttrVAlign,
  88. :tbody => Attrs + AttrHAlign + AttrVAlign,
  89. :tr => Attrs + AttrHAlign + AttrVAlign,
  90. :th => Attrs + AttrHAlign + AttrVAlign + [:abbr, :axis, :headers, :scope, :rowspan, :colspan],
  91. :td => Attrs + AttrHAlign + AttrVAlign + [:abbr, :axis, :headers, :scope, :rowspan, :colspan],
  92. :h1 => Attrs,
  93. :h2 => Attrs,
  94. :h3 => Attrs,
  95. :h4 => Attrs,
  96. :h5 => Attrs,
  97. :h6 => Attrs
  98. }
  99. @tags = @tagset.keys
  100. @forms = @tags & FORM_TAGS
  101. @self_closing = @tags & SELF_CLOSING_TAGS
  102. end
  103. # Additional tags found in XHTML 1.0 Transitional
  104. class XHTMLTransitional
  105. class << self
  106. attr_accessor :tags, :tagset, :forms, :self_closing, :doctype
  107. end
  108. @doctype = ["-//W3C//DTD XHTML 1.0 Transitional//EN", "DTD/xhtml1-transitional.dtd"]
  109. @tagset = XHTMLStrict.tagset.merge \
  110. :strike => Attrs,
  111. :center => Attrs,
  112. :dir => Attrs + [:compact],
  113. :noframes => Attrs,
  114. :basefont => [:id, :size, :color, :face],
  115. :u => Attrs,
  116. :menu => Attrs + [:compact],
  117. :iframe => AttrCore + [:longdesc, :name, :src, :frameborder, :marginwidth, :marginheight, :scrolling, :align, :height, :width],
  118. :font => AttrCore + AttrI18n + [:size, :color, :face],
  119. :s => Attrs,
  120. :applet => AttrCore + [:codebase, :archive, :code, :object, :alt, :name, :width, :height, :align, :hspace, :vspace],
  121. :isindex => AttrCore + AttrI18n + [:prompt]
  122. # Additional attributes found in XHTML 1.0 Transitional
  123. { :script => [:language],
  124. :a => [:target],
  125. :td => [:bgcolor, :nowrap, :width, :height],
  126. :p => [:align],
  127. :h5 => [:align],
  128. :h3 => [:align],
  129. :li => [:type, :value],
  130. :div => [:align],
  131. :pre => [:width],
  132. :body => [:background, :bgcolor, :text, :link, :vlink, :alink],
  133. :ol => [:type, :compact, :start],
  134. :h4 => [:align],
  135. :h2 => [:align],
  136. :object => [:align, :border, :hspace, :vspace],
  137. :img => [:name, :align, :border, :hspace, :vspace],
  138. :link => [:target],
  139. :legend => [:align],
  140. :dl => [:compact],
  141. :input => [:align],
  142. :h6 => [:align],
  143. :hr => [:align, :noshade, :size, :width],
  144. :base => [:target],
  145. :ul => [:type, :compact],
  146. :br => [:clear],
  147. :form => [:name, :target],
  148. :area => [:target],
  149. :h1 => [:align]
  150. }.each do |k, v|
  151. @tagset[k] += v
  152. end
  153. @tags = @tagset.keys
  154. @forms = @tags & FORM_TAGS
  155. @self_closing = @tags & SELF_CLOSING_TAGS
  156. end
  157. end