/* * htmlfilter.aikido * * Aikido Language System, * export version: 1.00 * Copyright (c) 2002 Sun Microsystems, Inc. * * Sun Public License Notice * * The contents of this file are subject to the Sun Public License Version 1.0 (the "License"). You * may not use this file except in compliance with the License. A copy of the License is available * at http://www.opensource.org/licenses/sunpublic.php * * The Original Code is Aikido. * The Initial Developer of the Original Code is David Allison on behalf of Sun Microsystems, Inc. * Copyright (C) Sun Microsystems, Inc. 2000-2003. All Rights Reserved. * * * Contributor(s): dallison * * Version: 1.4 * Created by dallison on 4/19/2002 * Last modified by dallison on 03/07/29 */ class HTMLFilter (instream, outstream) { outstream.putHeader ("Content-type", "text/html") var headersent = false public function setContentLength (len) { outstream.setContentLength (len) } public function title (text) { ["<title>", text, "</title>\n"] -> outstream } public function header (level, text) { ["<h", level, ">", text, "</h", level, ">\n"] -> outstream } public function beginHTML() { "<html>\n" -> outstream } public function endHTML() { "</html>\n" -> outstream } public function beginHead() { "<head>\n" -> outstream } public function endHead() { "</head>\n" -> outstream } public function beginBody() { "<body>\n" -> outstream } public function endBody() { "</body>\n" -> outstream } public function beginPreformatted() { "<pre>\n" -> outstream } public function endPreformatted() { "</pre>\n" -> outstream } public function rule() { "<hr>" -> outstream } public function link (url, text) { ["<a href=\"", url, "\">", text, "</a>\n"] -> outstream } public function paragraph() { "<p>" -> outstream } public operator -> (data, isout) { if (isout) { if (!headersent) { headersent = true "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n" -> outstream } data -> outstream } else { } } }