mircparser v0.2.0 MircParser
Parse mIRC colour codes and render to HTML.
Full documentation about these codes can be found online.
The characters used for each kind of formatting are:
- "x02": Bold. Represented with
<b>
. - "x1D": Italic. Represented with
<i>
. - "x1F": Underline. Represented with
<u>
. - "x16": Reverse text. Represented with a span of class
reverse
. - "x1E": Strikethrough. Represented with
<s>
. - "x11": Monospaced. Represented with
<tt>
. - "x0F": Strips all formatting.
- "x03
": Sets the foreground colour. This is represented with a san of class fg<int>
. - "x03
, ": Sets the foreground and background colour. This is represented with a span of classes fg<int> bg<int>
. - "x03": Terminates colouring.
The colour codes are:
- 0: White (#FFFFFF)
- 1: Black (#000000)
- 2: Navy (#00007F)
- 3: Green (#009300)
- 4: Red (#FF0000)
- 5: Maroon (#7F0000)
- 6: Purple (#9C009C)
- 7: Orange (#FC7F00)
- 8: Yellow (#FFFF00)
- 9: Light Green (#00FC00)
- 10: Teal (#009393)
- 11: Cyan (#00FFFF)
- 12: Blue (#0000FC)
- 13: Pink (#FF00FF)
- 14: Grey (#7F7F7F)
- 15: Light Grey (#D2D2D2)
Link to this section Summary
Functions
Converts a string of mIRC formatted text into tokens.
Turns a string with mIRC formatting into an HTML string.
Turns a list of tokens into an HTML string.
Link to this section Functions
Link to this function
parse(string)
Converts a string of mIRC formatted text into tokens.
Examples
iex> MircParser.parse("plain\x1Ditalic")
["plain", :italic, "italic"]
Link to this function
render(string)
Turns a string with mIRC formatting into an HTML string.
Examples
iex> MircParser.render("foo\x02bar")
"foo<b>bar</b>"
Link to this function
render_tokens(tokens)
Turns a list of tokens into an HTML string.
Examples
iex> MircParser.render_tokens(["foo", :bold, "bar"])
"foo<b>bar</b>"