html_tags 0.1.120

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of html_tags might be problematic. Click here for more details.

Files changed (86) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +110 -0
  3. data/USAGE.md +17 -0
  4. data/doc/README.gen +69 -0
  5. data/html_tags.gemspec +53 -0
  6. data/lib/html_tags/array_registered_html_tags.rb +125 -0
  7. data/lib/html_tags/autoinclude.rb +2 -0
  8. data/lib/html_tags/autoinclude_base_module.rb +7 -0
  9. data/lib/html_tags/base/README.md +3 -0
  10. data/lib/html_tags/base/base.rb +11 -0
  11. data/lib/html_tags/base/base_module.rb +224 -0
  12. data/lib/html_tags/base/prototype.rb +19 -0
  13. data/lib/html_tags/checks.rb +58 -0
  14. data/lib/html_tags/closing_tag/closing_tag.rb +76 -0
  15. data/lib/html_tags/constants/array_strip_newlines.rb +14 -0
  16. data/lib/html_tags/constants/misc.rb +21 -0
  17. data/lib/html_tags/constants.rb +26 -0
  18. data/lib/html_tags/html_closing_tags.rb +36 -0
  19. data/lib/html_tags/html_comment.rb +29 -0
  20. data/lib/html_tags/html_tags.rb +131 -0
  21. data/lib/html_tags/html_tags_constants.rb +14 -0
  22. data/lib/html_tags/individual_tags/a.rb +524 -0
  23. data/lib/html_tags/individual_tags/abbr.rb +44 -0
  24. data/lib/html_tags/individual_tags/audio.rb +32 -0
  25. data/lib/html_tags/individual_tags/b.rb +22 -0
  26. data/lib/html_tags/individual_tags/blockquote.rb +19 -0
  27. data/lib/html_tags/individual_tags/body.rb +19 -0
  28. data/lib/html_tags/individual_tags/br.rb +28 -0
  29. data/lib/html_tags/individual_tags/button.rb +30 -0
  30. data/lib/html_tags/individual_tags/canvas.rb +19 -0
  31. data/lib/html_tags/individual_tags/details.rb +69 -0
  32. data/lib/html_tags/individual_tags/div.rb +51 -0
  33. data/lib/html_tags/individual_tags/figure.rb +39 -0
  34. data/lib/html_tags/individual_tags/footer.rb +26 -0
  35. data/lib/html_tags/individual_tags/form.rb +93 -0
  36. data/lib/html_tags/individual_tags/h1.rb +36 -0
  37. data/lib/html_tags/individual_tags/h2.rb +42 -0
  38. data/lib/html_tags/individual_tags/h3.rb +73 -0
  39. data/lib/html_tags/individual_tags/h4.rb +36 -0
  40. data/lib/html_tags/individual_tags/h5.rb +36 -0
  41. data/lib/html_tags/individual_tags/h6.rb +40 -0
  42. data/lib/html_tags/individual_tags/head.rb +36 -0
  43. data/lib/html_tags/individual_tags/header.rb +29 -0
  44. data/lib/html_tags/individual_tags/html.rb +61 -0
  45. data/lib/html_tags/individual_tags/i.rb +14 -0
  46. data/lib/html_tags/individual_tags/img.rb +135 -0
  47. data/lib/html_tags/individual_tags/input.rb +32 -0
  48. data/lib/html_tags/individual_tags/label.rb +43 -0
  49. data/lib/html_tags/individual_tags/legend.rb +14 -0
  50. data/lib/html_tags/individual_tags/li.rb +44 -0
  51. data/lib/html_tags/individual_tags/main.rb +29 -0
  52. data/lib/html_tags/individual_tags/nav.rb +14 -0
  53. data/lib/html_tags/individual_tags/object.rb +18 -0
  54. data/lib/html_tags/individual_tags/ol.rb +50 -0
  55. data/lib/html_tags/individual_tags/p.rb +50 -0
  56. data/lib/html_tags/individual_tags/pre.rb +16 -0
  57. data/lib/html_tags/individual_tags/span.rb +60 -0
  58. data/lib/html_tags/individual_tags/strong.rb +17 -0
  59. data/lib/html_tags/individual_tags/style.rb +29 -0
  60. data/lib/html_tags/individual_tags/table.rb +33 -0
  61. data/lib/html_tags/individual_tags/tbody.rb +19 -0
  62. data/lib/html_tags/individual_tags/td.rb +24 -0
  63. data/lib/html_tags/individual_tags/textarea.rb +46 -0
  64. data/lib/html_tags/individual_tags/th.rb +14 -0
  65. data/lib/html_tags/individual_tags/thead.rb +14 -0
  66. data/lib/html_tags/individual_tags/title.rb +18 -0
  67. data/lib/html_tags/individual_tags/tr.rb +20 -0
  68. data/lib/html_tags/individual_tags/ul.rb +23 -0
  69. data/lib/html_tags/individual_tags/video.rb +54 -0
  70. data/lib/html_tags/module.rb +5 -0
  71. data/lib/html_tags/opening_tag/opening_tag.rb +288 -0
  72. data/lib/html_tags/project/project_base_directory.rb +23 -0
  73. data/lib/html_tags/requires/require_the_html_tags_project.rb +9 -0
  74. data/lib/html_tags/requires/require_the_img_tag.rb +7 -0
  75. data/lib/html_tags/shared.rb +23 -0
  76. data/lib/html_tags/stag.rb +54 -0
  77. data/lib/html_tags/toplevel_methods/add.rb +22 -0
  78. data/lib/html_tags/toplevel_methods/full_output.rb +33 -0
  79. data/lib/html_tags/toplevel_methods/newline_or_empty.rb +21 -0
  80. data/lib/html_tags/toplevel_methods/strip_newlines.rb +27 -0
  81. data/lib/html_tags/version/version.rb +17 -0
  82. data/lib/html_tags/yaml/valid_tags_in_a_head_tag.yml +16 -0
  83. data/lib/html_tags.rb +5 -0
  84. data/test/testing_html_tags.rb +158 -0
  85. data/test/testing_the_a_tag.rb +113 -0
  86. metadata +141 -0
@@ -0,0 +1,524 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'html_tags/individual_tags/a.rb'
6
+ # =========================================================================== #
7
+ module HtmlTags
8
+
9
+ require 'html_tags/closing_tag/closing_tag.rb'
10
+ require 'html_tags/toplevel_methods/add.rb'
11
+
12
+ # ========================================================================= #
13
+ # === HtmlTags.a (a tag)
14
+ #
15
+ # This tag will attempt to create a HTML link. It follows all other
16
+ # conventions as well. The first argument called `i` is the target
17
+ # URL to use.
18
+ #
19
+ # In plain HTML, this would be create a string such as the following one:
20
+ #
21
+ # <a href="url">Test</a>
22
+ #
23
+ # The first argument `i` is the hyperref-target.
24
+ #
25
+ # Usage examples:
26
+ #
27
+ # a('connect')
28
+ # a('connect', :make_newline)
29
+ # a('connect', 'marl1em','great_link','color: blue')
30
+ # a('LINUX_DESIGNING.cgi', :copy_description)
31
+ # a('https://de.wikipedia.org/wiki/Lampensockel#Edisonsockel', 'SELF', :make_newline)
32
+ # a('local_ruby_c', description: 'Ruby C Seite', css_style: 'margin-left: 2em')
33
+ # a(
34
+ # remote_url: remote_url,
35
+ # text: title?.to_s,
36
+ # css_style: 'font-weight: bold; color: darkblue'
37
+ # )
38
+ #
39
+ # ========================================================================= #
40
+ def self.a(
41
+ hyperref_target = '',
42
+ link_description = :use_hyperref_as_the_target,
43
+ css_class = '',
44
+ the_id = '',
45
+ css_style = '',
46
+ javascript = ''
47
+ )
48
+ # ======================================================================= #
49
+ # The following Hash can be used to store data into, such as :tooltip.
50
+ # ======================================================================= #
51
+ internal_hash = {}
52
+ # ======================================================================= #
53
+ # Store the generated String in the local variable called result.
54
+ # ======================================================================= #
55
+ result = ''.dup
56
+ # ======================================================================= #
57
+ # If make_newline is set to true then we will append a <br> tag.
58
+ # ======================================================================= #
59
+ make_newline = false
60
+ close_me = close(__method__) # Default. Must come before case css_class.
61
+ # ======================================================================= #
62
+ # Since as of December 2015 we will check whether we have passed an
63
+ # Array.
64
+ #
65
+ # This may look like that way:
66
+ #
67
+ # ["https://de.wikipedia.org/wiki/Lampensockel#Edisonsockel",
68
+ # {:content=>"SELF", :css_class=>"mars2em"}]
69
+ #
70
+ # or
71
+ #
72
+ # ["http://geizhals.at/philips-voice-tracer-dvt3600-digitales-diktiergeraet-a992644.html?hloc=at", "SELF", 1]
73
+ #
74
+ # So we have to stay flexible here.
75
+ # ======================================================================= #
76
+ if hyperref_target.is_a? Array
77
+ if hyperref_target.size > 1
78
+ hash = hyperref_target[1] # This may not have to be a Hash, though.
79
+ if hash.is_a? Hash
80
+ link_description = hash
81
+ hyperref_target = hyperref_target[0]
82
+ elsif hash.is_a? Array
83
+ if hash[1]
84
+ link_description = hash[1]
85
+ end
86
+ if hash[2] and (hash[2] == 1)
87
+ make_newline = true
88
+ end
89
+ # ================================================================= #
90
+ # Finally, assign the first entry to hyperref_target.
91
+ # ================================================================= #
92
+ hyperref_target = hyperref_target.first
93
+ end
94
+ end
95
+ if hyperref_target.is_a? Array
96
+ hyperref_target = hyperref_target.first
97
+ end
98
+ end
99
+ case css_class
100
+ # ======================================================================= #
101
+ # === :copy_description
102
+ # ======================================================================= #
103
+ when :copy_description
104
+ css_class = ''
105
+ link_description = hyperref_target
106
+ # ======================================================================= #
107
+ # === :make_newline
108
+ # ======================================================================= #
109
+ when :make_newline
110
+ css_class = ''
111
+ close_me = close(__method__) {{ make_newline: true }}
112
+ # ======================================================================= #
113
+ # === :no_newline
114
+ # ======================================================================= #
115
+ when :no_newline
116
+ css_class = ''
117
+ close_me = close(__method__) {{ make_newline: false }}
118
+ else # Else do not make a newline, simply pass through..
119
+ end
120
+ # ======================================================================= #
121
+ # === Check for hyperref_target being a Hash
122
+ # ======================================================================= #
123
+ if hyperref_target.is_a? Hash
124
+ # ===================================================================== #
125
+ # === :link_description
126
+ # ===================================================================== #
127
+ if hyperref_target.has_key? :link_description
128
+ link_description = hyperref_target.delete(:link_description)
129
+ # ===================================================================== #
130
+ # === :description
131
+ # ===================================================================== #
132
+ elsif hyperref_target.has_key? :description
133
+ link_description = hyperref_target.delete(:description)
134
+ end
135
+ # ===================================================================== #
136
+ # === :id
137
+ # ===================================================================== #
138
+ if hyperref_target.has_key? :id
139
+ the_id = hyperref_target.delete(:id)
140
+ # ===================================================================== #
141
+ # === :the_id
142
+ # ===================================================================== #
143
+ elsif hyperref_target.has_key? :the_id
144
+ the_id = hyperref_target.delete(:the_id)
145
+ end
146
+ # ===================================================================== #
147
+ # === :make_newline
148
+ # ===================================================================== #
149
+ if hyperref_target.has_key? :make_newline
150
+ make_newline = hyperref_target.delete(:make_newline)
151
+ # ===================================================================== #
152
+ # === :linebreak
153
+ # ===================================================================== #
154
+ elsif hyperref_target.has_key? :linebreak
155
+ make_newline = hyperref_target.delete(:linebreak)
156
+ end
157
+ # ===================================================================== #
158
+ # === :css_class
159
+ #
160
+ # Handle :css_class early on, as it is a very unproblematic entry.
161
+ # ===================================================================== #
162
+ if hyperref_target.has_key? :css_class
163
+ css_class = hyperref_target.delete(:css_class)
164
+ end
165
+ # ===================================================================== #
166
+ # === :css_style
167
+ #
168
+ # This entry point allows us to handle css-styles for a given
169
+ # HTML tag.
170
+ # ===================================================================== #
171
+ if hyperref_target.has_key? :css_style
172
+ css_style = hyperref_target.delete(:css_style)
173
+ end
174
+ # ===================================================================== #
175
+ # === :content
176
+ #
177
+ # Rewrite :content to the more correctly named :link_description.
178
+ # ===================================================================== #
179
+ if hyperref_target.has_key? :content
180
+ link_description = hyperref_target.delete(:content)
181
+ # ===================================================================== #
182
+ # === :text
183
+ # ===================================================================== #
184
+ elsif hyperref_target.has_key? :text
185
+ link_description = hyperref_target.delete(:text)
186
+ end
187
+ # ===================================================================== #
188
+ # === :link_description
189
+ #
190
+ # This entry point ought to come last.
191
+ # ===================================================================== #
192
+ if hyperref_target.has_key?(:link_description) and
193
+ (hyperref_target[:link_description] == 'SELF')
194
+ link_description = hyperref_target.delete(:link_description)
195
+ end
196
+ # ===================================================================== #
197
+ # The next two checks should come last, since they will modify
198
+ # hyperref_target.
199
+ # ===================================================================== #
200
+ # ===================================================================== #
201
+ # === :remote_url
202
+ # ===================================================================== #
203
+ if hyperref_target.has_key? :remote_url
204
+ hyperref_target = hyperref_target.delete(:remote_url)
205
+ # ===================================================================== #
206
+ # === :href
207
+ # ===================================================================== #
208
+ elsif hyperref_target.has_key? :href
209
+ hyperref_target = hyperref_target.delete(:href)
210
+ end if hyperref_target.is_a?(Hash)
211
+ end
212
+ # ======================================================================= #
213
+ # === Intercept Hash for the link_description variable
214
+ #
215
+ # The hash can contain entries such as linebreak: true, but also
216
+ # entries such as content: :self.
217
+ # ======================================================================= #
218
+ if link_description.is_a? Hash
219
+ # ===================================================================== #
220
+ # === :tooltip
221
+ # ===================================================================== #
222
+ if link_description.has_key? :tooltip
223
+ internal_hash[:tooltip] = link_description.delete(:tooltip)
224
+ end
225
+ # ===================================================================== #
226
+ # === :onclick
227
+ #
228
+ # This may look like so:
229
+ #
230
+ # onclick: 'change_the_colour_to()'
231
+ #
232
+ # ===================================================================== #
233
+ if link_description.has_key? :onclick
234
+ javascript = ' onclick="'+link_description.delete(:onclick)+'"'
235
+ end
236
+ # ===================================================================== #
237
+ # === :css_style
238
+ # ===================================================================== #
239
+ if link_description.has_key? :css_style
240
+ css_style = link_description.delete(:css_style)
241
+ end
242
+ # ===================================================================== #
243
+ # === :id
244
+ # ===================================================================== #
245
+ if link_description.has_key? :id
246
+ the_id = link_description.delete(:id)
247
+ # ===================================================================== #
248
+ # === :the_id
249
+ # ===================================================================== #
250
+ elsif link_description.has_key? :the_id
251
+ the_id = link_description.delete(:the_id)
252
+ end
253
+ # ===================================================================== #
254
+ # === css_class
255
+ # ===================================================================== #
256
+ if link_description.has_key? :css_class
257
+ css_class = link_description.delete(:css_class)
258
+ end
259
+ # ===================================================================== #
260
+ # Rewrite :link_description into :description.
261
+ # ===================================================================== #
262
+ if link_description.has_key? :description
263
+ link_description = link_description.delete(:description)
264
+ # ===================================================================== #
265
+ # Rewrite :link_description into :link_description.
266
+ # ===================================================================== #
267
+ elsif link_description.has_key? :link_description
268
+ link_description = link_description.delete(:link_description)
269
+ # ===================================================================== #
270
+ # Rewrite :title into :description.
271
+ #
272
+ # This entry point is for input such as:
273
+ #
274
+ # a('http://rubyreports.org/', title: 'Ruport')
275
+ #
276
+ # ===================================================================== #
277
+ elsif link_description.has_key? :title
278
+ link_description = link_description.delete :title
279
+ # ===================================================================== #
280
+ # === :content
281
+ #
282
+ # Rewrite :content into :link_description.
283
+ #
284
+ # This entry point is for input such as:
285
+ #
286
+ # a('http://rubyreports.org/', content: '<b>Link</b>')
287
+ #
288
+ # ===================================================================== #
289
+ elsif link_description.has_key? :content
290
+ link_description = link_description.delete(:content).to_s
291
+ if link_description and link_description.start_with?('→ ')
292
+ hyperref_target.sub!(/^→ /,'')
293
+ end
294
+ # =================================================================== #
295
+ # Next, we must both check for 'SELF' 'self', second variant
296
+ # could also be the Symbol :self.
297
+ # =================================================================== #
298
+ if link_description.include?('SELF') or (link_description.to_s == 'self')
299
+ if link_description.frozen?
300
+ link_description = link_description.dup
301
+ end
302
+ # ================================================================= #
303
+ # Must replace it with the proper target next.
304
+ # ================================================================= #
305
+ link_description = link_description.to_s.sub( # Ensure we have a String.
306
+ /^SELF/i, hyperref_target
307
+ )
308
+ end
309
+ else
310
+ # =================================================================== #
311
+ # We don't have a link_description entry, so we will simply use
312
+ # the value from hyperref_target..
313
+ # =================================================================== #
314
+ if link_description.is_a?(Hash) and link_description.empty?
315
+ link_description = hyperref_target.to_s.dup
316
+ end
317
+ end
318
+ # ===================================================================== #
319
+ # ==== :content
320
+ #
321
+ # This should come last, since it will overwrite link_description.
322
+ # ===================================================================== #
323
+ if link_description.is_a?(Hash) and
324
+ link_description.has_key?(:content)
325
+ link_description = link_description.delete(:content)
326
+ end
327
+ end
328
+ # ======================================================================= #
329
+ # Work on link_description next, assuming it is a String at this point.
330
+ # ======================================================================= #
331
+ case link_description.to_s
332
+ when /^→ / # If it starts with a right-arrow.
333
+ if link_description.to_s == :self
334
+ link_description = hyperref_target.dup.sub(/^→ /,'')
335
+ end
336
+ when /^SELF$/i
337
+ link_description = link_description.dup if link_description.frozen?
338
+ link_description = link_description.to_s.sub!(
339
+ /^SELF/i, hyperref_target.dup # .sub(/^→ /,'')
340
+ )
341
+ end
342
+ case hyperref_target
343
+ # Remove leading right-arrows.
344
+ when /^→ /
345
+ hyperref_target = hyperref_target.dup if hyperref_target.frozen?
346
+ hyperref_target.sub!(/^→ /,'')
347
+ end
348
+ # ======================================================================= #
349
+ # === :make_newline is treated in a special manner, as the id.
350
+ # Same for the number 1, which stands for newline too, due
351
+ # to historic reasons.
352
+ # ======================================================================= #
353
+ case the_id
354
+ when :make_newline, 1
355
+ make_newline = true
356
+ the_id = '' # Reset it here in this case.
357
+ end
358
+ if css_class and css_class.is_a?(String) and (css_class == 'SELF')
359
+ css_class = ''.dup
360
+ end
361
+ if css_class.is_a? Hash
362
+ # ===================================================================== #
363
+ # === Intercept key :css_style next, on the css_class variable
364
+ #
365
+ # This entry point is for input such as:
366
+ #
367
+ # a(@target, css_style: 'color:red; margin-left:2em')
368
+ #
369
+ # ===================================================================== #
370
+ if css_class.has_key? :css_style
371
+ css_style = css_class.delete :css_style
372
+ end if css_class.is_a? Hash # Must check again due to the earlier resetting.
373
+ # ===================================================================== #
374
+ # === Intercept key :css_class next
375
+ # ===================================================================== #
376
+ if css_class.has_key? :css_class
377
+ # =================================================================== #
378
+ # Must assign to css_class variable in this case:
379
+ # =================================================================== #
380
+ css_class = css_class.delete :css_class
381
+ end if css_class.is_a? Hash # See above explanation.
382
+ # ===================================================================== #
383
+ # === Intercept key :url next
384
+ # ===================================================================== #
385
+ if css_class.has_key? :url
386
+ i = css_class.delete :url
387
+ end if css_class.is_a? Hash # See above explanation.
388
+ # ===================================================================== #
389
+ # === Intercept key :linebreak next
390
+ # ===================================================================== #
391
+ if css_class.has_key? :linebreak
392
+ i = css_class.delete :linebreak
393
+ close_me = close(__method__) {{ make_newline: i }}
394
+ end if css_class.is_a? Hash # See above explanation.
395
+ if css_class.is_a?(Hash) and css_class.empty?
396
+ css_class = ''
397
+ end
398
+ end
399
+ # ======================================================================= #
400
+ # === Handle blocks next
401
+ #
402
+ # Append a pre-defined content to it, unless we also use a block.
403
+ # ======================================================================= #
404
+ if block_given?
405
+ yielded = yield
406
+ case yielded # Intercept some Symbols.
407
+ when :strip
408
+ hyperref_target.strip!
409
+ close_me.strip! if close_me
410
+ when :only_basename
411
+ if hyperref_target.has_key? :link_description
412
+ link_description = File.basename(hyperref_target[:link_description])
413
+ end
414
+ when :smaller
415
+ _ = link_description
416
+ link_description = '<span style="font-size:smaller">'+_+'</span>'
417
+ else
418
+ # =================================================================== #
419
+ # Assume that it could be a HTML colour, such as :slateblue:
420
+ # =================================================================== #
421
+ if yielded.is_a? Symbol
422
+ begin
423
+ require 'colours/html/html_colours.rb'
424
+ if Colours.is_this_html_colour_included?(yielded)
425
+ if css_style.nil?
426
+ css_style = ''.dup
427
+ end
428
+ css_style = css_style.dup if css_style.frozen?
429
+ css_style << " color: #{yielded};"
430
+ end
431
+ rescue LoadError
432
+ end
433
+ end
434
+ end
435
+ hyperref_target.merge!(yielded) unless yielded.is_a? Symbol
436
+ end
437
+ # ======================================================================= #
438
+ # === Copy the content of hyperref_target onto link_description
439
+ #
440
+ # This should come fairly late, though.
441
+ # ======================================================================= #
442
+ case link_description
443
+ when :use_hyperref_as_the_target
444
+ link_description = hyperref_target.dup
445
+ end
446
+ # ======================================================================= #
447
+ # Finally we will build-up the result-String next.
448
+ # ======================================================================= #
449
+ result = '<a'.dup
450
+ if hyperref_target.is_a?(Hash) and hyperref_target.empty? and
451
+ !link_description.empty?
452
+ hyperref_target = link_description.dup
453
+ end
454
+ hyperref_target = hyperref_target.to_s
455
+ result << ' href="'+hyperref_target+'"'
456
+ if css_class and !css_class.to_s.empty?
457
+ result << ' class="'+css_class.to_s+'"'
458
+ end
459
+ if the_id and !the_id.empty?
460
+ result << ' id="'+the_id.to_s+'"'
461
+ end
462
+ if css_style and !css_style.empty?
463
+ result << ' style="'+css_style.to_s+'"'
464
+ end
465
+ if javascript and !javascript.empty?
466
+ # The next lines exist to use "onclick" javascript directly.
467
+ unless javascript.lstrip.start_with? 'onclick'
468
+ result << ' javascript="'
469
+ end
470
+ result << javascript
471
+ unless javascript.lstrip.start_with? 'onclick'
472
+ result << '"'
473
+ end
474
+ end
475
+ if internal_hash.is_a?(Hash) and internal_hash.has_key?(:tooltip)
476
+ result << " data-tip=\"#{internal_hash[:tooltip]}\""
477
+ end
478
+ result << '>'
479
+ # result << N
480
+ result << link_description.to_s # Could be a Symbol after all.
481
+ result << close_me
482
+ if make_newline
483
+ result << '<br>'
484
+ end
485
+ # ======================================================================= #
486
+ # Must add it onto the main String too.
487
+ # ======================================================================= #
488
+ return HtmlTags.add(result)
489
+ end; self.instance_eval { alias slink a } # === HtmlTags.slink
490
+ self.instance_eval { alias link a } # === HtmlTags.link
491
+
492
+ # ========================================================================= #
493
+ # === a
494
+ # ========================================================================= #
495
+ def a(
496
+ hyperref_target = '',
497
+ link_description = :use_hyperref_as_the_target,
498
+ css_class = '',
499
+ the_id = '',
500
+ css_style = '',
501
+ javascript = '',
502
+ &block
503
+ )
504
+ HtmlTags.a(
505
+ hyperref_target,
506
+ link_description,
507
+ css_class,
508
+ the_id,
509
+ css_style,
510
+ javascript,
511
+ &block
512
+ )
513
+ end; alias slink a # === slink
514
+ alias link a # === link
515
+
516
+ end
517
+
518
+ if __FILE__ == $PROGRAM_NAME
519
+ alias e puts
520
+ puts HtmlTags.a(
521
+ 'https://geizhals.at/diverse-cr2032-knopfzelle-a134716.html',
522
+ css_style: 'margin-left: 4em'
523
+ )
524
+ end
@@ -0,0 +1,44 @@
1
+ # =========================================================================== #
2
+ # Documentation for the <abbr> tag can be found here:
3
+ # http://www.w3schools.com/tags/tag_abbr.asp
4
+ # =========================================================================== #
5
+ module HtmlTags
6
+
7
+ # ========================================================================= #
8
+ # === HtmlTags.abbr
9
+ #
10
+ # To test this method, try:
11
+ #
12
+ # HtmlTags.abbr 'WHO','World Health Organization'
13
+ # ========================================================================= #
14
+ def self.abbr(abbreviation_to_use = '', long_name = '')
15
+ if long_name.empty? and !abbreviation_to_use.empty?
16
+ # ===================================================================== #
17
+ # In this case, we simply copy to the long name.
18
+ # ===================================================================== #
19
+ long_name = abbreviation_to_use.to_s.dup
20
+ end
21
+ if block_given?
22
+ return HtmlTags.add(
23
+ opening_tag(__method__, title: long_name.to_s)+
24
+ abbreviation_to_use+
25
+ yield+
26
+ close(__method__)
27
+ )
28
+ else
29
+ return HtmlTags.add(
30
+ opening_tag(__method__, title: long_name.to_s)+
31
+ abbreviation_to_use+
32
+ close(__method__)
33
+ )
34
+ end
35
+ end
36
+
37
+ # ========================================================================= #
38
+ # === abbr
39
+ # ========================================================================= #
40
+ def abbr(abbreviation_to_use = '', long_name = '')
41
+ HtmlTags.abbr(abbreviation_to_use, long_name)
42
+ end
43
+
44
+ end
@@ -0,0 +1,32 @@
1
+ module HtmlTags
2
+
3
+ # ========================================================================= #
4
+ # === HtmlTags.audio
5
+ #
6
+ # Use a HTML5 audio tag.
7
+ # ========================================================================= #
8
+ def self.audio(url = '', optional_autoplay = false)
9
+ case File.extname(url).delete('.')
10
+ when '','ogg'
11
+ use_this_audio_type = 'ogg'
12
+ when 'mp3'
13
+ use_this_audio_type = 'mpeg'
14
+ when 'wav'
15
+ use_this_audio_type = 'wav'
16
+ else
17
+ use_this_audio_type = nil # Else we will not play it.
18
+ end
19
+ if use_this_audio_type
20
+ result = '<audio controls'
21
+ result << ' autoplay="autoplay"' if optional_autoplay
22
+ result << '>'+N
23
+ result << '<source src="'+url.to_s+'" type="audio/'+use_this_audio_type.to_s+'">'+N
24
+ result << 'Your browser does not support the audio element.'
25
+ result << close(__method__)
26
+ else
27
+ nil
28
+ end
29
+ return HtmlTags.add(result)
30
+ end
31
+
32
+ end
@@ -0,0 +1,22 @@
1
+ module HtmlTags
2
+
3
+ # ========================================================================= #
4
+ # === b
5
+ #
6
+ # This is the same as bold. Note that since HTML 5, it is recommended
7
+ # to use <strong> instead.
8
+ # ========================================================================= #
9
+ def b(
10
+ i = '',
11
+ css_class = '',
12
+ the_id = '',
13
+ css_style = ''
14
+ )
15
+ return HtmlTags.add(
16
+ opening_tag(__method__, css_class, the_id, css_style)+
17
+ i.to_s+
18
+ close(__method__)
19
+ )
20
+ end; alias bold b
21
+
22
+ end
@@ -0,0 +1,19 @@
1
+ module HtmlTags
2
+
3
+ # ========================================================================= #
4
+ # === blockquote
5
+ # ========================================================================= #
6
+ def blockquote(
7
+ i = '',
8
+ css_class = '',
9
+ the_id = '',
10
+ css_style = ''
11
+ )
12
+ HtmlTags.add(
13
+ opening_tag(__method__, css_class, the_id, css_style)+
14
+ i.to_s+
15
+ close(__method__)
16
+ )
17
+ end
18
+
19
+ end
@@ -0,0 +1,19 @@
1
+ module HtmlTags
2
+
3
+ # ========================================================================= #
4
+ # === body
5
+ # ========================================================================= #
6
+ def body(
7
+ i = '',
8
+ css_class = '',
9
+ the_id = '',
10
+ css_style = ''
11
+ )
12
+ return HtmlTags.add(
13
+ opening_tag(__method__, css_class, the_id, css_style)+
14
+ i.to_s+
15
+ close(__method__)
16
+ )
17
+ end
18
+
19
+ end