DocumentUtil
Description
Helper class for dealing with text documents.
Content for text documents can be specified using a simple mini-HTML dialect, which is defined by the following Grammar:
document := preamble doctype '<document' '>' blocks? '</document' '>' | blocks? ;
inlines := inline+ ;
blocks := block block* ;
doctype := '<!DOCTYPE' 'document' 'PUBLIC' '"-//TINMAN//TEXTDOC//EN"' '"http://dtd.tinman3d.com/TextDocument.dtd"' '>' ;
preamble := '<?xml' 'version' '=' '"1.0"' 'encoding' '=' '"utf-8"' '?>' ;
block := comment* (p | ol | ul | cdata | h1 | h2 | hr) ;
li := '<li' '>' block* '</li' '>' ;
ol := '<ol' '>' li* '</ol' '>' ;
ul := '<ul' '>' li* '</ul' '>' ;
h1 := '<h1' '>' inline* '</h1' '>' ;
h2 := '<h2' '>' inline* '</h2' '>' ;
p := '<p' '>' inline* '</p' '>' | inline+ ;
inline := comment* (img | br | b | c | i | u | a | text) ;
a := '<a' (href | name) ('/>' | '>' text '</a>') ;
b := '<b' '>' text '</b' '>' ;
c := '<c' '>' text '</c' '>' ;
i := '<i' '>' text '</i' '>' ;
img := '<img' src ('border' '=' '"1"')? '/>' ;
u := '<u' '>' text '</u' '>' ;
href := 'href' '=' '"' (char-2 | entity)+ '"' ;
name := 'name' '=' '"' (char-2 | entity)+ '"' ;
src := 'src' '=' '"' (char-2 | entity)+ '"' ;
text := (char-1 | entity)+ ;
br := '<br' '/>' ;
cdata := '<![CDATA[' ~']]>'* ']]>' ;
char-1 := ]<&[+ ;
char-2 := ]<"\r&\n[+ ;
comment := '<!--' ~'-->'* '-->' ;
entity := '<' | '&' | '>' | '"' | ''' ;
hr := '<hr' '/>' ;
Use the BlockContent and InlineContent methods to populate text document nodes with mini-HTML content:
-
Rule
'a': LinkNode -
Rule
'b': TextNode with TextStyle.Bold -
Rule
'br': BreakNode -
Rule
'c': TextNode with TextStyle.Monospace -
Rule
'cdata': TextBlockNode -
Rule
'h1': ParagraphNode with ParagraphStyle.Heading -
Rule
'h2': ParagraphNode with ParagraphStyle.Subheading -
Rule
'hr': SeparatorNode -
Rule
'i': TextNode with TextStyle.Italic -
Rule
'img': ImageNode with ImageStyle.Plain or ImageStyle.Frame. -
Rule
'li': ListItemNode -
Rule
'ol': ListNode with ListStyle.ListNumber -
Rule
'p': ParagraphNode with ParagraphStyle.Paragraph -
Rule
'u': TextNode with TextStyle.Underline -
Rule
'ul': ListNode with ListStyle.ListBullet
Public / Methods
BlockContent
Populates the given document node with block content.
- ValidatingException
-
If one or more parsing errors have occurred.
InlineContent
Populates the given document node with block content.
- ValidatingException
-
If one or more parsing errors have occurred.
PlainText
Extracts the plain text content (see ITextContentNode.Text) in the given node, adding whitespace characters where necessary (see ITextContentNode.Flags).