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

NAME

Dotiac::DTL::Addon::markup: Filters to work with common markup languages

SYNOPSIS

Load from a Dotiac::DTL-template:

        {% load markup %}

Load in Perl file for all templates:

        use Dotiac::DTL::Addon::markup;

Then it can be used:

        {{ var|markdown }}
        {{ text|textile }}
        {{ content|restructuredtext }}

INSTALLATION

via CPAN:

        perl -MCPAN -e "install Dotiac::DTL::Addon::markup"

or get it from https://sourceforge.net/project/showfiles.php?group_id=249411&package_id=306751, extract it and then run in the extracted folder:

        perl Makefile.PL
        make test
        make install

DESCRIPTION

This is like Django.contrib.markup, (http://docs.djangoproject.com/en/dev/ref/contrib/#ref-contrib-marku), but for Dotiac::DTL and Perl.

It converts some of the common markup languages to HTML.

Filters

textile

Converts textile syntax to HTML.

Gives the content to Text::Textile and returns the results.

It will always return a safe string.

        my $text = <<EOT;
        h1. Heading

        A _simple_ demonstration of Textile markup.

        * One
        * Two
        * Three

        "More information":http://www.textism.com/tools/textile is available.
        EOT

        text=>$text;

In the template:

        {{ text|textile }}

This will render to:

        <h1>Heading</h1>

        <p>A <em>simple</em> demonstration of Textile markup.</p>

        <ul>
                <li>One</li>
                <li>Two</li>
                <li>Three</li>
        </ul>

        <p><a href="http://www.textism.com/tools/textile">More information</a> is available.</p>

        

Example from Text::Textile.

markdown

Converts markdown syntax to HTML.

Gives the content to Text::Markdown and returns the results.

It will always return a safe string.

        my $text = <<EOM;
        A First Level Header
        ====================

        A Second Level Header
        ---------------------

        Now is the time for all good men to come to
        the aid of their country. This is just a
        regular paragraph.

        The quick brown fox jumped over the lazy
        dog's back.

        ### Header 3

        > This is a blockquote.
        > 
        > This is the second paragraph in the blockquote.
        >
        > ## This is an H2 in a blockquote
        EOM

        text=>$text;

In the template:

        {{ text|markdown }}

This will render to:

        <h1>A First Level Header</h1>

        <h2>A Second Level Header</h2>

        <p>Now is the time for all good men to come to
        the aid of their country. This is just a
        regular paragraph.</p>

        <p>The quick brown fox jumped over the lazy
        dog's back.</p>

        <h3>Header 3</h3>

        <blockquote>
            <p>This is a blockquote.</p>

            <p>This is the second paragraph in the blockquote.</p>

            <h2>This is an H2 in a blockquote</h2>
        </blockquote>
        

Example from http://daringfireball.net/projects/markdown/basics

restructuredtext

Converts ReST syntax to HTML.

Gives the content to Text::Restructured and returns the results.

It will always return a safe string.

        my $text = <<EOR;
        =====
        Title
        =====
        Subtitle
        -------- 

        Titles are underlined (or over-
        and underlined) with a printing
        nonalphanumeric 7-bit ASCII
        character.
        
        - This is item 1
        - This is item 2 
        
        EOR

        text=>$text;

In the template:

        {{ text|markdown }}

This will render to:

        <font size="+2"><strong>Title</strong></font>
        <p><font size="+1"><strong>Subtitle</strong></font>
        </p><p>Titles are underlined (or over-
          and underlined) with a printing
          nonalphanumeric 7-bit ASCII
          character.</p>
        

        <ul>
          <li>This is item 1
          </li><li>This is item 2
          </li></ul>
        

Example from http://docutils.sourceforge.net/docs/user/rst/quickref.html

BUGS

Since Text::Restructured won't compile under Win32, this can't be tested. Either it works or it won't.

Please report any bugs or feature requests to https://sourceforge.net/tracker2/?group_id=249411&atid=1126445

SEE ALSO

Dotiac::DTL, Dotiac::DTL::Addon, http://www.dotiac.com, http://www.djangoproject.com

AUTHOR

Marc-Sebastian Lucksch

perl@marc-s.de