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