File: Main.pm

package info (click to toggle)
libmojomojo-perl 1.11%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 4,496 kB
  • ctags: 927
  • sloc: perl: 14,671; sh: 148; xml: 120; makefile: 8; ruby: 6
file content (62 lines) | stat: -rw-r--r-- 1,518 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package MojoMojo::Formatter::Main;

use parent 'MojoMojo::Formatter';

=head1 NAME

MojoMojo::Formatter::Main - MojoMojo's main formatter, dispatching between
Textile and MultiMarkdown

=head1 DESCRIPTION

This is the main MojoMojo formatter, which transforms lightweight plain text
markup into XHTML. It reads the site preference main_formatter and calls the
corresponding formatter, either L<Text::Textile>, or L<Text::MultiMarkdown>.

=head1 METHODS

=head2 format_content_order

Format order can be 1-99. The main formatter runs on 15.

=cut

sub format_content_order { 15 }

=head2 format_content

Calls the formatter. Takes a ref to the content as well as the context object.
The latter is needed in order to determine the main formatter via a call to
C<< $c->pref('main_formatter') >>.

=cut

sub format_content {
    my ( $class, $content, $c ) = @_;

    # dispatch to the preferred formatter
    if ($c->pref('main_formatter') eq 'MojoMojo::Formatter::Textile') {
        require MojoMojo::Formatter::Textile;
        $$content = MojoMojo::Formatter::Textile->main_format_content($content);
    } else {
        require MojoMojo::Formatter::Markdown;
        $$content = MojoMojo::Formatter::Markdown->main_format_content($content);
    }
}

=head1 SEE ALSO

L<MojoMojo>, L<Module::Pluggable::Ordered>, L<Text::Textile>

=head1 AUTHORS

Marcus Ramberg <mramberg@cpan.org>

=head1 LICENSE

This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.

=cut

1;