Skip to content

tawani/StmlParser

Repository files navigation

StmlParser

Simple Text Markup Language Parser is a custom HTML parser to convert user entered text into formatted XHTML documents that can be converted to XSL-FO and eventually PDF or RTF. It parses tags similar to BBCode tags and other extension tags relevant to generated [PDF] documents.

Convert the following markup to HTML

Input Text

Some random [blue]blue[/blue] text Base[sub]64[/sub] for 1[sup]st[/sup] game
This is a simple [b]bold[/b], [i]italic[/i], [u]underline[/u]
[olist]
    [#]This is line 1
    [#]This is line 2
        [olist=a]
            [#]This is [orange]orange[/orange] line 2.1
            [#]This is [green]green[/green] line 2.2
            [#]This is [red]red[/red] line 2.3
    and it continues here
        [/olist]
    [#]This is line 3
[/olist]
Another line

Output HTML

Some random <font color="blue">blue</font> text Base<sub>64</sub> for 1<sup>st</sup>
game This is a simple <b>bold</b>, <i>italic</i>, <u>underline</u>
<ol>
    <li>This is line 1</li>
    <li>This is line 2
        <ol type="a">
            <li>This is <font color="orange">orange</font> line 2.1</li>
            <li>This is <font color="green">green</font> line 2.2</li>
            <li>This is <font color="red">red</font> line 2.3 
            and it continues here</li>
        </ol>
    </li>
    <li>This is line 3</li>
</ol>
Another line

Sample Usage

const string input = "This is [b]bold[/b], [i]italic[i] and [blue]blue[/blue] for now";
const string expected = "This is <b>bold</b>, <i>italic</i> and <font color=\"blue\">blue</font> for now";
var actual = StmlParser.Parse(input).ToString();

Assert.AreEqual(expected, actual);

About

Simple Text Markup Language Parse

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages