-
Notifications
You must be signed in to change notification settings - Fork 18
Documentation
The main class, that parses string into HTML.
Methods:
constructor(bbTags)
Creates a new BBCode parser using the given tags.
parseString(content, stripTags)
Parses the given string and returns it as HTML. If stripTags is true, the tags are simply stripped from the string. Defaults to false.
treeToHtml(subTrees, insertLineBreaks, stripTags)
Converts the given sub trees into HTML.
Static functions:
defaultTags()
Returns default tags.
A BB tag which defines how tags are generated into HTML.
Methods
constructor(tagName, insertLineBreaks, suppressLineBreaks, noNesting, markupGenerator)
Parameters description:
- tagName: The name of the tag
- insertLineBreaks: Indicates if the tag inserts line breaks (\n ->
<br>
) in the content. - suppressLineBreaks: Suppresses line breaks for any nested tag.
- noNesting: If the tags doesn't support nested tags.
- tagGenerator: The HTML generator for the tag. If not supplied the default one is used:
<tagName>content</tagName>
.
Static functions
createSimpleTag(tagName, insertLineBreaks)
Creates a tag using the markup generator: <tagName>content</tagName>
createTag(tagName, markupGenerator, insertLineBreaks)
Creates a tag using the given markup generator.
Represents a BB code parse tree.
Methods
constructor(treeType, content, attributes, subTrees)
Parameters description:
- treeType: The type of the tree (Root, Text, Tag).
- content: The text content of the tree (can be null).
- attributes: The attributes for the tree-
- subTrees: The sub trees.
isValid()
Indicates if the current tree is valid.
Static functions
buildTree(str, bbTags)
Builds a tree from the given string using the given BB tags.
buildTreeFromTokens(rootTree, tokens, currentTag)
Creates a new parse tree from the given tokens.
Parameter descriptions:
- rootTree: The root tree.
- tokens: The tokens to build from.
- currentTag: The current tag being parsed.
Represents a token.
Methods
constructor(tokenType, content, tagAttributes, tagStr)
Parameter description:
- content: The text content for the token (if text token).
- tokenType: The type of the token (Text, StartTag, EndTag).
- tagAttributes: The attributes for the tag (if start tag).
- tagStr: The string representation of the tag (if start tag).
equals(token)
Determines if the given token equals the current.
Represents a tokenizer.
Methods
constructor(bbTags)
Creates a new tokenizer using the given tags.
tokenizeString(str)
Tokenizes the given string.