html_tags 0.1.183

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.
Files changed (120) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +456 -0
  3. data/USAGE.md +17 -0
  4. data/doc/README.gen +256 -0
  5. data/html_tags.gemspec +48 -0
  6. data/images/logo_for_the_html_tags_project.png +0 -0
  7. data/lib/html_tags/array_registered_html_tags.rb +126 -0
  8. data/lib/html_tags/autoinclude.rb +2 -0
  9. data/lib/html_tags/autoinclude_base_module.rb +7 -0
  10. data/lib/html_tags/base/README.md +3 -0
  11. data/lib/html_tags/base/base.rb +11 -0
  12. data/lib/html_tags/base/base_module.rb +271 -0
  13. data/lib/html_tags/base/prototype.rb +19 -0
  14. data/lib/html_tags/checks.rb +58 -0
  15. data/lib/html_tags/closing_tag/closing_tag.rb +76 -0
  16. data/lib/html_tags/constants/array_strip_newlines.rb +14 -0
  17. data/lib/html_tags/constants/misc.rb +21 -0
  18. data/lib/html_tags/constants.rb +26 -0
  19. data/lib/html_tags/html_closing_tags.rb +36 -0
  20. data/lib/html_tags/html_comment.rb +29 -0
  21. data/lib/html_tags/html_tags.rb +118 -0
  22. data/lib/html_tags/html_tags_constants.rb +14 -0
  23. data/lib/html_tags/individual_tags/a.rb +646 -0
  24. data/lib/html_tags/individual_tags/abbr.rb +44 -0
  25. data/lib/html_tags/individual_tags/address.rb +50 -0
  26. data/lib/html_tags/individual_tags/area.rb +60 -0
  27. data/lib/html_tags/individual_tags/article.rb +48 -0
  28. data/lib/html_tags/individual_tags/aside.rb +80 -0
  29. data/lib/html_tags/individual_tags/audio.rb +54 -0
  30. data/lib/html_tags/individual_tags/b.rb +22 -0
  31. data/lib/html_tags/individual_tags/bdo.rb +50 -0
  32. data/lib/html_tags/individual_tags/blockquote.rb +19 -0
  33. data/lib/html_tags/individual_tags/body.rb +19 -0
  34. data/lib/html_tags/individual_tags/br.rb +28 -0
  35. data/lib/html_tags/individual_tags/button.rb +143 -0
  36. data/lib/html_tags/individual_tags/canvas.rb +19 -0
  37. data/lib/html_tags/individual_tags/caption.rb +107 -0
  38. data/lib/html_tags/individual_tags/cite.rb +78 -0
  39. data/lib/html_tags/individual_tags/code.rb +105 -0
  40. data/lib/html_tags/individual_tags/del.rb +112 -0
  41. data/lib/html_tags/individual_tags/details.rb +79 -0
  42. data/lib/html_tags/individual_tags/dialog.rb +108 -0
  43. data/lib/html_tags/individual_tags/div.rb +99 -0
  44. data/lib/html_tags/individual_tags/em.rb +99 -0
  45. data/lib/html_tags/individual_tags/fieldset.rb +88 -0
  46. data/lib/html_tags/individual_tags/figure.rb +42 -0
  47. data/lib/html_tags/individual_tags/footer.rb +61 -0
  48. data/lib/html_tags/individual_tags/form.rb +93 -0
  49. data/lib/html_tags/individual_tags/h1.rb +48 -0
  50. data/lib/html_tags/individual_tags/h2.rb +46 -0
  51. data/lib/html_tags/individual_tags/h3.rb +78 -0
  52. data/lib/html_tags/individual_tags/h4.rb +36 -0
  53. data/lib/html_tags/individual_tags/h5.rb +36 -0
  54. data/lib/html_tags/individual_tags/h6.rb +40 -0
  55. data/lib/html_tags/individual_tags/head.rb +47 -0
  56. data/lib/html_tags/individual_tags/header.rb +54 -0
  57. data/lib/html_tags/individual_tags/hgroup.rb +78 -0
  58. data/lib/html_tags/individual_tags/html.rb +61 -0
  59. data/lib/html_tags/individual_tags/i.rb +47 -0
  60. data/lib/html_tags/individual_tags/iframe.rb +131 -0
  61. data/lib/html_tags/individual_tags/img.rb +135 -0
  62. data/lib/html_tags/individual_tags/input.rb +96 -0
  63. data/lib/html_tags/individual_tags/ins.rb +102 -0
  64. data/lib/html_tags/individual_tags/kbd.rb +109 -0
  65. data/lib/html_tags/individual_tags/keygen.rb +90 -0
  66. data/lib/html_tags/individual_tags/label.rb +77 -0
  67. data/lib/html_tags/individual_tags/legend.rb +48 -0
  68. data/lib/html_tags/individual_tags/li.rb +74 -0
  69. data/lib/html_tags/individual_tags/link.rb +58 -0
  70. data/lib/html_tags/individual_tags/main.rb +29 -0
  71. data/lib/html_tags/individual_tags/map.rb +95 -0
  72. data/lib/html_tags/individual_tags/mark.rb +78 -0
  73. data/lib/html_tags/individual_tags/menu.rb +79 -0
  74. data/lib/html_tags/individual_tags/nav.rb +64 -0
  75. data/lib/html_tags/individual_tags/object.rb +76 -0
  76. data/lib/html_tags/individual_tags/ol.rb +50 -0
  77. data/lib/html_tags/individual_tags/p.rb +92 -0
  78. data/lib/html_tags/individual_tags/pre.rb +16 -0
  79. data/lib/html_tags/individual_tags/progress.rb +114 -0
  80. data/lib/html_tags/individual_tags/script.rb +22 -0
  81. data/lib/html_tags/individual_tags/source.rb +42 -0
  82. data/lib/html_tags/individual_tags/span.rb +95 -0
  83. data/lib/html_tags/individual_tags/strong.rb +17 -0
  84. data/lib/html_tags/individual_tags/style.rb +29 -0
  85. data/lib/html_tags/individual_tags/summary.rb +77 -0
  86. data/lib/html_tags/individual_tags/sup.rb +57 -0
  87. data/lib/html_tags/individual_tags/table.rb +90 -0
  88. data/lib/html_tags/individual_tags/tbody.rb +19 -0
  89. data/lib/html_tags/individual_tags/td.rb +30 -0
  90. data/lib/html_tags/individual_tags/textarea.rb +72 -0
  91. data/lib/html_tags/individual_tags/th.rb +50 -0
  92. data/lib/html_tags/individual_tags/thead.rb +53 -0
  93. data/lib/html_tags/individual_tags/time.rb +50 -0
  94. data/lib/html_tags/individual_tags/title.rb +59 -0
  95. data/lib/html_tags/individual_tags/tr.rb +50 -0
  96. data/lib/html_tags/individual_tags/track.rb +59 -0
  97. data/lib/html_tags/individual_tags/u.rb +47 -0
  98. data/lib/html_tags/individual_tags/ul.rb +23 -0
  99. data/lib/html_tags/individual_tags/var.rb +46 -0
  100. data/lib/html_tags/individual_tags/video.rb +70 -0
  101. data/lib/html_tags/module.rb +5 -0
  102. data/lib/html_tags/opening_tag/opening_tag.rb +288 -0
  103. data/lib/html_tags/project/project_base_directory.rb +23 -0
  104. data/lib/html_tags/requires/require_the_html_tags_project.rb +9 -0
  105. data/lib/html_tags/requires/require_the_img_tag.rb +7 -0
  106. data/lib/html_tags/shared.rb +23 -0
  107. data/lib/html_tags/stag.rb +54 -0
  108. data/lib/html_tags/toplevel_methods/add.rb +22 -0
  109. data/lib/html_tags/toplevel_methods/full_output.rb +33 -0
  110. data/lib/html_tags/toplevel_methods/newline_or_empty.rb +21 -0
  111. data/lib/html_tags/toplevel_methods/strip_newlines.rb +27 -0
  112. data/lib/html_tags/version/version.rb +17 -0
  113. data/lib/html_tags/yaml/available_html_tags.yml +135 -0
  114. data/lib/html_tags/yaml/valid_tags_in_a_head_tag.yml +16 -0
  115. data/lib/html_tags.rb +5 -0
  116. data/test/testing_html_tags.rb +158 -0
  117. data/test/testing_the_a_tag.rb +162 -0
  118. data/test/testing_the_button_tag.rb +37 -0
  119. data/test/testing_the_details_tag.rb +38 -0
  120. metadata +171 -0
@@ -0,0 +1,271 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # Note that not necessarily every HTML tag will be made available in
6
+ # HtmlTags::BaseModule for the time being. For now I will only add
7
+ # tags that I commonly need to re-use in other projects. In the long
8
+ # run, I may just batch-generate the required tags, though. (28.04.2019)
9
+ # =========================================================================== #
10
+ # require 'html_tags/base/base_module.rb'
11
+ # include HtmlTags::BaseModule
12
+ # =========================================================================== #
13
+ module HtmlTags
14
+
15
+ module BaseModule # === HtmlTags::BaseModule
16
+
17
+ require 'html_tags/individual_tags/a.rb'
18
+ require 'html_tags/individual_tags/div.rb'
19
+ require 'html_tags/individual_tags/form.rb'
20
+ require 'html_tags/individual_tags/li.rb'
21
+ require 'html_tags/individual_tags/h1.rb'
22
+ require 'html_tags/individual_tags/h2.rb'
23
+ require 'html_tags/individual_tags/h3.rb'
24
+ require 'html_tags/individual_tags/h4.rb'
25
+ require 'html_tags/individual_tags/h5.rb'
26
+ require 'html_tags/individual_tags/h6.rb'
27
+ require 'html_tags/individual_tags/html.rb'
28
+ require 'html_tags/individual_tags/ol.rb'
29
+ require 'html_tags/individual_tags/p.rb'
30
+ require 'html_tags/individual_tags/pre.rb'
31
+
32
+ # ========================================================================= #
33
+ # === HtmlTags::BaseModule.is_on_roebe?
34
+ # ========================================================================= #
35
+ def self.is_on_roebe?
36
+ ENV['IS_ROEBE'].to_s == '1'
37
+ end
38
+
39
+ # ========================================================================= #
40
+ # === pre
41
+ # ========================================================================= #
42
+ def pre(
43
+ i = '', css_class = '', the_id = '', css_style = '', &block
44
+ )
45
+ HtmlTags.pre(
46
+ i, css_class, the_id, css_style, &block
47
+ )
48
+ end
49
+
50
+ # ========================================================================= #
51
+ # === li (li tag)
52
+ # ========================================================================= #
53
+ def li(
54
+ i = '', optional_css_class = '', optional_id = '', optional_css_style = '', &block
55
+ )
56
+ HtmlTags.li(
57
+ i, optional_css_class, optional_id, optional_css_style, &block
58
+ )
59
+ end
60
+
61
+ # ========================================================================= #
62
+ # === ol (ol tag)
63
+ # ========================================================================= #
64
+ def ol(
65
+ i = '', optional_css_class = '', optional_id = '', optional_css_style = '', &block
66
+ )
67
+ HtmlTags.ol(
68
+ i, optional_css_class, optional_id, optional_css_style, &block
69
+ )
70
+ end
71
+
72
+ # ========================================================================= #
73
+ # === h1
74
+ # ========================================================================= #
75
+ def h1(
76
+ i = '',
77
+ css_class = '',
78
+ the_id = '', css_style = '', javascript_code = '', &block
79
+ )
80
+ HtmlTags.h1(
81
+ i,
82
+ css_class,
83
+ the_id,
84
+ css_style,
85
+ javascript_code,
86
+ &block
87
+ )
88
+ end
89
+
90
+ # ========================================================================= #
91
+ # === h2
92
+ # ========================================================================= #
93
+ def h2(
94
+ i = '',
95
+ css_class = '',
96
+ the_id = '',
97
+ css_style = '',
98
+ javascript_code = '',
99
+ &block
100
+ )
101
+ HtmlTags.h2(
102
+ i,
103
+ css_class,
104
+ the_id,
105
+ css_style,
106
+ javascript_code,
107
+ &block
108
+ )
109
+ end
110
+
111
+ # ========================================================================= #
112
+ # === h3
113
+ # ========================================================================= #
114
+ def h3(
115
+ i = '',
116
+ css_class = '',
117
+ the_id = '',
118
+ css_style = '',
119
+ javascript_code = '',
120
+ &block
121
+ )
122
+ HtmlTags.h3(
123
+ i, css_class, the_id, css_style, javascript_code, &block
124
+ )
125
+ end
126
+
127
+ # ========================================================================= #
128
+ # === h4
129
+ # ========================================================================= #
130
+ def h4(
131
+ i = '',
132
+ css_class = '',
133
+ the_id = '',
134
+ css_style = '',
135
+ javascript_code = '',
136
+ &block
137
+ )
138
+ HtmlTags.h4(
139
+ i,
140
+ css_class,
141
+ the_id,
142
+ css_style,
143
+ javascript_code,
144
+ &block
145
+ )
146
+ end
147
+
148
+ # ========================================================================= #
149
+ # === h5
150
+ # ========================================================================= #
151
+ def h5(
152
+ i = '',
153
+ css_class = '',
154
+ the_id = '',
155
+ css_style = '',
156
+ javascript_code = '',
157
+ &block
158
+ )
159
+ HtmlTags.h5(
160
+ i,
161
+ css_class,
162
+ the_id,
163
+ css_style,
164
+ javascript_code,
165
+ &block
166
+ )
167
+ end
168
+
169
+ # ========================================================================= #
170
+ # === h6
171
+ # ========================================================================= #
172
+ def h6(
173
+ i = '',
174
+ css_class = '',
175
+ the_id = '',
176
+ css_style = '',
177
+ javascript_code = '',
178
+ &block
179
+ )
180
+ HtmlTags.h6(
181
+ i,
182
+ css_class,
183
+ the_id,
184
+ css_style,
185
+ javascript_code,
186
+ &block
187
+ )
188
+ end
189
+
190
+ # ========================================================================= #
191
+ # === p
192
+ #
193
+ # This method can be used to create the html <p> tag.
194
+ # ========================================================================= #
195
+ def p(
196
+ i = '',
197
+ css_class = '',
198
+ the_id = '',
199
+ css_style = '',
200
+ &block
201
+ )
202
+ HtmlTags.p(i, css_class, the_id, css_style, &block)
203
+ end
204
+
205
+ # ========================================================================= #
206
+ # === div
207
+ #
208
+ # This method can be used to create the html <div> tag.
209
+ # ========================================================================= #
210
+ def div(
211
+ i = '',
212
+ css_class = '',
213
+ the_id = '',
214
+ css_style = '',
215
+ &block
216
+ )
217
+ HtmlTags.div(i, css_class, the_id, css_style, &block)
218
+ end
219
+
220
+ # ========================================================================= #
221
+ # === a (a tag)
222
+ # ========================================================================= #
223
+ def a(
224
+ i = '',
225
+ css_class = '',
226
+ the_id = '',
227
+ css_style = '',
228
+ javascript = '',
229
+ &block
230
+ )
231
+ HtmlTags.a(
232
+ i, css_class, the_id, css_style, javascript, &block
233
+ )
234
+ end
235
+
236
+ # ========================================================================= #
237
+ # === form (form tag)
238
+ # ========================================================================= #
239
+ def form(
240
+ i = '',
241
+ css_class = '',
242
+ the_id = '',
243
+ css_style = '',
244
+ &block
245
+ )
246
+ HtmlTags.form(
247
+ i, css_class, the_id, css_style, &block
248
+ )
249
+ end
250
+
251
+ # ========================================================================= #
252
+ # === br
253
+ # ========================================================================= #
254
+ def br
255
+ HtmlTags.br
256
+ end
257
+
258
+ # ========================================================================= #
259
+ # === html
260
+ # ========================================================================= #
261
+ def html(
262
+ i = '',
263
+ css_class = '',
264
+ the_id = '',
265
+ css_style = '',
266
+ &block
267
+ )
268
+ HtmlTags.html(i, css_class, the_id, css_style, &block)
269
+ end
270
+
271
+ end; end
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'html_tags/base/prototype.rb'
6
+ # =========================================================================== #
7
+ module HtmlTags
8
+
9
+ require 'html_tags/base/base.rb'
10
+ require 'html_tags/constants/misc.rb'
11
+
12
+ # ========================================================================= #
13
+ # === HtmlTags.new
14
+ # ========================================================================= #
15
+ def self.new
16
+ HtmlTags::Base.new
17
+ end
18
+
19
+ end
@@ -0,0 +1,58 @@
1
+ require 'html_tags/array_registered_html_tags.rb'
2
+
3
+ module HtmlTags # require 'html_tags/checks.rb'
4
+
5
+ # ========================================================================= #
6
+ # === is_valid_html?
7
+ #
8
+ # This method will check whether the given input is a valid html tag
9
+ # or whether it is not. It will delegate towards the class method
10
+ # HtmlTags.is_valid_html?
11
+ # ========================================================================= #
12
+ def is_valid_html?(i = '</br>')
13
+ return HtmlTags.is_valid_html? i
14
+ end; alias is_valid? is_valid_html?
15
+ alias is_valid_html_tag? is_valid_html?
16
+
17
+ # ========================================================================= #
18
+ # === HtmlTags.is_valid_html?
19
+ #
20
+ # This is the real method that does the check.
21
+ # ========================================================================= #
22
+ def self.is_valid_html?(i)
23
+ i = i.delete('<')
24
+ i = i.delete('>')
25
+ i = i.delete('/')
26
+ return ARRAY_REGISTERED_HTML_TAGS.include? i
27
+ end
28
+
29
+ # ========================================================================= #
30
+ # === HtmlTags.string_contains_only_valid_html_tags?
31
+ #
32
+ # This method will test if a whole string will have only valid html
33
+ # tags.
34
+ # ========================================================================= #
35
+ def self.string_contains_only_valid_html_tags?(i)
36
+ all_matches = i.scan(/\<.+\>/)
37
+ return all_matches.all? {|entry| is_valid_html? entry }
38
+ end
39
+
40
+ # ========================================================================= #
41
+ # === string_contains_only_valid_html_tags?(i)
42
+ # ========================================================================= #
43
+ def string_contains_only_valid_html_tags?(i)
44
+ return HtmlTags.string_contains_only_valid_html_tags?(i)
45
+ end
46
+
47
+ end
48
+
49
+ # =========================================================================== #
50
+ # Here we test the above.
51
+ # =========================================================================== #
52
+ if __FILE__ == $PROGRAM_NAME
53
+ puts HtmlTags.is_valid_html? '<br>'
54
+ puts HtmlTags.is_valid_html? '<div>'
55
+ puts HtmlTags.is_valid_html? '<dav>'
56
+ puts HtmlTags.string_contains_only_valid_html_tags? 'hello ruby </br>'
57
+ puts HtmlTags.string_contains_only_valid_html_tags? 'hello ruby<haha>'
58
+ end # rb checks.rb
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'html_tags/closing_tag/closing_tag.rb'
6
+ # =========================================================================== #
7
+ module HtmlTags
8
+
9
+ require 'html_tags/toplevel_methods/strip_newlines.rb'
10
+ # ========================================================================= #
11
+ # === HtmlTags.close
12
+ #
13
+ # This method creates the closing tag. It will return that tag as
14
+ # a string.
15
+ #
16
+ # This method also accepts a block, which can be a hash that could
17
+ # have keys such as { :make_newline => true }.
18
+ #
19
+ # Usage example:
20
+ #
21
+ # HtmlTags.close('span')
22
+ #
23
+ # ========================================================================= #
24
+ def self.close(i, &block)
25
+ append_newline = true
26
+ # ======================================================================= #
27
+ # If we strip newlines, then we won't append them logically.
28
+ # ======================================================================= #
29
+ append_newline = false if HtmlTags.strip_newlines?
30
+ i = i.to_s.dup # It should remain a String.
31
+ # ======================================================================= #
32
+ # Next, sanitize some wrongful/shortcut tags here.
33
+ # ======================================================================= #
34
+ case i
35
+ when 'link'
36
+ i = 'a'
37
+ when 'field',
38
+ 'mini_header'
39
+ i = 'fieldset'
40
+ end
41
+ end_string = ''.dup # This will be be appended.
42
+ # ======================================================================= #
43
+ # Intercept blocks passed to the method here.
44
+ # ======================================================================= #
45
+ if block_given?
46
+ yielded = yield # Tap into the block.
47
+ if yielded.is_a? Hash
48
+ if yielded.has_key? :make_newline
49
+ end_string << br if yielded[:make_newline] == true
50
+ end
51
+ elsif yielded == :make_newline
52
+ end_string << br
53
+ elsif yielded == :no_newline
54
+ append_newline = false # Do not append a newline in this case here.
55
+ end
56
+ end
57
+ result = ''.dup
58
+ # result << "\n" if append_newline # This one was disabled in April 2022.
59
+ result << '</'+i.to_s.dup+'>'
60
+ result << "\n" if append_newline
61
+ result << end_string # This is the result we will return. A String.
62
+ return result
63
+ end
64
+
65
+ # ========================================================================= #
66
+ # === close (close tag)
67
+ #
68
+ # This is a wrapper towards HtmlTags.close(), which will close a
69
+ # given HTML tag.
70
+ # ========================================================================= #
71
+ def close(i, &block)
72
+ return HtmlTags.close(i, &block) # Delegate to the above class-method.
73
+ end; alias ctag close # === ctag
74
+ # alias c close <- Not sure about that alias yet.
75
+
76
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'html_tags/constants/array_strip_newlines.rb'
6
+ # =========================================================================== #
7
+ module HtmlTags
8
+
9
+ # ========================================================================= #
10
+ # === HtmlTags::ARRAY_STRIP_NEWLINES
11
+ # ========================================================================= #
12
+ ARRAY_STRIP_NEWLINES = [false]
13
+
14
+ end
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'html_tags/constants/misc.rb'
6
+ # =========================================================================== #
7
+ module HtmlTags
8
+
9
+ # ========================================================================= #
10
+ # === DOCTYPE_HTML
11
+ # ========================================================================= #
12
+ DOCTYPE_HTML = '<!DOCTYPE html>'
13
+
14
+ # ========================================================================= #
15
+ # === HtmlTags.doctype_html
16
+ # ========================================================================= #
17
+ def self.doctype_html
18
+ DOCTYPE_HTML
19
+ end
20
+
21
+ end
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'yaml'
6
+ require 'html_tags/project/project_base_directory.rb'
7
+
8
+ module HtmlTags
9
+
10
+ # ========================================================================= #
11
+ # === FILE_VALID_TAGS_IN_A_HEAD_TAG
12
+ #
13
+ # This specifies the path to a yaml-file that keeps an Array.
14
+ # ========================================================================= #
15
+ FILE_VALID_TAGS_IN_A_HEAD_TAG = "#{PROJECT_YAML_DIR}valid_tags_in_a_head_tag.yml"
16
+
17
+ # ========================================================================= #
18
+ # === VALID_TAGS_IN_A_HEAD_TAG
19
+ # ========================================================================= #
20
+ if File.exist? FILE_VALID_TAGS_IN_A_HEAD_TAG
21
+ VALID_TAGS_IN_A_HEAD_TAG = YAML.load_file(FILE_VALID_TAGS_IN_A_HEAD_TAG)
22
+ else
23
+ VALID_TAGS_IN_A_HEAD_TAG = []
24
+ end
25
+
26
+ end
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # =========================================================================== #
4
+ # All html closing tags are autogenerated here.
5
+ # =========================================================================== #
6
+ require 'html_tags/array_registered_html_tags.rb'
7
+ require 'html_tags/html_tags_constants.rb'
8
+ require 'html_tags/closing_tag/closing_tag.rb'
9
+
10
+ module HtmlTags
11
+
12
+ # ========================================================================= #
13
+ # Next, generate all closing html tags. A respective closing tag is
14
+ # the name of the tag, and a 'c' preprended.
15
+ #
16
+ # Example:
17
+ # The closing tag for h1() method call will be ch1(). Of course the
18
+ # () can be omitted in Ruby, so we can use:
19
+ # ch1
20
+ # chtml
21
+ #
22
+ # Some html tags do not have a closing tag though.
23
+ # ========================================================================= #
24
+ ( ARRAY_REGISTERED_HTML_TAGS - ARRAY_TAGS_WITHOUT_CLOSING_TAG ).each {|entry|
25
+ define_method('c'+entry.to_s) {
26
+ close(entry.to_s.dup) # This method is defined in the file close.rb
27
+ }
28
+ }
29
+
30
+ end
31
+
32
+ if __FILE__ == $PROGRAM_NAME
33
+ include HtmlTags
34
+ p HtmlTags::methods
35
+ p ch6 # Close a <h6> tag that way.
36
+ end # html_closing_tags
@@ -0,0 +1,29 @@
1
+ module HtmlTags # require 'html_tags/html_comment.rb'
2
+
3
+ # ========================================================================= #
4
+ # === HtmlTags.html_comment
5
+ # ========================================================================= #
6
+ def self.html_comment(your_comment = '')
7
+ return '<!-- '+your_comment.to_s+' --> '+NL
8
+ end; self.instance_eval { alias comment html_comment } # HtmlTags.comment
9
+
10
+ # ========================================================================= #
11
+ # === html_comment
12
+ #
13
+ # This method will make a html comment - as in, make a valid comment within
14
+ # the source of a html file. This is done by putting <!-- --> around
15
+ # the content in question.
16
+ #
17
+ # Specific Usage Examples:
18
+ # HtmlTags.html_comment 'yup'
19
+ # ee HtmlTags.html_comment 'yup'
20
+ # ee html_comment 'this is for displaying some data'
21
+ #
22
+ # Resources for Comments in HTML:
23
+ # http://www.tutorialspoint.com/html/html_comments.htm
24
+ # ========================================================================= #
25
+ def html_comment(your_comment = '')
26
+ HtmlTags.html_comment(your_comment)
27
+ end; alias comment html_comment
28
+
29
+ end
@@ -0,0 +1,118 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === HtmlTags
6
+ #
7
+ # This project can generate HTML tags. We will also create the corresponding
8
+ # closing tags to said actions - see the file html_closing_tags.rb for
9
+ # close-related actions.
10
+ #
11
+ # If you want to autoinclude this project, do this:
12
+ # require 'html_tags/autoinclude'
13
+ # =========================================================================== #
14
+ require 'pathname'
15
+ require 'html_tags/array_registered_html_tags.rb' # bl $HTML_TAGS/array_registered_html_tags.rb
16
+ require 'html_tags/constants/array_strip_newlines.rb'
17
+ require 'html_tags/constants.rb'
18
+ require 'html_tags/html_closing_tags.rb'
19
+ require 'html_tags/html_comment.rb'
20
+ require 'html_tags/html_tags_constants.rb'
21
+ require 'html_tags/opening_tag/opening_tag.rb'
22
+ require 'html_tags/shared.rb'
23
+ require 'html_tags/stag.rb'
24
+ require 'html_tags/version/version.rb'
25
+ require 'html_tags/toplevel_methods/full_output.rb'
26
+ require 'html_tags/toplevel_methods/strip_newlines.rb'
27
+
28
+ # =========================================================================== #
29
+ # Next, require the individual tags from the individual_tags/ directory.
30
+ # =========================================================================== #
31
+ Dir[RbConfig::CONFIG['sitelibdir']+'/html_tags/individual_tags/*.rb'].each {|file|
32
+ require file
33
+ }
34
+
35
+ module HtmlTags # require 'html_tags'
36
+
37
+ include HtmlTags::Shared
38
+
39
+ # ========================================================================= #
40
+ # === NL
41
+ # ========================================================================= #
42
+ NL = "\n"
43
+
44
+ # ========================================================================= #
45
+ # === is_this_an_allowed_tag_in_head_element?
46
+ #
47
+ # This method will return true or false depending on whether the given
48
+ # tag may be part of a <head> tag.
49
+ # ========================================================================= #
50
+ def is_this_an_allowed_tag_in_head_element?(i)
51
+ i = i.to_s # Ought to be a String.
52
+ # ======================================================================= #
53
+ # Get rid of <> tags.
54
+ # ======================================================================= #
55
+ i.delete!('<')
56
+ i.delete!('>')
57
+ VALID_TAGS_IN_A_HEAD_TAG.include? i
58
+ end
59
+
60
+ # ========================================================================= #
61
+ # === q
62
+ #
63
+ # The quote tag, <q>.
64
+ # ========================================================================= #
65
+ def q(i = '', css_class = '', the_id = '', css_style = '')
66
+ return HtmlTags.add(
67
+ opening_tag(__method__, css_class, the_id, css_style)+
68
+ i.to_s+
69
+ close(__method__)
70
+ )
71
+ end; alias quote q # === quote
72
+
73
+ # ========================================================================= #
74
+ # === hr
75
+ # ========================================================================= #
76
+ def hr
77
+ return HtmlTags.add(
78
+ otag(__method__)
79
+ )
80
+ end
81
+
82
+ # ========================================================================= #
83
+ # === sbody
84
+ #
85
+ # Start of body tag.
86
+ # ========================================================================= #
87
+ def sbody
88
+ unless string?.include?('</head>')
89
+ HtmlTags.add('</head><body>')
90
+ end
91
+ end
92
+
93
+ extend self
94
+
95
+ end
96
+
97
+ # =========================================================================== #
98
+ # Now some testing of the HTML components:
99
+ # =========================================================================== #
100
+ if __FILE__ == $PROGRAM_NAME
101
+ include HtmlTags
102
+ puts li 'Hi there.'
103
+ puts 'Now testing some components:'
104
+ ARRAY_REGISTERED_HTML_TAGS.each {|entry|
105
+ puts send(entry.to_sym)
106
+ }
107
+ puts head {'Ok'}
108
+ puts button 'ack','s1em'
109
+ ARRAY_REGISTERED_HTML_TAGS.each {|entry|
110
+ begin
111
+ puts send(entry.to_sym, 'Test','bblack1')
112
+ rescue Exception => error
113
+ pp error
114
+ end
115
+ }
116
+ puts h4 'Test','bblack1'
117
+ puts h4 'Test','bblack1','foo','border:1px solid black'
118
+ end # htmltags
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # =========================================================================== #
4
+ module HtmlTags # require 'html_tags/html_tags_constants.rb'
5
+
6
+ # ========================================================================= #
7
+ # Some hardcoded HTML-constants will be defined here.
8
+ # ========================================================================= #
9
+ TABLE = '<table>'
10
+ TR = '<tr>'
11
+ TD = '<td>'
12
+ BR = '<br/>'
13
+
14
+ end