I'm looking for a solution that allows me to write native Emacs Lisp code and at compile time turns it into HTML, like Franz's htmlgen:
(html
((:div class "post")
(:h1 "Title")
(:p "Hello, World!")))
Of course I can write my own macros, but I'm interested if there are any projects around this problem.
As you found out,
xmlgen
generates XML from a list structure. What I did find disappointing with the ``xmlgen` package that the format it supports is not quite the inverse of Emacs' xml parser.I did add this to my copy of xmlgen:
Note: the interface for this is
xml-gen
(notxmlgen
which is the original parsing).With this interface, the following holds:
and
The new
xml-gen
does not strive to preserve the whitespace around that thexml-parse-region
routine generates.This could be a starting point: http://www.emacswiki.org/emacs/HtmlLite
Meanwhile, I found some code that contains something similar I want. Now I can write:
The implementation has a few limitations (e.g. hard-coded element list), but it seems to be a good starting point.
This is not quite what you're looking for, but there's a 20 minute video where a guy creates a simple website using UCW, the UnCommon Web application framework. It's all done in Emacs using lisp...
Here is a link to the transcript (all the code (~25 lines) is available at the end of the transcript).
I had a similar requirement to be able to parse xml using xml-parse functions, transform it, and then output it back as a xml string.
Trey's solution almost worked except I needed to retain the whitespace xml elements. So I wrote my own implementation here:
https://github.com/upgradingdave/xml-to-string