
FanToHtml generates a syntax color coded HTML fragment from a Fan source file. The actual CSS styles are not defined by this class, and should be set by the parent HTML markup or external CSS file.
// parse the file below into the markup below FanToHtml.make(in, out).parse class Foo { Int x := 5 } <div class='src'> <pre> <span class='k'>class<span>Foo <span class='b'>{</span> Int x := 5 <span class='b'>}</span> <pre> </div>
The default CSS class names can be changed by modifing the respective fields. They default to a single character to preserve space:
source => src bracket => b keyword => k string => s char => c uri => u blockComment => x lineComment => y fandocComment => z
Slots
-
private Void bracket()
Parse a bracket.
-
static private Int:Bool brackets
-
private Void char()
Parse a char literal.
- classBlockComment
-
Str classBlockComment
The CSS class name used to style block comments.
- classBracket
-
Str classBracket
The CSS class name used to style brackets (parens, curly brace).
- classChar
-
Str classChar
The CSS class name used to style characters.
- classFandocComment
-
Str classFandocComment
The CSS class name used to style fandoc comments.
- classKeyword
-
Str classKeyword
The CSS class name used to style keywords.
- classLineComment
-
Str classLineComment
The CSS class name used to style single line comments.
- classSource
-
Str classSource
The top level <div> CSS class name.
- classString
-
Str classString
The CSS class name used to style strings.
- classUri
-
Str classUri
The CSS class name used to style URI's.
-
private Void comment()
Parse a comment.
-
private Void fandoc()
Parse a fandoc comment.
-
private Void identifier()
Parse an identifier.
-
private FanToHtmlInStream in
-
static private Str:Bool keywords
- make
-
new make(InStream in, OutStream out, Str:Int slots := null)
Create a new FanToHtml to parse the given InStream to the given OutStream. The slots map is a slot name to line number map. If non-null, it will be used to attempt to place an anchor where the respective slot is defined.
-
private Bool nextToken()
Parse the next token.
-
Return true if ch is a newline character.
-
private OutStream out
- parse
-
Void parse()
Parse the source file into a HTML fragment.
-
Escape <, &, and > characters.
-
private Str:Int slots
-
private Void string()
Parse a string literal.
-
private Void uri()
Parse a Uri literal.
-
private Str:Bool used