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

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.

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.

parse

Void parse()

Parse the source file into a HTML fragment.