html-writing: Writing HTML from SXML/xexp in Racket
(require (planet neil/html-writing:2:0)) |
1 Introduction
2 Foreign Filters
(current-html-writing-foreign-filter) → !!! (current-html-writing-foreign-filter ff) → void? ff : !!!
3 Writing Procedures
!!! The two most common procedures in html-writing for writing HTML from an SXML/xexp representation are write-html and xexp->html. These are perhaps most useful for emitting the result of parsed and transformed input HTML. They can also be used for emitting HTML from generated or handwritten SXML/xexp.
3.1 Writing Attributes
3.2 Writing Other
3.3 Writing HTML
(write-html '((html (head (title "My Title")) (body (@ (bgcolor "white")) (h1 "My Heading") (p "This is a paragraph.") (p "This is another paragraph.")))) (current-output-port))
<html><head><title>My Title</title></head><body bgcolor="white"><h1>My Heading</h1><p>This is a paragraph.</p><p>This isanother paragraph.</p></body></html>
> (xexp->html (html->xexp "<P>This is<br<b<I>bold </foo>italic</ b > text.</p>")) "<p>This is<br><b><i>bold italic</i></b> text.</p>"
4 History
- PLaneT 2:0 —
2012-06-12 Heavy API and implementation changes (although the previous version was not really documented), including the following.
All out arguments are now mandatory rather than optional.
All foreign-filter arguments have been removed.
Foreign filter context value symbol renamed from 'attribute (singular) to 'attributes (plural).
The suffix /fixed has been removed from all identifiers, since all procedures now have fixed arguments.
write-html-attribute-or-list is renamed to write-html-attributes.
write-html-attribute-value-string is renamed to write-html-attribute-value-part-string.
Added html->bytes and html-attribute-value->bytes.
We no longer do backward-compatible XHTML empty element terminators like the string " />"; now they’re just ">".
In attribute values, some additional characters are now written as numeric character references: ASCII 0 through 31, and 127.
Got rid of the *splice* form that we have experimentally added, and philosophically switched back to SXML’s arbitrarily nested lists for splicing with generally less allocation.
Restored some of the handling of unnecessary list nesting in SXML/xexp, which had been removed after forking from HtmlPrag and a brief experiment with *splice* when trying to unify SXML and PLT xexprs.
Converted to McFly and Overeasy.
- Version 0.1 —
PLaneT 1:0 — 2011-08-21 Part of forked development from HtmlPrag, with substantial changes.
5 Legal
Copyright 2004 – 2012 Neil Van Dyke. This program is Free Software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License,or (at your option) any later version. This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. See http://www.gnu.org/licenses/ for details. For other licenses and consulting, please contact the author.