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