This appears to be a great idea and is already done correctly in Text::MultiMarkdown::XS.

Punchline: much faster

Rate perl xs perl 386/s -- -67% xs 1179/s 206% --

Test code

use strictures; use Template; use Benchmark "cmpthese"; my $tt2 = Template->new(); my $template = do { local $/; <DATA> }; cmpthese 10_000, { xs => sub { $tt2->process(\qq{[% USE MultiMarkdown(implementation => "XS") + -%] $template}, {}, \my $toss) or die $tt2->error; }, perl => sub { $tt2->process(\qq{[% USE MultiMarkdown(implementation => "PP") + -%] $template}, {}, \my $toss) or die $tt2->error; } }; __DATA__ [% FILTER multimarkdown %] An h1 header ============ Use 3 dashes---for an em-dash. Use 2 dashes for ranges (ex. "it's all in chapters 12--14"). Three dots ... will be converted to an ellipsis. Bulleted list-- * this one * that one * the other one > Block quotes are written like so. Paragraphs are separated by a blank line. Obviously. [% END %]

Caveats, help till it normalizes

Text::MultiMarkdown::XS is still experimental and has no regular releases so it can't be installed with cpanm, even with the -dev flag. It also has a problem (for me) with the Makefile.PL (no printf for file handle) which I fixed by manualling adding use IO::Handle and installing with (update, took out note about pre-installing multimarkdown per anonymonk)–

wget http://search.cpan.org/CPAN/authors/id/A/AN/ANDREWF/Text-MultiMa +rkdown-XS-0.001_03.tar.gz gnutar xpfvz Text-MultiMarkdown-XS-0.001_03.tar.gz cd Text-MultiMarkdown-XS-0.001_03 # add "use IO::Handle;" to Makefile.PL make Makefile.PL make make test make install # Might need "sudo make install"

Eventually, for future readers, this, or your favorite alternative, is all it should take–

cpanm Text::MultiMarkdown::XS

In reply to Re: Replacing perl module with external program by Your Mother
in thread Replacing perl module with external program by sgbotsford

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.