HTML Shorthand

HTML by itself is a very verbous document language with lengthy opening and ending tags and detailed attribute descriptions. This makes writing HTML tedious and error prone. Many web authors resort to markup languages like retext or markdown. Naturally however, all markup languages include only the most common subset of HTML functionality, limiting an authors abilty to define complex document structures, class attributes, and even some HTML tags.

Enter Shorthand

Shorthand aims to be a simplified notation of HTML. It lets you enter arbitrary tags and attributes, without the unnecessary verbosity of plain HTML. It lets you build the full document structure including the HTML header, empty elements, wrappers, input forms, and so on.

Shorthand is written in sed script. A sed interpreter is availale in all posix compliant Unices, including GNU Linux and busybox based OSes.

Shorthand is developed as part of cgilite, but can be used standalone.


you can either clone the entire cgilite repository, or just download the plain scripts file:

$ git clone

File Download

How it works

Here is an example

[html [head
  [title Example]
  [link rel="stylesheet" type="text/css" href="style.css"]
  [h1 Headline]
  [p You can also define classes and IDs]
  [form #search method="POST" action="/search"
     [input name="q" placeholder="Search"]
  [pre .code \[p a Shorthand example\]]


[tag .foo #id .bar  narf="noob"  Content also="content"]

is equivalent to

<tag class="foo bar" id="id" narf="noob">Content also="content"</tag>


There are a few simplifications, e.g.

[a "" link]

will turn into a link, with the first item in quotes becoming href.

here is the source code of this document

that's it.


The shorthand script reads shorthand notation from stdin and prints HTML to stdout. Text is processed line by line, so it can be streamed from CGI-like programs.

$ html-sh.sed < input.short > output.html


$ printf '[html [head [title Title]][body \n %s \n ]]' "$muchtext" |html-sh.sed

Tags that are not closed by the end of the input will automatically be closed.