about summary refs log tree commit diff stats
path: root/plugins/el.sh
diff options
context:
space:
mode:
authorCase Duckworth2023-01-06 16:22:15 -0600
committerCase Duckworth2023-01-06 16:22:15 -0600
commit21fd5c66eecedddd0bf33379a6d3731ea6ea3a7e (patch)
tree28840f252aa32351de7cbcb2700af6c19ecd6a95 /plugins/el.sh
parentRemove trailing --> (diff)
downloadvienna-21fd5c66eecedddd0bf33379a6d3731ea6ea3a7e.tar.gz
vienna-21fd5c66eecedddd0bf33379a6d3731ea6ea3a7e.zip
Add plugins
Plugins	go in the vienna directory as hidden .sh files.  They're sourced by
vienna so pages or whatever can use them.
Diffstat (limited to 'plugins/el.sh')
-rw-r--r--plugins/el.sh202
1 files changed, 202 insertions, 0 deletions
diff --git a/plugins/el.sh b/plugins/el.sh new file mode 100644 index 0000000..6d0780a --- /dev/null +++ b/plugins/el.sh
@@ -0,0 +1,202 @@
1# el.sh --- insert html elements using sh
2
3### Code:
4
5el() { # el NAME ARGS...
6 ## Create an HTML element named NAME using ARGS.
7 # Any ARGS that contain an equals sign will be made into attributes of the
8 # element, until the special argument '--' which will stop attribute
9 # processing. While some nesting is possible with 'el', the way bash
10 # expansion works it's not great.
11 #
12 # No validation is done on any arguments in this function. It could create
13 # something that looks vaguely like an HTML element but isn't valid.
14 _name="$1"; shift || return 1 # Require at least an element name
15 _element="\\<$_name"
16 _content=""
17 _process_args=true
18
19 while test -n "$1"; do
20 case "$1" in
21 --) if "$_process_args"; then
22 _process_args=false
23 else
24 _content="$_content${_content:+ }$1"
25 fi
26 ;;
27 *=*)
28 if "$_process_args"; then
29 _element="$_element ${1%%=*}=\"${1#*=}\""
30 else
31 _content="$_content${_content:+ }$1"
32 fi
33 ;;
34 *)
35 if "$_process_args"; then
36 _process_args=false
37 fi
38 _content="$_content${_content:+ }$1"
39 ;;
40 esac
41 shift
42 done
43 _element="$_element\\>"
44 printf '%s%s\\</%s\\>\n' "$_element" "$_content" "$_name"
45}
46
47### HTML5 element aliases
48## These come from https://developer.mozilla.org/en-US/docs/Web/HTML/Element
49
50# To avoid clobbering the shell's namespace, a prefix is used. Change this
51# variable when sourcing el.sh in order to change or disable the prefix. E.g.:
52# $ EL_PREFIX= . ./el.sh
53# $ EL_PREFIX=HTML . ./el.sh
54: "${EL_PREFIX:=_}"
55
56for e in \
57 html \
58 base \
59 head \
60 link \
61 meta \
62 style \
63 title \
64 body \
65 address \
66 article \
67 aside \
68 footer \
69 header \
70 h1 \
71 h2 \
72 h3 \
73 h4 \
74 h5 \
75 h6 \
76 main \
77 nav \
78 section \
79 blockquote \
80 dd \
81 div \
82 dl \
83 dt \
84 figcaption \
85 figure \
86 hr \
87 li \
88 menu \
89 ol \
90 p \
91 pre \
92 ul \
93 a \
94 abbr \
95 b \
96 bdi \
97 bdo \
98 br \
99 cite \
100 code \
101 data \
102 dfn \
103 em \
104 i \
105 kbd \
106 mark \
107 q \
108 rp \
109 rt \
110 ruby \
111 s \
112 samp \
113 small \
114 span \
115 strong \
116 sub \
117 sup \
118 time \
119 u \
120 var \
121 wbr \
122 area \
123 audio \
124 img \
125 map \
126 track \
127 video \
128 embed \
129 iframe \
130 object \
131 picture \
132 portal \
133 source \
134 svg \
135 math \
136 canvas \
137 noscript \
138 script \
139 del \
140 ins \
141 caption \
142 col \
143 colgroup \
144 table \
145 tbody \
146 td \
147 tfoot \
148 th \
149 thead \
150 tr \
151 button \
152 datalist \
153 fieldset \
154 form \
155 input \
156 label \
157 legend \
158 meter \
159 optgroup \
160 option \
161 output \
162 progress \
163 select \
164 textarea \
165 details \
166 dialog \
167 summary \
168 slot \
169 template \
170 acronym \
171 applet \
172 bgsound \
173 big \
174 blink \
175 center \
176 content \
177 dir \
178 font \
179 frame \
180 frameset \
181 image \
182 keygen \
183 marquee \
184 menuitem \
185 nobr \
186 noembed \
187 noframes \
188 param \
189 plaintext \
190 rb \
191 rtc \
192 shadow \
193 spacer \
194 strike \
195 tt \
196 xmp \
197 ; do
198 eval "alias $EL_PREFIX$e='el $e'"
199done
200
201
202# el.sh ends here