On Wed, 21 Dec 2016 13:44:31 -0700
Sherwood Botsford <sgbotsf...@gmail.com> wrote:

> I asked a similar question a few years ago, and didn't understand the
> answers.  I really don't understand the care and feeding of modules.
> 
> Here's what I'm starting with:
> 
> #$Id: MultiMarkdown.pm 4103 2009-03-02 20:41:50Z andrew $
> package Template::Plugin::MultiMarkdown;
> use strict;
> use base qw (Template::Plugin::Filter);
> use Text::MultiMarkdown;
> 
> our $VERSION = 0.03;
> 
> sub init {
>     my $self = shift;
>     $self->{_DYNAMIC} = 1;
>     $self->install_filter($self->{_ARGS}->[0] || 'multimarkdown');
>     return $self;
> }
> 
> sub filter {
>     my ($self, $text, $args, $config) = @_;
>     my $m = Text::MultiMarkdown->new(%{$config || {}});
>     return $m->markdown($text);
> }
> 
> 1;
> 
> ******
> 
> I want to change the reference to Text:MultiMarkdown
> to use /usr/local/bin/multimarkdown
> 
> I think I need to change:
> use Text::MultiMarkdown;
> To
> use IPC::run3
> 
> and then the my $m line involves a call to run3, but then I'm lost.
> 
> 
> Regards
> 
> Sherwood

Try this in place of the two lines, "my $m..." and "return ...":

<code>
    my @mmdcmd = ( '/usr/local/bin/multimarkdown' );
    my $out;
    run3 \@mmdcmd, \$text, \$out;
    return $out;
</code>

If you need to add switches to the multimarkdown command line, you'd
add each one as an item in the list for the @mmdcmd array.  Like this
(wrapped to multiple lines to avoid auto-wrapping):

<code>
    my @mmdcmd = ( 
        '/usr/local/bin/multimarkdown',
        '--switch1', 'switch1arg',
        '--switch2', 'switch2arg',
        '--noargswitch',
        # etc... 
    );
</code>

I think the next trick will be adapting the plugin config to the
command line of multimarkdown...  but I know nothing about either, so
you're on your own there. 


-- 

C. Chad Wallace, B.Sc.
The Lodging Company
http://www.lodgingcompany.com/
OpenPGP Public Key ID: 0x262208A0


_______________________________________________
templates mailing list
templates@template-toolkit.org
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to