HTML-from-sexpr

Things similar to the built-in function (library? I haven't looked at it yet) in Araneida which makes HTML from a sexpr.

For an example, see htout.

For the more general case, see XML.

I was quite interested in something like this, as a toy for generating HTML (either by preprocessing or some CGI hack). I was considering writing a minimal Lisp interpretter in Perl .. oh the putrid irony! I'm a Lisp newbie who suspects that a Lisp-like language would be ideal for the next project.

Representations

Boilerplate? Well it looks like a server-side include.

You don't say whether this is code or data. The function in Araneida uses a representation like your second example above, but as data. We use backquote and comma to splice expressions into the html.

Um ... both? It's data to start with. If it were mine or generated by code I trusted, I would just execute it to get back the large string containing text/html. If it may be hostile I would have to write a mini lisp interpretter (yes? or am I deluded?).

Whence?

  1. Program generated, for example a Lisp CGI Eliza.
  2. Written as Lisp source by some nutter who wants to have a non-standard home page.
  3. Parsed from a text/html document loaded from somewhere. I'm sorely tempted to cram a perl parser in any way it will fit because I know how to do the parser: use HTML::PullParser;

You can actually do much more interesting things using the s-exp approach. You can create you own elements and attach functions which create html based on the content e.g. I use an 'MCQ element to present multiple choice questions in forms. I also attach preprocessing functions to different symbols to e.g. generate required images (such as equations) for the web page as a side effect. I am also assigning functioanlity to convert the markup to latex for creation of pdf files on the fly i.e. you don't have to limit yourself to HTML - the markup can match your problem space and them be mapped to html, or latex, or whatever. (JARW)

Validation

Bonus points for finding a really horrible way to enforce the DTD's rules. Remapping symbols to (raise "You can't put that there") ?

Here's a lispy XML validator: xml-psychiatrist


In addition to htout, consider lml, htmlgen, and Le Sursis.

This page is linked from: araneida   Cut and shut   heredocs in lisp   HTML-TEMPLATE   Lisp Markup Languages  

CLiki pages can be edited by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively