Skip to content

aziascreations/Extended-BBCode-Parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Extended BBCode Parser

A crude BBCode parser that outputs a string that contains HTML elements.

Do not use it on in a production/critical environment, it messes up often and easily.

Usage

Just add the js file in your page and call the function processText(rawText) with your raw BBCode as the rawText argument.

And you will either get the parsed HTML code or an error string that follows this format: ERROR: <message>.

Check "demo.html" for an example, or "this link (UNAVAILABLE)" for a live demo.

Specification

Go to the "Specification page" to read it.

Custom tags

You can easily add custom tags by modifying the bbElements constant.

It is an array of objects that follow this structure:

Field Type Description
tags String[] Array that contains the BBCode tags that refer to this element.
htmlElement String The HTML element that will be used for opening and closing this tag.
htmlElementDefaultParams String Optional String that is added to the opening HTML element if the `parameters` field is undefined, null or empty.
parameters Parameter[] Optional array of Parameter objects that define all the possible parameters for the tag.

And here is the Parameter structure:

Field Type Description
name String[] Array of strings that correspond to this parameter.
isRequired Boolean Indicates wether or not this parameter is required to parse this tag.
Returns an error message if the parameter is not declared in the BBCode.
isDefault Boolean Indicates wether or not this parameter is the one that will be parsed if it is joined to the tag like this: `[tag=val]`.
Returns an error message if a parameter like this is used an no parameter is set as the default one.
isTagParameter Boolean Indicates wether or not the value of this parameter should be put inside the final HTML element as a value like: <a arg1="val1">.
tagValueKey String Used as the parameter key in the HTML element is `isTagParameter` is set to true.
tagValueContentPrefix String ???
tagValueContentSuffix String ???

License

Unlicense

About

A crude BBCode parser that outputs a string that contains HTML elements

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages