Plagger::Plugin::Filter::Markdown - Text formatting filter with Markdown


Plagger documentation Contained in the Plagger distribution.

Index


Code Index:

NAME

Top

Plagger::Plugin::Filter::Markdown - Text formatting filter with Markdown

SYNOPSIS

Top

  - module: Filter::Markdown
    config:
      empty_element_suffix: ' />'
      tab_width: '4'

DESCRIPTION

Top

This filter allows you to format the content with Markdown. You can get html string from simple text with syntax like Wiki.

CONFIG

Top

Any configurations will be passed to the constructor of Text::Markdown. See Text::Markdown in detail.

AUTHOR

Top

Nobuhito Sato

SEE ALSO

Top

Plagger, Text::Markdown


Plagger documentation Contained in the Plagger distribution.

package Plagger::Plugin::Filter::Markdown;
use strict;
use warnings;
use base qw( Plagger::Plugin );

our $VERSION = 0.01;

use Text::Markdown 'markdown';

sub register {
    my($self, $context) = @_;
    $context->register_hook(
        $self,
        'update.entry.fixup' => \&filter,
    );
}

sub filter {
    my($self, $context, $args) = @_;
    my $cfg = $self->conf;
    my $entry = $args->{entry};
    my $html = markdown($entry->body, {
        empty_element_suffix => $cfg->{empty_element_suffix} || ' />',
        tab_width => $cfg->{tab_width} || '4',
    } );
    $entry->body($html);
}

1;

__END__