# HG changeset patch # User wenzelm # Date 1259963519 -3600 # Node ID c54498f88a77a58eb6792e8a27eb5c974ce92ee7 # Parent cfbf1ff6170d00f8a3300dc362b6c6627c0e75fc Basic HTML output. diff -r cfbf1ff6170d -r c54498f88a77 src/Pure/IsaMakefile --- a/src/Pure/IsaMakefile Fri Dec 04 20:03:37 2009 +0100 +++ b/src/Pure/IsaMakefile Fri Dec 04 22:51:59 2009 +0100 @@ -128,7 +128,7 @@ System/cygwin.scala System/gui_setup.scala \ System/isabelle_process.scala System/isabelle_syntax.scala \ System/isabelle_system.scala System/platform.scala \ - Thy/completion.scala Thy/thy_header.scala + Thy/completion.scala Thy/html.scala Thy/thy_header.scala JAR_DIR = $(ISABELLE_HOME)/lib/classes PURE_JAR = $(JAR_DIR)/Pure.jar diff -r cfbf1ff6170d -r c54498f88a77 src/Pure/Thy/html.scala --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Pure/Thy/html.scala Fri Dec 04 22:51:59 2009 +0100 @@ -0,0 +1,41 @@ +/* Title: Pure/Thy/html.scala + Author: Makarius + +Basic HTML output. +*/ + +package isabelle + +object HTML +{ + // common elements and attributes + + val BODY = "body" + val DIV = "div" + val SPAN = "span" + val BR = "br" + val CLASS = "class" + + + // document markup + + def body(trees: List[XML.Tree]): XML.Tree = + XML.Elem(BODY, Nil, trees) + + def div(trees: List[XML.Tree]): XML.Tree = + XML.Elem(DIV, Nil, trees) + + val br: XML.Tree = XML.Elem(BR, Nil, Nil) + + def spans(tree: XML.Tree): List[XML.Tree] = + tree match { + case XML.Elem(name, _, ts) => + List(XML.Elem(SPAN, List((CLASS, name)), ts.flatMap(spans))) + case text @ XML.Text(txt) => + txt.split("\n").toList match { + case line :: lines if !lines.isEmpty => + XML.Text(line) :: lines.flatMap(l => List(br, XML.Text(l))) + case _ => List(text) + } + } +}