The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

HTML::SBC - simple blog code for valid (X)HTML

VERSION

This document describes version 0.08 of HTML::SBC from June 22, 2006.

SYNOPSIS

    use HTML::SBC qw(:all);

    my ($html, $errors) = sbc_translate($text);

DESCRIPTION

Simple blog code is a simple markup language. You can use it for guest books, blogs, wikis, boards and various other web applications. It produces valid and semantic (X)HTML from input and is patterned on that tiny usenet markups like *bold* and _underline_. See "Language description" for details.

HTML::SBC tries to give useful error messages and guess the right translation even with invalid input. It will always produce valid (X)HTML.

Translation

You can choose a different output language before translating (English by default) These additional languages are available:

  • German

        $HTML::SBC::german();

Now, HTML::SBC::sbc_translate() (importable) tries a simple blog code translation of given input and returns a list with the translation and an array reference with some error messages:

    my ($html, $errors) = sbc_translate($text);
    print "$_\n" for @$errors;

If you want to translate in quirks mode, just ignore the error messages, evaluate sbc_translate() in scalar context:

    my $html = sbc_translate($text);

If you have some text in simple blog code $original and you want it to be sbc-quoted (e. g. for reply functionality in boards), just use

    my $reply = sbc_quote($original);

or add the author's name:

    my $reply = sbc_quote($original, $author);

Additionally, you can use HTML::SBC for one-liners (HTML text fields):

    my $line = sbc_translate_inline($line);

If you want some newbies to use SBC, just show them our SBC language description:

    my $description = sbc_description();

and embed this in your HTML document. The sbc_description()'s result is HTML.

To import these functions, use() HTML::SBC as described below:

    use HTML::SBC;                      # nothing
    use HTML::SBC qw(sbc_translate);    # nothing but sbc_translate()
    ...
    use HTML::SBC qw(:all);             # import all subs
                                        # except language setter

Language description

Simple blog code is a simple markup language. Paragraphs in input (text between newlines) are translated in (X)HTML P elements. In paragraphs, some

inline elements

are allowed as follows:

*emphasis*
    <em>emphasis</em>
_strong emphasis_
    <strong>strong emphasis</strong>
<http://www.example.org/>
    <a href="http://www.example.org/">http://www.example.org/</a>
<http://www.example.org/ hyperlink>
    <a href="http://www.example.org/">hyperlink</a>

There are some elements on block level which don't have to be in paragraphs.

block level elements

[nice quote]
    <div class="quote">
        <blockquote>
            nice quote
        </blockquote>
    </div>
[another nice quote] author
    <div class="qoute">
        <cite>author</cite>
        <blockquote>
            another nice quote
        </blockquote>
    </div>
- first\n- second\n- third\n
    <ul>
        <li>first</li>
        <li>second</li>
        <li>third</li>
    </ul>
# first\n# second\n# third\n
    <ol>
        <li>first</li>
        <li>second</li>
        <li>third</li>
    </ol>

Block level elements have to be started in new lines. In quotes, you can use block level elements, e. g.

    [
    \[...\] the three great virtues of a programmer:
    - laziness,
    - impatience and
    - hubris.
    ] Larry Wall

You'll get the nice quote from Larry with an inner list. You can see here, that characters with a special meaning have to be escaped in SBC. You would use "\*" to get an asterisk, for example.

BUGS

This module is in BETA STATUS. I love bug reports and other feedback.

AUTHOR

Mirko Westermeier (mail@memowe.de)

COPYRIGHT and LICENSE

Copyright (C) 2005, 2006 by Mirko Westermeier

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.