This appears to be a great idea and is already done correctly in Text::MultiMarkdown::XS.
Rate perl xs perl 386/s -- -67% xs 1179/s 206% --
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 %]
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::XSIn reply to Re: Replacing perl module with external program
by Your Mother
in thread Replacing perl module with external program
by sgbotsford
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |