logo

class

docCompiler::FanToHtml

sys::Obj
  docCompiler::FanToHtml

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(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

classBlockComment

Str classBlockComment := "x"

The CSS class name used to style block comments.

Source

classBracket

Str classBracket := "b"

The CSS class name used to style brackets (parens, curly brace).

Source

classChar

Str classChar := "c"

The CSS class name used to style characters.

Source

classFandocComment

Str classFandocComment := "z"

The CSS class name used to style fandoc comments.

Source

classKeyword

Str classKeyword := "k"

The CSS class name used to style keywords.

Source

classLineComment

Str classLineComment := "y"

The CSS class name used to style single line comments.

Source

classSource

Str classSource := "src"

The top level <div> CSS class name.

Source

classString

Str classString := "s"

The CSS class name used to style strings.

Source

classUri

Str classUri := "u"

The CSS class name used to style URI's.

Source

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.

Source

parse

Void parse()

Parse the source file into a HTML fragment.

Source