markaby 0.8.1 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/markaby/tags.rb DELETED
@@ -1,288 +0,0 @@
1
- module Markaby
2
- FORM_TAGS = [ :form, :input, :select, :textarea ]
3
- SELF_CLOSING_TAGS = [:area, :base, :br, :col, :command, :embed, :frame, :hr,
4
- :img, :input, :keygen, :link, :meta, :param, :source,
5
- :track, :wbr]
6
-
7
- # Common sets of attributes.
8
- AttrCore = [:id, :class, :style, :title]
9
- AttrI18n = [:lang, 'xml:lang'.intern, :dir]
10
- AttrEvents = [:onclick,
11
- :ondblclick,
12
- :onmousedown,
13
- :onmouseup,
14
- :onmouseover,
15
- :onmousemove,
16
- :onmouseout,
17
- :onkeypress,
18
- :onkeydown,
19
- :onkeyup]
20
- AttrFocus = [:accesskey, :tabindex, :onfocus, :onblur]
21
- AttrHAlign = [:align, :char, :charoff]
22
- AttrVAlign = [:valign]
23
- Attrs = AttrCore + AttrI18n + AttrEvents
24
-
25
- AttrsBoolean = [
26
- :checked, :disabled, :multiple, :readonly, :selected, # standard forms
27
- :autofocus, :required, :novalidate, :formnovalidate, # HTML5 forms
28
- :defer, :ismap, # <script defer>, <img ismap>
29
- :compact, :declare, :noresize, :noshade, :nowrap # deprecated or unused
30
- ]
31
-
32
- # All the tags and attributes from XHTML 1.0 Strict
33
- class XHTMLStrict
34
- class << self
35
- attr_accessor :tags, :tagset, :forms, :self_closing, :doctype
36
- end
37
-
38
- @doctype = ['-//W3C//DTD XHTML 1.0 Strict//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd']
39
- @tagset = {
40
- :html => AttrI18n + [:id, :xmlns],
41
- :head => AttrI18n + [:id, :profile],
42
- :title => AttrI18n + [:id],
43
- :base => [:href, :id],
44
- :meta => AttrI18n + [:id, :http, :name, :content, :scheme, 'http-equiv'.intern],
45
- :link => Attrs + [:charset, :href, :hreflang, :type, :rel, :rev, :media],
46
- :style => AttrI18n + [:id, :type, :media, :title, 'xml:space'.intern],
47
- :script => [:id, :charset, :type, :src, :defer, 'xml:space'.intern],
48
- :noscript => Attrs,
49
- :body => Attrs + [:onload, :onunload],
50
- :div => Attrs,
51
- :p => Attrs,
52
- :ul => Attrs,
53
- :ol => Attrs,
54
- :li => Attrs,
55
- :dl => Attrs,
56
- :dt => Attrs,
57
- :dd => Attrs,
58
- :address => Attrs,
59
- :hr => Attrs,
60
- :pre => Attrs + ['xml:space'.intern],
61
- :blockquote => Attrs + [:cite],
62
- :ins => Attrs + [:cite, :datetime],
63
- :del => Attrs + [:cite, :datetime],
64
- :a => Attrs + AttrFocus + [:charset, :type, :name, :href, :hreflang, :rel, :rev, :shape, :coords],
65
- :span => Attrs,
66
- :bdo => AttrCore + AttrEvents + [:lang, 'xml:lang'.intern, :dir],
67
- :br => AttrCore,
68
- :em => Attrs,
69
- :strong => Attrs,
70
- :dfn => Attrs,
71
- :code => Attrs,
72
- :samp => Attrs,
73
- :kbd => Attrs,
74
- :var => Attrs,
75
- :cite => Attrs,
76
- :abbr => Attrs,
77
- :acronym => Attrs,
78
- :q => Attrs + [:cite],
79
- :sub => Attrs,
80
- :sup => Attrs,
81
- :tt => Attrs,
82
- :i => Attrs,
83
- :b => Attrs,
84
- :big => Attrs,
85
- :small => Attrs,
86
- :object => Attrs + [:declare, :classid, :codebase, :data, :type, :codetype, :archive, :standby, :height, :width, :usemap, :name, :tabindex],
87
- :param => [:id, :name, :value, :valuetype, :type],
88
- :img => Attrs + [:src, :alt, :longdesc, :height, :width, :usemap, :ismap],
89
- :map => AttrI18n + AttrEvents + [:id, :class, :style, :title, :name],
90
- :area => Attrs + AttrFocus + [:shape, :coords, :href, :nohref, :alt],
91
- :form => Attrs + [:action, :method, :enctype, :onsubmit, :onreset, :accept, :accept],
92
- :label => Attrs + [:for, :accesskey, :onfocus, :onblur],
93
- :input => Attrs + AttrFocus + [:type, :name, :value, :checked, :disabled, :readonly, :size, :maxlength, :src, :alt, :usemap, :onselect, :onchange, :accept],
94
- :select => Attrs + [:name, :size, :multiple, :disabled, :tabindex, :onfocus, :onblur, :onchange],
95
- :optgroup => Attrs + [:disabled, :label],
96
- :option => Attrs + [:selected, :disabled, :label, :value],
97
- :textarea => Attrs + AttrFocus + [:name, :rows, :cols, :disabled, :readonly, :onselect, :onchange],
98
- :fieldset => Attrs,
99
- :legend => Attrs + [:accesskey],
100
- :button => Attrs + AttrFocus + [:name, :value, :type, :disabled],
101
- :table => Attrs + [:summary, :width, :border, :frame, :rules, :cellspacing, :cellpadding],
102
- :caption => Attrs,
103
- :colgroup => Attrs + AttrHAlign + AttrVAlign + [:span, :width],
104
- :col => Attrs + AttrHAlign + AttrVAlign + [:span, :width],
105
- :thead => Attrs + AttrHAlign + AttrVAlign,
106
- :tfoot => Attrs + AttrHAlign + AttrVAlign,
107
- :tbody => Attrs + AttrHAlign + AttrVAlign,
108
- :tr => Attrs + AttrHAlign + AttrVAlign,
109
- :th => Attrs + AttrHAlign + AttrVAlign + [:abbr, :axis, :headers, :scope, :rowspan, :colspan],
110
- :td => Attrs + AttrHAlign + AttrVAlign + [:abbr, :axis, :headers, :scope, :rowspan, :colspan],
111
- :h1 => Attrs,
112
- :h2 => Attrs,
113
- :h3 => Attrs,
114
- :h4 => Attrs,
115
- :h5 => Attrs,
116
- :h6 => Attrs
117
- }
118
-
119
- @tags = @tagset.keys
120
- @forms = @tags & FORM_TAGS
121
- @self_closing = @tags & SELF_CLOSING_TAGS
122
- end
123
-
124
- # Additional tags found in XHTML 1.0 Transitional
125
- class XHTMLTransitional
126
- class << self
127
- attr_accessor :tags, :tagset, :forms, :self_closing, :doctype
128
- end
129
-
130
- @doctype = ['-//W3C//DTD XHTML 1.0 Transitional//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd']
131
- @tagset = XHTMLStrict.tagset.merge({
132
- :strike => Attrs,
133
- :center => Attrs,
134
- :dir => Attrs + [:compact],
135
- :noframes => Attrs,
136
- :basefont => [:id, :size, :color, :face],
137
- :u => Attrs,
138
- :menu => Attrs + [:compact],
139
- :iframe => AttrCore + [:longdesc, :name, :src, :frameborder, :marginwidth, :marginheight, :scrolling, :align, :height, :width],
140
- :font => AttrCore + AttrI18n + [:size, :color, :face],
141
- :s => Attrs,
142
- :applet => AttrCore + [:codebase, :archive, :code, :object, :alt, :name, :width, :height, :align, :hspace, :vspace],
143
- :isindex => AttrCore + AttrI18n + [:prompt]
144
- })
145
-
146
- # Additional attributes found in XHTML 1.0 Transitional
147
- additional_tags = {
148
- :script => [:language],
149
- :a => [:target],
150
- :td => [:bgcolor, :nowrap, :width, :height],
151
- :p => [:align],
152
- :h5 => [:align],
153
- :h3 => [:align],
154
- :li => [:type, :value],
155
- :div => [:align],
156
- :pre => [:width],
157
- :body => [:background, :bgcolor, :text, :link, :vlink, :alink],
158
- :ol => [:type, :compact, :start],
159
- :h4 => [:align],
160
- :h2 => [:align],
161
- :object => [:align, :border, :hspace, :vspace],
162
- :img => [:name, :align, :border, :hspace, :vspace],
163
- :link => [:target],
164
- :legend => [:align],
165
- :dl => [:compact],
166
- :input => [:align],
167
- :h6 => [:align],
168
- :hr => [:align, :noshade, :size, :width],
169
- :base => [:target],
170
- :ul => [:type, :compact],
171
- :br => [:clear],
172
- :form => [:name, :target],
173
- :area => [:target],
174
- :h1 => [:align]
175
- }
176
-
177
- additional_tags.each do |k, v|
178
- @tagset[k] += v
179
- end
180
-
181
- @tags = @tagset.keys
182
- @forms = @tags & FORM_TAGS
183
- @self_closing = @tags & SELF_CLOSING_TAGS
184
- end
185
-
186
- # Additional tags found in XHTML 1.0 Frameset
187
- class XHTMLFrameset
188
- class << self
189
- attr_accessor :tags, :tagset, :forms, :self_closing, :doctype
190
- end
191
-
192
- @doctype = ['-//W3C//DTD XHTML 1.0 Frameset//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd']
193
- @tagset = XHTMLTransitional.tagset.merge({
194
- :frameset => AttrCore + [:rows, :cols, :onload, :onunload],
195
- :frame => AttrCore + [:longdesc, :name, :src, :frameborder, :marginwidth, :marginheight, :noresize, :scrolling]
196
- })
197
-
198
- @tags = @tagset.keys
199
- @forms = @tags & FORM_TAGS
200
- @self_closing = @tags & SELF_CLOSING_TAGS
201
- end
202
-
203
- class HTML5
204
- class << self
205
- attr_accessor :tags, :tagset, :forms, :self_closing, :doctype
206
- end
207
-
208
- @doctype = ['html']
209
- @tagset = XHTMLTransitional.tagset.merge({
210
- :abbr => Attrs,
211
- :article => Attrs,
212
- :aside => Attrs,
213
- :audio => Attrs,
214
- :bdi => Attrs,
215
- :canvas => Attrs,
216
- :command => Attrs,
217
- :datalist => Attrs,
218
- :details => Attrs,
219
- :embed => Attrs,
220
- :figure => Attrs,
221
- :figcaption => Attrs,
222
- :footer => Attrs,
223
- :header => Attrs,
224
- :hgroup => Attrs,
225
- :keygen => Attrs,
226
- :mark => Attrs,
227
- :menu => Attrs,
228
- :meter => Attrs,
229
- :nav => Attrs,
230
- :output => Attrs,
231
- :progress => Attrs,
232
- :rp => Attrs,
233
- :rt => Attrs,
234
- :ruby => Attrs,
235
- :section => Attrs,
236
- :source => Attrs,
237
- :time => Attrs,
238
- :track => Attrs,
239
- :video => Attrs,
240
- :wbr => Attrs
241
- })
242
-
243
- # Additional attributes found in HTML5
244
- additional_tags = {
245
- :a => [:media, :download, :ping],
246
- :area => [:media, :download, :ping, :hreflang, :rel, :type],
247
- :base => [:target],
248
- :button => [:autofocus, :form, :formaction, :formenctype, :formmethod,
249
- :formnovalidate, :formtarget],
250
- :fieldset => [:form, :disabled, :name],
251
- :form => [:novalidate],
252
- :label => [:form],
253
- :html => [:manifest],
254
- :iframe => [:sandbox, :seamless, :srcdoc],
255
- :img => [:crossorigin],
256
- :input => [:autofocus, :placeholder, :form, :required, :autocomplete,
257
- :min, :max, :multiple, :pattern, :step, :list, :width, :height,
258
- :dirname, :formaction, :formenctype, :formmethod,
259
- :formnovalidate, :formtarget],
260
- :link => [:sizes],
261
- :meta => [:charset],
262
- :menu => [:type, :label],
263
- :object => [:form, :typemustmatch],
264
- :ol => [:reversed],
265
- :output => [:form],
266
- :script => [:async],
267
- :select => [:autofocus, :form, :required],
268
- :style => [:scoped],
269
- :textarea => [:autofocus, :placeholder, :form, :required, :dirname,
270
- :maxlength, :wrap],
271
- }
272
-
273
- AttrsHTML5 = [:contenteditable, :contextmentu, :draggable, :dropzone,
274
- :hidden, :role, :spellcheck, :translate]
275
-
276
- additional_tags.each do |k, v|
277
- @tagset[k] += v
278
- end
279
-
280
- @tagset.each do |k, v|
281
- @tagset[k] += AttrsHTML5
282
- end
283
-
284
- @tags = @tagset.keys
285
- @forms = @tags & FORM_TAGS
286
- @self_closing = @tags & SELF_CLOSING_TAGS
287
- end
288
- end