From 21fd5c66eecedddd0bf33379a6d3731ea6ea3a7e Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Fri, 6 Jan 2023 16:22:15 -0600 Subject: Add plugins Plugins go in the vienna directory as hidden .sh files. They're sourced by vienna so pages or whatever can use them. --- plugins/el.sh | 202 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 202 insertions(+) create mode 100644 plugins/el.sh (limited to 'plugins') 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 @@ +# el.sh --- insert html elements using sh + +### Code: + +el() { # el NAME ARGS... + ## Create an HTML element named NAME using ARGS. + # Any ARGS that contain an equals sign will be made into attributes of the + # element, until the special argument '--' which will stop attribute + # processing. While some nesting is possible with 'el', the way bash + # expansion works it's not great. + # + # No validation is done on any arguments in this function. It could create + # something that looks vaguely like an HTML element but isn't valid. + _name="$1"; shift || return 1 # Require at least an element name + _element="\\<$_name" + _content="" + _process_args=true + + while test -n "$1"; do + case "$1" in + --) if "$_process_args"; then + _process_args=false + else + _content="$_content${_content:+ }$1" + fi + ;; + *=*) + if "$_process_args"; then + _element="$_element ${1%%=*}=\"${1#*=}\"" + else + _content="$_content${_content:+ }$1" + fi + ;; + *) + if "$_process_args"; then + _process_args=false + fi + _content="$_content${_content:+ }$1" + ;; + esac + shift + done + _element="$_element\\>" + printf '%s%s\\\n' "$_element" "$_content" "$_name" +} + +### HTML5 element aliases +## These come from https://developer.mozilla.org/en-US/docs/Web/HTML/Element + +# To avoid clobbering the shell's namespace, a prefix is used. Change this +# variable when sourcing el.sh in order to change or disable the prefix. E.g.: +# $ EL_PREFIX= . ./el.sh +# $ EL_PREFIX=HTML . ./el.sh +: "${EL_PREFIX:=_}" + +for e in \ + html \ + base \ + head \ + link \ + meta \ + style \ + title \ + body \ + address \ + article \ + aside \ + footer \ + header \ + h1 \ + h2 \ + h3 \ + h4 \ + h5 \ + h6 \ + main \ + nav \ + section \ + blockquote \ + dd \ + div \ + dl \ + dt \ + figcaption \ + figure \ + hr \ + li \ + menu \ + ol \ + p \ + pre \ + ul \ + a \ + abbr \ + b \ + bdi \ + bdo \ + br \ + cite \ + code \ + data \ + dfn \ + em \ + i \ + kbd \ + mark \ + q \ + rp \ + rt \ + ruby \ + s \ + samp \ + small \ + span \ + strong \ + sub \ + sup \ + time \ + u \ + var \ + wbr \ + area \ + audio \ + img \ + map \ + track \ + video \ + embed \ + iframe \ + object \ + picture \ + portal \ + source \ + svg \ + math \ + canvas \ + noscript \ + script \ + del \ + ins \ + caption \ + col \ + colgroup \ + table \ + tbody \ + td \ + tfoot \ + th \ + thead \ + tr \ + button \ + datalist \ + fieldset \ + form \ + input \ + label \ + legend \ + meter \ + optgroup \ + option \ + output \ + progress \ + select \ + textarea \ + details \ + dialog \ + summary \ + slot \ + template \ + acronym \ + applet \ + bgsound \ + big \ + blink \ + center \ + content \ + dir \ + font \ + frame \ + frameset \ + image \ + keygen \ + marquee \ + menuitem \ + nobr \ + noembed \ + noframes \ + param \ + plaintext \ + rb \ + rtc \ + shadow \ + spacer \ + strike \ + tt \ + xmp \ + ; do + eval "alias $EL_PREFIX$e='el $e'" +done + + +# el.sh ends here -- cgit 1.4.1-21-gabe81