Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
== Outdated egg! This is an egg for CHICKEN 3, the unsupported old release. You're almost certainly looking for [[/eggref/4/html-stream|the CHICKEN 4 version of this egg]], if it exists. If it does not exist, there may be equivalent functionality provided by another egg; have a look at the [[https://wiki.call-cc.org/chicken-projects/egg-index-4.html|egg index]]. Otherwise, please consider porting this egg to the current version of CHICKEN. [[tags:web html streams eggs eggs-web]] [[toc:]] == html-stream === Introduction Small, functional and highly optimized HTML generator, generating srfi-40 streams of characters. === Examples ==== Generating HTML The following code evaluates to a stream of characters in HTML: <enscript highlight=scheme>(use html-stream) (stream->string (html-stream (p (i "The squares of the first " (b "five") " integers are:")) (ul (apply stream-append (map (lambda (x) (html-stream (li (* x x)))) (iota 5 1))))))</enscript> ==== Removing HTML comments from a stream The following code reads HTML from the current-input-port, removes HTML comments and writes the output: <enscript highlight=scheme>(use stream-ext html-stream) (write-stream (remove-comments (port->stream (current-input-port)))</enscript> === Authors The html-stream egg was created by [[Alejandro Forero Cuervo]]. === License The html-stream egg for Chicken Scheme is in the public domain and may be reproduced or copied without permission from its author. Citation of the source is appreciated. === Requirements This egg depends on the following: * srfi-40 * stream-parser * stream-ext === Rendering an HTML stream <enscript highlight=scheme>(html-stream tag1 ...)</enscript> {{html-stream}} is used to generate HTML from a simple and straight-forward format. A {{(html-stream ...)}} form will evaluate to a srfi-40 stream of characters with its associated contents. Each expresion inside a {{html-stream}} macro may have any of the following forms: ==== Tag definition <enscript highlight=scheme>((tag param0 ...) arg0 ...)</enscript> If {{tag}} is recognized as the name of an HTML tag, this expresion expands to an HTML tag with the arguments specified by the {{param0 ...}} list. This list must have an even number of elements: the even elements must be symbols for the parameter names, followed by their actual values (which must have a type accepted by {{->stream-char}}). The forms {{arg0 ...}} are parsed recursively and their values included inside the HTML tag.</p> Examples: <enscript highlight=scheme>(html-stream ((a href "index.html" title "Some Title") "Home Page")) ==> #,(stream "<a href='index.html' title='Some Title'>Home Page</a>") (html-stream ((img src "photo.jpeg" height 150 width 150 alt "Yes"))) ==> #,(stream "<img src='photo.jpeg' height=150 width=150 alt='Yes'/>")</enscript> ==== Shorthand for tag definition <enscript highlight=scheme>(tag arg0 ...)</enscript> If {{tag}} is the name of an HTML tag, an HTML tag with no parameters is generated. The arguments {{arg0 ...}} are parsed recursively. Note that this form is just an alias for {{((tag) arg0 ...)}}. Examples: <enscript highlight=scheme>(html-stream (p "My name is " (b "Alejo") "."))</enscript> ==== Other expresions Other expresions not having any of the two forms above will be evaluated (at runtime), their results passed to {{->stream-char}} and the resulting streams added to the result. === Tags recognized: The library recognizes the following HTML tags: {{style}}, {{html}}, {{head}}, {{title}}, {{body}}, {{p}}, {{a}}, {{b}}, {{i}}, {{ul}}, {{ol}}, {{li}}, {{dl}}, {{dt}}, {{dd}}, {{table}}, {{tr}}, {{td}}, {{thead}}, {{th}}, {{tbody}}, {{h1}}, {{h2}}, {{h3}}, {{h4}}, {{h5}}, {{h6}}, {{div}}, {{span}}, {{small}}, {{big}}, {{script}}, {{select}}, {{option}}, {{textarea}}, {{center}}, {{form}}, {{pre}}, {{frameset}}, {{strong}}, {{em}}, {{tt}}, {{code}}, {{blockquote}}, {{object}}, {{embed}}, {{label}}, {{img}}, {{br}}, {{hr}}, {{meta}}, {{input}}, {{link}}, {{frame}}, {{param}}, {{base}}. === Removing comments <enscript highlight=scheme>(remove-comments str)</enscript> {{remove-comments}} is provided as a convenience function to, well, remove HTML comments from a stream of characters. === Version history ==== 1.5 * Adding {{stream-html-escape}}. ==== 1.4 * Adding {{text->html-id}}. ==== Previos releases ;1.3 : Adding support for more tags: {{label}}. Proper escaping of characters inside tag parameters, to make the output closer to being XML conformant. ;1.2 : Adding support for more tags: {{base}}. Use documentation from wiki. ;1.1 : Adding support for more tags: {{th}}, {{font}}, {{frameset}}, {{strong}}, {{em}}, {{tt}}, {{code}}, {{blockquote}}, {{link}}, {{frame}}. ;1.0 : First release
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you multiply 8 by 1?