Jaq Html

I hand code all my webpages. Because of this it can be very annoying when you have to repeat a number of commands many times with only slight changes. So I want macros! Unfortunately html does not support macros so I had to extend it.
To define a macro you write:
<macro macroname> substitutehtmlcode </macro>
You can also specify arguments to the macro:
<macro newid arg1 ... argN> htmlcode argn html</macro>
An example:
<HTML>
<HEAD></HEAD>
<BODY><h1>Let's see what you can do with macros!</h1>

<macro jtd jcolor> <td bgcolor="#jcolor"><font size=+1></macro>
<macro /jtd></font><font size=-1><sup>tm</sup></font></td></macro>

<table border=1>
<tr><jtd FF0000> Adam   </jtd><jtd FF00FF> Karl   </jtd></tr>
<tr><jtd FF2000> Bertil </jtd><jtd E000FF> Bertil </jtd></tr>
<tr><jtd FF4000> David  </jtd><jtd C000FF> Jon    </jtd></tr>
<tr><jtd FF6000> Evert  </jtd><jtd A000FF> Erik   </jtd></tr>
<tr><jtd FF8000> Fjodor </jtd><jtd 8000FF> Sigurd </jtd></tr>
<tr><jtd FFA000> Guran  </jtd><jtd 6000FF> Magnus </jtd></tr>
<tr><jtd FFC000> Hans   </jtd><jtd 4000FF> Marcus </jtd></tr>
<tr><jtd FFE000> Isabel </jtd><jtd 2000FF> Eva    </jtd></tr>
<tr><jtd FFFF00> Jonas  </jtd><jtd 0000FF> Frida  </jtd></tr>
</table>
With macros expanded the source would look something like this:
<HTML>
<HEAD></HEAD>
<BODY><h1>Let's see what you can do with macros!</h1>




<table border=1>
<tr> <td bgcolor="#FF0000"><font size=+1> Adam   </font><font size=-1><sup>tm</sup></font></td> <td bgcolor="#FF00FF"><font size=+1> Karl   </font><font size=-1><sup>tm</sup></font></td></tr>
<tr> <td bgcolor="#FF2000"><font size=+1> Bertil </font><font size=-1><sup>tm</sup></font></td> <td bgcolor="#E000FF"><font size=+1> Bertil </font><font size=-1><sup>tm</sup></font></td></tr>
<tr> <td bgcolor="#FF4000"><font size=+1> David  </font><font size=-1><sup>tm</sup></font></td> <td bgcolor="#C000FF"><font size=+1> Jon    </font><font size=-1><sup>tm</sup></font></td></tr>
<tr> <td bgcolor="#FF6000"><font size=+1> Evert  </font><font size=-1><sup>tm</sup></font></td> <td bgcolor="#A000FF"><font size=+1> Erik   </font><font size=-1><sup>tm</sup></font></td></tr>
<tr> <td bgcolor="#FF8000"><font size=+1> Fjodor </font><font size=-1><sup>tm</sup></font></td> <td bgcolor="#8000FF"><font size=+1> Sigurd </font><font size=-1><sup>tm</sup></font></td></tr>
<tr> <td bgcolor="#FFA000"><font size=+1> Guran  </font><font size=-1><sup>tm</sup></font></td> <td bgcolor="#6000FF"><font size=+1> Magnus </font><font size=-1><sup>tm</sup></font></td></tr>
<tr> <td bgcolor="#FFC000"><font size=+1> Hans   </font><font size=-1><sup>tm</sup></font></td> <td bgcolor="#4000FF"><font size=+1> Marcus </font><font size=-1><sup>tm</sup></font></td></tr>
<tr> <td bgcolor="#FFE000"><font size=+1> Isabel </font><font size=-1><sup>tm</sup></font></td> <td bgcolor="#2000FF"><font size=+1> Eva    </font><font size=-1><sup>tm</sup></font></td></tr>
<tr> <td bgcolor="#FFFF00"><font size=+1> Jonas  </font><font size=-1><sup>tm</sup></font></td> <td bgcolor="#0000FF"><font size=+1> Frida  </font><font size=-1><sup>tm</sup></font></td></tr>
</table>
The table defined above would look something like:

Let's see what you can do with macros!

Adam tm Karl tm
Bertil tm Bertil tm
David tm Jon tm
Evert tm Erik tm
Fjodor tm Sigurd tm
Guran tm Magnus tm
Hans tm Marcus tm
Isabel tm Eva tm
Jonas tm Frida tm
A more extensive example can be found in demo.jhtml and demo.html. Please note that your browser will most likely regard demo.jhtml as an html file and because of this will not be able to view it. Instead you should view the source for both the files and compare the difference.
To use Jaq Html you need some kind of compiler that compiles .jhtml files to .html. I made one in emacs lisp. A friend of mine (Jonas S Karlsson) implemented the compiler in Perl.


Mail me: jaq@lysator.liu.se
Last change:


Back home.