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.
- checksums.yaml +7 -0
- data/README.md +456 -0
- data/USAGE.md +17 -0
- data/doc/README.gen +256 -0
- data/html_tags.gemspec +48 -0
- data/images/logo_for_the_html_tags_project.png +0 -0
- data/lib/html_tags/array_registered_html_tags.rb +126 -0
- data/lib/html_tags/autoinclude.rb +2 -0
- data/lib/html_tags/autoinclude_base_module.rb +7 -0
- data/lib/html_tags/base/README.md +3 -0
- data/lib/html_tags/base/base.rb +11 -0
- data/lib/html_tags/base/base_module.rb +271 -0
- data/lib/html_tags/base/prototype.rb +19 -0
- data/lib/html_tags/checks.rb +58 -0
- data/lib/html_tags/closing_tag/closing_tag.rb +76 -0
- data/lib/html_tags/constants/array_strip_newlines.rb +14 -0
- data/lib/html_tags/constants/misc.rb +21 -0
- data/lib/html_tags/constants.rb +26 -0
- data/lib/html_tags/html_closing_tags.rb +36 -0
- data/lib/html_tags/html_comment.rb +29 -0
- data/lib/html_tags/html_tags.rb +118 -0
- data/lib/html_tags/html_tags_constants.rb +14 -0
- data/lib/html_tags/individual_tags/a.rb +646 -0
- data/lib/html_tags/individual_tags/abbr.rb +44 -0
- data/lib/html_tags/individual_tags/address.rb +50 -0
- data/lib/html_tags/individual_tags/area.rb +60 -0
- data/lib/html_tags/individual_tags/article.rb +48 -0
- data/lib/html_tags/individual_tags/aside.rb +80 -0
- data/lib/html_tags/individual_tags/audio.rb +54 -0
- data/lib/html_tags/individual_tags/b.rb +22 -0
- data/lib/html_tags/individual_tags/bdo.rb +50 -0
- data/lib/html_tags/individual_tags/blockquote.rb +19 -0
- data/lib/html_tags/individual_tags/body.rb +19 -0
- data/lib/html_tags/individual_tags/br.rb +28 -0
- data/lib/html_tags/individual_tags/button.rb +143 -0
- data/lib/html_tags/individual_tags/canvas.rb +19 -0
- data/lib/html_tags/individual_tags/caption.rb +107 -0
- data/lib/html_tags/individual_tags/cite.rb +78 -0
- data/lib/html_tags/individual_tags/code.rb +105 -0
- data/lib/html_tags/individual_tags/del.rb +112 -0
- data/lib/html_tags/individual_tags/details.rb +79 -0
- data/lib/html_tags/individual_tags/dialog.rb +108 -0
- data/lib/html_tags/individual_tags/div.rb +99 -0
- data/lib/html_tags/individual_tags/em.rb +99 -0
- data/lib/html_tags/individual_tags/fieldset.rb +88 -0
- data/lib/html_tags/individual_tags/figure.rb +42 -0
- data/lib/html_tags/individual_tags/footer.rb +61 -0
- data/lib/html_tags/individual_tags/form.rb +93 -0
- data/lib/html_tags/individual_tags/h1.rb +48 -0
- data/lib/html_tags/individual_tags/h2.rb +46 -0
- data/lib/html_tags/individual_tags/h3.rb +78 -0
- data/lib/html_tags/individual_tags/h4.rb +36 -0
- data/lib/html_tags/individual_tags/h5.rb +36 -0
- data/lib/html_tags/individual_tags/h6.rb +40 -0
- data/lib/html_tags/individual_tags/head.rb +47 -0
- data/lib/html_tags/individual_tags/header.rb +54 -0
- data/lib/html_tags/individual_tags/hgroup.rb +78 -0
- data/lib/html_tags/individual_tags/html.rb +61 -0
- data/lib/html_tags/individual_tags/i.rb +47 -0
- data/lib/html_tags/individual_tags/iframe.rb +131 -0
- data/lib/html_tags/individual_tags/img.rb +135 -0
- data/lib/html_tags/individual_tags/input.rb +96 -0
- data/lib/html_tags/individual_tags/ins.rb +102 -0
- data/lib/html_tags/individual_tags/kbd.rb +109 -0
- data/lib/html_tags/individual_tags/keygen.rb +90 -0
- data/lib/html_tags/individual_tags/label.rb +77 -0
- data/lib/html_tags/individual_tags/legend.rb +48 -0
- data/lib/html_tags/individual_tags/li.rb +74 -0
- data/lib/html_tags/individual_tags/link.rb +58 -0
- data/lib/html_tags/individual_tags/main.rb +29 -0
- data/lib/html_tags/individual_tags/map.rb +95 -0
- data/lib/html_tags/individual_tags/mark.rb +78 -0
- data/lib/html_tags/individual_tags/menu.rb +79 -0
- data/lib/html_tags/individual_tags/nav.rb +64 -0
- data/lib/html_tags/individual_tags/object.rb +76 -0
- data/lib/html_tags/individual_tags/ol.rb +50 -0
- data/lib/html_tags/individual_tags/p.rb +92 -0
- data/lib/html_tags/individual_tags/pre.rb +16 -0
- data/lib/html_tags/individual_tags/progress.rb +114 -0
- data/lib/html_tags/individual_tags/script.rb +22 -0
- data/lib/html_tags/individual_tags/source.rb +42 -0
- data/lib/html_tags/individual_tags/span.rb +95 -0
- data/lib/html_tags/individual_tags/strong.rb +17 -0
- data/lib/html_tags/individual_tags/style.rb +29 -0
- data/lib/html_tags/individual_tags/summary.rb +77 -0
- data/lib/html_tags/individual_tags/sup.rb +57 -0
- data/lib/html_tags/individual_tags/table.rb +90 -0
- data/lib/html_tags/individual_tags/tbody.rb +19 -0
- data/lib/html_tags/individual_tags/td.rb +30 -0
- data/lib/html_tags/individual_tags/textarea.rb +72 -0
- data/lib/html_tags/individual_tags/th.rb +50 -0
- data/lib/html_tags/individual_tags/thead.rb +53 -0
- data/lib/html_tags/individual_tags/time.rb +50 -0
- data/lib/html_tags/individual_tags/title.rb +59 -0
- data/lib/html_tags/individual_tags/tr.rb +50 -0
- data/lib/html_tags/individual_tags/track.rb +59 -0
- data/lib/html_tags/individual_tags/u.rb +47 -0
- data/lib/html_tags/individual_tags/ul.rb +23 -0
- data/lib/html_tags/individual_tags/var.rb +46 -0
- data/lib/html_tags/individual_tags/video.rb +70 -0
- data/lib/html_tags/module.rb +5 -0
- data/lib/html_tags/opening_tag/opening_tag.rb +288 -0
- data/lib/html_tags/project/project_base_directory.rb +23 -0
- data/lib/html_tags/requires/require_the_html_tags_project.rb +9 -0
- data/lib/html_tags/requires/require_the_img_tag.rb +7 -0
- data/lib/html_tags/shared.rb +23 -0
- data/lib/html_tags/stag.rb +54 -0
- data/lib/html_tags/toplevel_methods/add.rb +22 -0
- data/lib/html_tags/toplevel_methods/full_output.rb +33 -0
- data/lib/html_tags/toplevel_methods/newline_or_empty.rb +21 -0
- data/lib/html_tags/toplevel_methods/strip_newlines.rb +27 -0
- data/lib/html_tags/version/version.rb +17 -0
- data/lib/html_tags/yaml/available_html_tags.yml +135 -0
- data/lib/html_tags/yaml/valid_tags_in_a_head_tag.yml +16 -0
- data/lib/html_tags.rb +5 -0
- data/test/testing_html_tags.rb +158 -0
- data/test/testing_the_a_tag.rb +162 -0
- data/test/testing_the_button_tag.rb +37 -0
- data/test/testing_the_details_tag.rb +38 -0
- metadata +171 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
#!/usr/bin/ruby -w
|
|
2
|
+
# Encoding: UTF-8
|
|
3
|
+
# frozen_string_literal: true
|
|
4
|
+
# =========================================================================== #
|
|
5
|
+
# require 'html_tags/requires/require_the_image_tag.rb'
|
|
6
|
+
# =========================================================================== #
|
|
7
|
+
require 'html_tags/individual_tags/img.rb'
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/ruby -w
|
|
2
|
+
# Encoding: UTF-8
|
|
3
|
+
# =========================================================================== #
|
|
4
|
+
require 'html_tags/checks.rb'
|
|
5
|
+
require 'html_tags/toplevel_methods/newline_or_empty.rb'
|
|
6
|
+
|
|
7
|
+
module HtmlTags # HtmlTags::Shared
|
|
8
|
+
|
|
9
|
+
module Shared # require 'html_tags/shared.rb'
|
|
10
|
+
|
|
11
|
+
N = "\n"
|
|
12
|
+
|
|
13
|
+
# ========================================================================= #
|
|
14
|
+
# === beautify_string
|
|
15
|
+
#
|
|
16
|
+
# First run .squeeze(' '), then delete newlines, to make a string more
|
|
17
|
+
# beautiful.
|
|
18
|
+
# ========================================================================= #
|
|
19
|
+
def beautify_string(i)
|
|
20
|
+
i.squeeze(' ').delete("\n")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end; end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/usr/bin/ruby -w
|
|
2
|
+
# Encoding: UTF-8
|
|
3
|
+
# frozen_string_literal: true
|
|
4
|
+
# =========================================================================== #
|
|
5
|
+
module HtmlTags
|
|
6
|
+
|
|
7
|
+
# ========================================================================= #
|
|
8
|
+
# === stag
|
|
9
|
+
#
|
|
10
|
+
# This method returns a proper HTML tag, including css class, possible
|
|
11
|
+
# javascript, id, and css style, and then return this as a string.
|
|
12
|
+
#
|
|
13
|
+
# By default we will use the <span> tag, hence why we have assigned
|
|
14
|
+
# the default argument "span" as the first argument to this method.
|
|
15
|
+
#
|
|
16
|
+
# "stag" is an alias to this method, a shortcut for "string_tag".
|
|
17
|
+
#
|
|
18
|
+
# Note that stag() itself will not return the closing tag.
|
|
19
|
+
#
|
|
20
|
+
# Specific Usage Examples for this method:
|
|
21
|
+
#
|
|
22
|
+
# HtmlTags.stag('span','marl1em')
|
|
23
|
+
# puts HtmlTags.stag('span','','','margin-left:0.92em; padding-left:6px')
|
|
24
|
+
#
|
|
25
|
+
# Would return:
|
|
26
|
+
#
|
|
27
|
+
# <span class="marl1em">
|
|
28
|
+
#
|
|
29
|
+
# ========================================================================= #
|
|
30
|
+
def stag(
|
|
31
|
+
name_of_the_tag = 'span',
|
|
32
|
+
optional_css_class = '',
|
|
33
|
+
optional_the_id = '',
|
|
34
|
+
optional_css_style = '',
|
|
35
|
+
optional_javascript = '',
|
|
36
|
+
&block
|
|
37
|
+
)
|
|
38
|
+
if optional_css_class.is_a? Hash
|
|
39
|
+
_ = otag(name_of_the_tag, optional_css_class) # otag() is defined in opening_tag.rb
|
|
40
|
+
else # We assume a string here.
|
|
41
|
+
optional_css_class = optional_css_class.to_s.chomp.dup
|
|
42
|
+
_ = otag(
|
|
43
|
+
name_of_the_tag,
|
|
44
|
+
css_class: optional_css_class,
|
|
45
|
+
id: optional_the_id,
|
|
46
|
+
css_style: optional_css_style,
|
|
47
|
+
javascript: optional_javascript,
|
|
48
|
+
&block
|
|
49
|
+
)
|
|
50
|
+
end
|
|
51
|
+
_.to_s
|
|
52
|
+
end; alias string_tag stag # === string_tag
|
|
53
|
+
|
|
54
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/ruby -w
|
|
2
|
+
# Encoding: UTF-8
|
|
3
|
+
# frozen_string_literal: true
|
|
4
|
+
# =========================================================================== #
|
|
5
|
+
# require 'html_tags/toplevel_methods/add.rb'
|
|
6
|
+
# =========================================================================== #
|
|
7
|
+
module HtmlTags
|
|
8
|
+
|
|
9
|
+
require 'html_tags/toplevel_methods/full_output.rb'
|
|
10
|
+
# ========================================================================= #
|
|
11
|
+
# === HtmlTags.add (add tag)
|
|
12
|
+
#
|
|
13
|
+
# Add to the main string called @full_output, which is a String.
|
|
14
|
+
# ========================================================================= #
|
|
15
|
+
def self.add(*i)
|
|
16
|
+
i.each {|entry|
|
|
17
|
+
@full_output << entry.to_s
|
|
18
|
+
}
|
|
19
|
+
i.join(' ').strip # Return the input. This is very important, naturally.
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/ruby -w
|
|
2
|
+
# Encoding: UTF-8
|
|
3
|
+
# frozen_string_literal: true
|
|
4
|
+
# =========================================================================== #
|
|
5
|
+
# require 'html_tags/toplevel_methods/full_output.rb'
|
|
6
|
+
# =========================================================================== #
|
|
7
|
+
module HtmlTags
|
|
8
|
+
|
|
9
|
+
# ========================================================================= #
|
|
10
|
+
# === @full_output
|
|
11
|
+
#
|
|
12
|
+
# The follow class-level instance variable stores all output from
|
|
13
|
+
# any of the various tags.
|
|
14
|
+
# ========================================================================= #
|
|
15
|
+
@full_output = ''.dup
|
|
16
|
+
|
|
17
|
+
# ========================================================================= #
|
|
18
|
+
# === HtmlTags[]
|
|
19
|
+
# ========================================================================= #
|
|
20
|
+
def self.[]
|
|
21
|
+
@full_output
|
|
22
|
+
end; self.instance_eval { alias output [] } # Next, we use 3 aliases.
|
|
23
|
+
self.instance_eval { alias output? [] }
|
|
24
|
+
self.instance_eval { alias string? [] }
|
|
25
|
+
|
|
26
|
+
# ========================================================================= #
|
|
27
|
+
# === HtmlTags.clear
|
|
28
|
+
# ========================================================================= #
|
|
29
|
+
def self.clear
|
|
30
|
+
@full_output = ''
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/ruby -w
|
|
2
|
+
# Encoding: UTF-8
|
|
3
|
+
# =========================================================================== #
|
|
4
|
+
# require 'html_tags/toplevel_methods/newline_or_empty.rb'
|
|
5
|
+
# =========================================================================== #
|
|
6
|
+
module HtmlTags
|
|
7
|
+
|
|
8
|
+
# ========================================================================= #
|
|
9
|
+
# === HtmlTags.newline_or_empty
|
|
10
|
+
#
|
|
11
|
+
# Either return a newline or return an empty string.
|
|
12
|
+
# ========================================================================= #
|
|
13
|
+
def self.newline_or_empty(make_newline = true)
|
|
14
|
+
if make_newline
|
|
15
|
+
"\n"
|
|
16
|
+
else
|
|
17
|
+
''
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/ruby -w
|
|
2
|
+
# Encoding: UTF-8
|
|
3
|
+
# frozen_string_literal: true
|
|
4
|
+
# =========================================================================== #
|
|
5
|
+
# require 'html_tags/toplevel_methods/strip_newlines.rb'
|
|
6
|
+
# =========================================================================== #
|
|
7
|
+
module HtmlTags
|
|
8
|
+
|
|
9
|
+
require 'html_tags/constants/array_strip_newlines.rb'
|
|
10
|
+
|
|
11
|
+
# ========================================================================= #
|
|
12
|
+
# === HtmlTags.strip_newlines
|
|
13
|
+
#
|
|
14
|
+
# We use this method to strip away "\n" newlines.
|
|
15
|
+
# ========================================================================= #
|
|
16
|
+
def self.strip_newlines
|
|
17
|
+
ARRAY_STRIP_NEWLINES[0] = true
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# ========================================================================= #
|
|
21
|
+
# === HtmlTags.strip_newlines?
|
|
22
|
+
# ========================================================================= #
|
|
23
|
+
def self.strip_newlines?
|
|
24
|
+
ARRAY_STRIP_NEWLINES.first
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/ruby -w
|
|
2
|
+
# Encoding: UTF-8
|
|
3
|
+
# frozen_string_literal: true
|
|
4
|
+
# =========================================================================== #
|
|
5
|
+
module HtmlTags
|
|
6
|
+
|
|
7
|
+
# ========================================================================= #
|
|
8
|
+
# === VERSION
|
|
9
|
+
# ========================================================================= #
|
|
10
|
+
VERSION = '0.1.183'
|
|
11
|
+
|
|
12
|
+
# ========================================================================= #
|
|
13
|
+
# === LAST_UPDATE
|
|
14
|
+
# ========================================================================= #
|
|
15
|
+
LAST_UPDATE = '19.02.2024'
|
|
16
|
+
|
|
17
|
+
end
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# ============================================================================ #
|
|
2
|
+
# Available HTML5 tags:
|
|
3
|
+
#
|
|
4
|
+
# https://dev.to/flippedcoding/the-ultimate-html5-tag-list-4i2a
|
|
5
|
+
# https://www.w3.org/TR/2012/WD-html-markup-20121025/elements.html
|
|
6
|
+
# https://www.tutorialrepublic.com/html-reference/html5-tags.php
|
|
7
|
+
#
|
|
8
|
+
# ============================================================================ #
|
|
9
|
+
|
|
10
|
+
# - !--...--
|
|
11
|
+
# - !doctype
|
|
12
|
+
- a
|
|
13
|
+
- abbr
|
|
14
|
+
# - acronym # Not available in HTML5, so the html_tag gem will not support it.
|
|
15
|
+
- address
|
|
16
|
+
# - applet # Not available in HTML5, so the html_tag gem will not support it.
|
|
17
|
+
- area
|
|
18
|
+
- article
|
|
19
|
+
- aside
|
|
20
|
+
- audio
|
|
21
|
+
- b
|
|
22
|
+
- base # Not sure if this will be implemented by the html_tag gem.
|
|
23
|
+
- basefont # Not available in HTML5, so the html_tag gem will not support it.
|
|
24
|
+
- bb # Not available in HTML5, so the html_tag gem will not support it.
|
|
25
|
+
- bdo # bdo stands for "bi-directional override".
|
|
26
|
+
- big # Not available in HTML5, so the html_tag gem will not support it.
|
|
27
|
+
- blockquote # Supported by the html_tags gem.
|
|
28
|
+
- body # Supported by the html_tags gem.
|
|
29
|
+
- br #
|
|
30
|
+
- button # Supported by the html_tags gem.
|
|
31
|
+
- canvas # Supported by the html_tags gem.
|
|
32
|
+
- caption # Supported by the html_tags gem.
|
|
33
|
+
- center
|
|
34
|
+
- cite # Supported by the html_tags gem.
|
|
35
|
+
- code # Supported by the html_tags gem.
|
|
36
|
+
- col
|
|
37
|
+
- colgroup
|
|
38
|
+
- command
|
|
39
|
+
- datagrid
|
|
40
|
+
- datalist
|
|
41
|
+
- dd
|
|
42
|
+
- del # Supported by the html_tags gem.
|
|
43
|
+
- details # Supported by the html_tags gem.
|
|
44
|
+
- dfn
|
|
45
|
+
- dialog # Supported by the html_tags gem.
|
|
46
|
+
# - dir # This feature is no longer recommended. See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dir
|
|
47
|
+
- div # Supported by the html_tags gem.
|
|
48
|
+
- dl
|
|
49
|
+
- dt
|
|
50
|
+
- em # Supported by the html_tags gem.
|
|
51
|
+
- embed # This one does not seem that useful anymore.
|
|
52
|
+
# - eventsource # This tag was removed from HTML5, so the HtmlTags won't support it.
|
|
53
|
+
- fieldset # Supported by the html_tags gem.
|
|
54
|
+
- figcaption
|
|
55
|
+
- figure # Supported by the html_tags gem.
|
|
56
|
+
# - font # NOT supported in HTML5.
|
|
57
|
+
- footer # Supported by the html_tags gem.
|
|
58
|
+
- form # Supported by the html_tags gem.
|
|
59
|
+
# - frame # NOT supported in HTML5.
|
|
60
|
+
# - frameset # The <frameset> tag was used in HTML4 to define a frameset. It is not part of HTML5.
|
|
61
|
+
- h1 # Supported by the html_tags gem.
|
|
62
|
+
- h2 # Supported by the html_tags gem.
|
|
63
|
+
- h3 # Supported by the html_tags gem.
|
|
64
|
+
- h4 # Supported by the html_tags gem.
|
|
65
|
+
- h5 # Supported by the html_tags gem.
|
|
66
|
+
- h6 # Supported by the html_tags gem.
|
|
67
|
+
- head # Supported by the html_tags gem.
|
|
68
|
+
- header # Supported by the html_tags gem.
|
|
69
|
+
- hgroup # Supported by the html_tags gem.
|
|
70
|
+
- hr # Supported by the html_tags gem.
|
|
71
|
+
- html # Supported by the html_tags gem.
|
|
72
|
+
- i # Supported by the html_tags gem.
|
|
73
|
+
- iframe # Supported by the html_tags gem.
|
|
74
|
+
- img # Supported by the html_tags gem.
|
|
75
|
+
- input # Supported by the html_tags gem.
|
|
76
|
+
- ins # Supported by the html_tags gem.
|
|
77
|
+
# - isindex # This has been removed from HTML5.
|
|
78
|
+
- kbd # Supported by the html_tags gem. The kbd element represents user input.
|
|
79
|
+
- keygen # Supported by the html_tags gem.
|
|
80
|
+
- label # Supported by the html_tags gem.
|
|
81
|
+
- legend # Supported by the html_tags gem.
|
|
82
|
+
- li # Supported by the html_tags gem.
|
|
83
|
+
- link # Supported by the html_tags gem.
|
|
84
|
+
- map # Supported by the html_tags gem.
|
|
85
|
+
- mark # Supported by the html_tags gem.
|
|
86
|
+
- menu # Supported by the html_tags gem.
|
|
87
|
+
- meta
|
|
88
|
+
- meter
|
|
89
|
+
- nav
|
|
90
|
+
- noframes
|
|
91
|
+
- noscript
|
|
92
|
+
- object # Supported by the html_tags gem.
|
|
93
|
+
- ol
|
|
94
|
+
- optgroup
|
|
95
|
+
- option
|
|
96
|
+
- output
|
|
97
|
+
- p
|
|
98
|
+
- param
|
|
99
|
+
- pre
|
|
100
|
+
- progress # Supported by the html_tags gem.
|
|
101
|
+
- q
|
|
102
|
+
- rp
|
|
103
|
+
- rt
|
|
104
|
+
- ruby
|
|
105
|
+
- s
|
|
106
|
+
- samp
|
|
107
|
+
- script
|
|
108
|
+
- section
|
|
109
|
+
- select
|
|
110
|
+
- small
|
|
111
|
+
- source # Supported by the html_tags gem.
|
|
112
|
+
- span
|
|
113
|
+
- strike
|
|
114
|
+
- strong
|
|
115
|
+
- style # Supported by the html_tags gem.
|
|
116
|
+
- sub
|
|
117
|
+
- summary # Supported by the html_tags gem.
|
|
118
|
+
- sup # Supported by the html_tags gem.
|
|
119
|
+
- table # Supported by the html_tags gem.
|
|
120
|
+
- tbody
|
|
121
|
+
- td
|
|
122
|
+
- textarea # Supported by the html_tags gem.
|
|
123
|
+
- tfoot
|
|
124
|
+
- th # Supported by the html_tags gem.
|
|
125
|
+
- thead # Supported by the html_tags gem.
|
|
126
|
+
- time # Supported by the html_tags gem.
|
|
127
|
+
- title # Supported by the html_tags gem.
|
|
128
|
+
- tr # Supported by the html_tags gem.
|
|
129
|
+
- track # Supported by the html_tags gem.
|
|
130
|
+
# - tt # This is no longer valid as of HTML5.
|
|
131
|
+
- u # Supported by the html_tags gem.
|
|
132
|
+
- ul # Supported by the html_tags gem.
|
|
133
|
+
- var # Supported by the html_tags gem.
|
|
134
|
+
- video # Supported by the html_tags gem.
|
|
135
|
+
- wbr # This is the "Word Break Opportunity" tag.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# =========================================================================== #
|
|
2
|
+
# The listing of allowed elements can be found here:
|
|
3
|
+
#
|
|
4
|
+
# https://www.w3schools.com/tags/tag_head.asp
|
|
5
|
+
#
|
|
6
|
+
# Do note that in HTML5, the <head> element can be omitted.
|
|
7
|
+
# =========================================================================== #
|
|
8
|
+
# The following elements can go inside the <head> element:
|
|
9
|
+
# =========================================================================== #
|
|
10
|
+
- title # This element is required in an HTML document.
|
|
11
|
+
- style
|
|
12
|
+
- base
|
|
13
|
+
- link
|
|
14
|
+
- meta
|
|
15
|
+
- script
|
|
16
|
+
- noscript
|
data/lib/html_tags.rb
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
#!/usr/bin/ruby -w
|
|
2
|
+
# Encoding: UTF-8
|
|
3
|
+
# =========================================================================== #
|
|
4
|
+
require 'cliner/autoinclude' # Make the Cliner module known automatically.
|
|
5
|
+
require 'colours/autoinclude'
|
|
6
|
+
require 'beautiful_url'
|
|
7
|
+
require 'html_tags'
|
|
8
|
+
begin
|
|
9
|
+
require 'colours'
|
|
10
|
+
rescue LoadError; end
|
|
11
|
+
N = "\n"
|
|
12
|
+
Cliner.set_colour 'lightblue'
|
|
13
|
+
|
|
14
|
+
# =========================================================================== #
|
|
15
|
+
# === _
|
|
16
|
+
#
|
|
17
|
+
# Simply colourize the input in a blue colour.
|
|
18
|
+
# =========================================================================== #
|
|
19
|
+
def _(i)
|
|
20
|
+
if Object.const_defined? :Colours
|
|
21
|
+
Colours.slateblue(i)
|
|
22
|
+
else
|
|
23
|
+
bold_blue(i)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# =========================================================================== #
|
|
28
|
+
# === orange
|
|
29
|
+
# =========================================================================== #
|
|
30
|
+
def orange(i)
|
|
31
|
+
Colours.orange(i.chomp)
|
|
32
|
+
end
|
|
33
|
+
cliner {
|
|
34
|
+
e _('Testing some closing tags next (note that '+
|
|
35
|
+
'we will keep trailing newlines:')
|
|
36
|
+
e HtmlTags.close 'p'
|
|
37
|
+
e HtmlTags.close 'div'
|
|
38
|
+
e 'Finished testing closing tags.'
|
|
39
|
+
}; e
|
|
40
|
+
# =========================================================================== #
|
|
41
|
+
# Include the HtmlTags namespace next.
|
|
42
|
+
# =========================================================================== #
|
|
43
|
+
include HtmlTags
|
|
44
|
+
cliner { # Test <p> paragraph next.
|
|
45
|
+
e _('Next testing some <p> paragraphs:')
|
|
46
|
+
e p 'Hello World', :css_style => 'border: 1px solid red'
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
puts Colours.beautiful 'lightblue'
|
|
51
|
+
Cliner.set_colour 'lightblue'
|
|
52
|
+
|
|
53
|
+
# =========================================================================== #
|
|
54
|
+
# Next display all registered HTML tags:
|
|
55
|
+
# =========================================================================== #
|
|
56
|
+
e _('Registered Tags:')
|
|
57
|
+
registered_html_tags?
|
|
58
|
+
e p 'Good Bye', :css_class => 'border: 1px solid red',
|
|
59
|
+
:id => 'goodbye'
|
|
60
|
+
e; e
|
|
61
|
+
|
|
62
|
+
e 'Next, we test the String Good Bye, with a css class and an id.'
|
|
63
|
+
e p 'Good Bye', :css_class => 'border: 1px solid red',
|
|
64
|
+
:id => 'goodbye'
|
|
65
|
+
e
|
|
66
|
+
# =========================================================================== #
|
|
67
|
+
# Next, we will test the <a> tag.
|
|
68
|
+
# =========================================================================== #
|
|
69
|
+
cliner {
|
|
70
|
+
e _('Next we will test the <a> tag in various combinations.')
|
|
71
|
+
e orange(a('connect'))
|
|
72
|
+
e orange(a('connect', :no_newline))
|
|
73
|
+
e orange(a('connect', :make_newline))
|
|
74
|
+
e orange(a('LINUX_DESIGNING.cgi', :copy_description))
|
|
75
|
+
e orange(a('connect', 'marl1em','great_link','color: blue'))
|
|
76
|
+
e orange(a('/test', :description => 'Link to test'))
|
|
77
|
+
e orange(a('/test', css_style: 'margin-left:1em'))
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
e N+N+_('Next testing the <tbody> tag.')
|
|
81
|
+
e HtmlTags.tbody 'testing','this'
|
|
82
|
+
e N+N+_('Now testing the output of the BR tag:')
|
|
83
|
+
e HtmlTags::BR
|
|
84
|
+
e N+N+_('Next, we try to find out whether ch4() works:')
|
|
85
|
+
e ch4.lstrip
|
|
86
|
+
e N+N+_('Next, testing whether cbody() and chtml() works:')
|
|
87
|
+
e orange(cbody+chtml)
|
|
88
|
+
pp cbody+chtml
|
|
89
|
+
HtmlTags.strip_newlines
|
|
90
|
+
e cbody+chtml
|
|
91
|
+
pp cbody+chtml
|
|
92
|
+
e N+N+_('Next checking whether <hr> and <bb> are valid HTML tags:')
|
|
93
|
+
e is_valid_html? '<hr>'
|
|
94
|
+
e is_valid_html? '<bb>'
|
|
95
|
+
e N+N+_('Next testing the method stag() for capturing HTML tags as strings:')
|
|
96
|
+
e stag('span', 'padl1em')
|
|
97
|
+
cliner {
|
|
98
|
+
e N+_('Next testing comments in .html files:')
|
|
99
|
+
e HtmlTags.html_comment('This is a comment.')
|
|
100
|
+
}
|
|
101
|
+
e N+_('Next testing <span> with a hash as second argument:')+N+N
|
|
102
|
+
e span('wget', :css_style => 'margin-left:2em')
|
|
103
|
+
e orange(HtmlTags.stag('h3', :javascript => 'on-click: { this.color = "blue" }'))
|
|
104
|
+
e orange(HtmlTags.stag('h2', 'ud mart10px'))
|
|
105
|
+
cliner
|
|
106
|
+
e N+N+_('Next, we will test whether we can use button() combined with blocks:')+N+N
|
|
107
|
+
e orange(button('Click me!', 'pad1em', 'yo', '', :on_click => 'go back in history'))
|
|
108
|
+
e orange(HtmlTags.link 'http://google.com')
|
|
109
|
+
e orange(HtmlTags.link 'http://google.com', :desc => 'Google')
|
|
110
|
+
# x = HtmlTags.stag( :button, 'pad1em', 'yo', '', :on_click => 'go back in history') {{ :value => 'yo man' }}
|
|
111
|
+
e orange(stag 'h3', id: 'yo')
|
|
112
|
+
e orange(stag 'h3', id: 'yo', css_class: 'ok')
|
|
113
|
+
e orange(stag 'h3', id: 'yo', css_class: 'blue', css_style: 'margin:5em')
|
|
114
|
+
e orange(stag 'h3', id: 'yo', css_class: 'blue', css_style: 'margin:5em', content: 'yo there')
|
|
115
|
+
e orange(h3 'oki doki', id: 'hmm')
|
|
116
|
+
e 'We will next test the storage-functionality of HtmlTags:'
|
|
117
|
+
e 'First we clear the old entries.'
|
|
118
|
+
HtmlTags.clear
|
|
119
|
+
e
|
|
120
|
+
e 'Now we run three <h2> statements.'
|
|
121
|
+
h2 'Test'
|
|
122
|
+
h2 'Yo'
|
|
123
|
+
h2 'Hello world!'
|
|
124
|
+
e 'Next we show these:'
|
|
125
|
+
e orange(HtmlTags[])
|
|
126
|
+
e 'Now we clear it again. Then we run HtmlTags.clear'
|
|
127
|
+
HtmlTags.clear
|
|
128
|
+
e orange(HtmlTags.add 'hello', 'world!')
|
|
129
|
+
e orange(HtmlTags.add 'hello')
|
|
130
|
+
e 'Now we will check whether the 3 following HTML Tags are valid within a <head> element:'
|
|
131
|
+
e orange('p: ')+is_this_an_allowed_tag_in_head_element?('p').to_s
|
|
132
|
+
e orange('<div>: ')+is_this_an_allowed_tag_in_head_element?('<div>').to_s
|
|
133
|
+
e orange('<base>: ')+is_this_an_allowed_tag_in_head_element?('<base>').to_s
|
|
134
|
+
e
|
|
135
|
+
e "Next we will test: HtmlTags.a('google.com','Go to Google') {{ description: 'yo there' }}"
|
|
136
|
+
e
|
|
137
|
+
e ' '+orange(HtmlTags.a('google.com','s1em') {{ description: 'yo there' }}).delete(N)
|
|
138
|
+
e
|
|
139
|
+
cliner
|
|
140
|
+
e 'Next we will test '+orange('label()')+':'
|
|
141
|
+
e
|
|
142
|
+
e HtmlTags.label 'John Doe'
|
|
143
|
+
e
|
|
144
|
+
cliner
|
|
145
|
+
e h2('Showing the axe-icon next', 'marl1em','','',
|
|
146
|
+
'on_click: show_image(:axe))') # Last one is javascript.
|
|
147
|
+
cliner
|
|
148
|
+
e 'Next testing:'
|
|
149
|
+
e "HtmlTags.a(BeautifulUrl[:my_gems], description: 'my gems')"
|
|
150
|
+
e HtmlTags.a(BeautifulUrl[:my_gems], description: 'my gems')
|
|
151
|
+
cliner
|
|
152
|
+
e 'HtmlTags.h2(text, css_class, the_id, css_style, javascript)'
|
|
153
|
+
e HtmlTags.h2('Hello world!','mars1em','','','onmouseover="this.style.textDecoration=\'underline\';"')
|
|
154
|
+
cliner
|
|
155
|
+
e 'Next testing the HtmlTags.img() tag:'
|
|
156
|
+
e "HtmlTags.img('foobar.png')"
|
|
157
|
+
e HtmlTags.img('foobar.png')
|
|
158
|
+
# ttags
|