Title

Text::CaffeinatedMarkup::HTMLFormatter - HTML formatter for the Caffeinated Markup Language

Synopsis

use Text::CaffeinatedMarkup::HTMLFormatter;

my $formatter = Text::CaffeinatedMarkup::HTMLFormatter->new;

my $to_format = 'Some **stuff** to be //parsed//';

my $html = $formatter->format($to_format);

Description

Provides formatting to HTML for the Caffeinated Markup Language. Implemented using the Text::CaffeinatedMarkup::PullParser.

For details on the syntax that CML implements, please see the Github wiki.

Methods

This module provides the following methods.

format

my $html = $formatter->format( 'something to format' );

Takes a raw string in Caffeinated Markup format and returns a string of encoded HTML.

Mappings

The various markup elements are mapped to HTML by this formatter as follows.

strong

**foo** -> <strong>foo</strong>

emphasis

//foo// -> <em>foo</em>

underline

__foo__ -> <u>foo</u>

delete

--foo-- -> <del>foo</del>

section divider

~~ -> <hr>

blockquote

""foo""     -> <blockquote>foo</blockquote>
""foo|bar"" -> <blockquote>foo<cite>bar</cite></blockquote>

headers

# foo    -> <h1>foo</h1>
## foo   -> <h2>foo</h2>
### foo  -> <h3>foo</h3>
[[http://www.google.com]]        -> <a href="http://www.google.com">http://www.google.com</a>
[[http://www.google.com|google]] -> <a href="http://www.google.com">google</a>

images

{{foo.jpg}}            -> <img src="foo.jpg">
{{foo.jpg|<<,H10,W10}} -> <img src="foo.jpg" class="pulled-left" width="10px" height="10px">

newlines and paragraphs

\n    -> <br>
\n\n  -> <p>  # (3+ \n still becomes single <p>)

rows and columns

==\n||foo\n||bar\n== -> <div class="clearfix col-2">
                        <div class="column">foo</div>
                        <div class="column">bar</div>
                        </div>

See Also

The Github wiki

Author

J Gregory <jgregory@cpan.org>