Created: 2008-09-10 20:37
Updated: 2018-08-10 01:48


nom: Nu on Markup

nom (all lowercase, please) is a Nu library designed to translate s-expressions into HTML code. Because HTML (and XML) are basically reinventions of s-expressions, there is a pleasant isomorphism between the two. nom can translate a given s-expression or the contents of a file into HTML code. Here's an example of a valid, nom-translatable s-expression (found in test/

          (title "Nuki!")
          (meta (http-equiv: "Content-Type" content:"text-html")))
        (div (id:"main")
             (div (id:"header")
                "I'm a header!"))))

And here's the output from running (nom "test/"):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN" "">
    <meta http-equiv="Content-Type" content="text-html" />
    <div id="main">
      <div id="header">
I'm a header!


nom was written in the course of a few days. The chapter from Practical Common Lisp in which Seibel writes an HTML generation library was an indispensable resource, though the nom codebase is much shorter than the corresponding Common Lisp code. :-) I am aware of Dean Mao's NuSAX, but wrote nom to solve a very different problem - whereas NuSAX is designed for serialization and marshaling s-expressions to XML, nom is intended to make writing HTML as painless as possible. Much like Haml, nom is designed to make HTML as concise as possible, and as such comes with utility functions to make certain HTML idioms easy.

Caveat Programmator

nom has not been tested in a production environment, and was written as an intellectual exercise. It may be very slow on large data sets, it may crash, and it is probably filled with every kind of bug imaginable. I am in no way responsible for any catastrophes that may occur. nom is released under the Apache License, v2.0, but I would appreciate a kind email or postcard if you use or like it.


As of right now, I cannot figure out how to make nom write to a string rather than standard output or a file. If you have any suggestions, please let me know. Pull requests are encouraged and accepted.

nom also needs more helper functions.

Parts of the code are really shifty, but I'm tired of sitting on this.


Tim Burks, for creating my favorite programming language Hampton Caitlin, for writing Haml. Peter Siebel's Practical Common Lisp, which was invaluable.

Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more