lib/MojoMojo/Formatter/Main.pm

filter: Statementstmt 100% 11 / 11 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod 100% 2 / 2 totaltotal 100% 18 / 18 CC 2 SCAR 4.1
CC
2
Cov
100%
format_content
2.0
BEGIN
1.0
format_content_order
1.0
CRAP 1.5
« lib/MojoMojo/Formatter/CPANHyperlink.pm ↑ Summary lib/MojoMojo/Formatter/File/Text.pm »
1 package MojoMojo::Formatter::Main;
2  
3 26 ▶use parent 'MojoMojo::Formatter';
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 =head1 NAME
6  
7 MojoMojo::Formatter::Main - MojoMojo's main formatter, dispatching between
8 Textile and MultiMarkdown
9  
10 =head1 DESCRIPTION
11  
12 This is the main MojoMojo formatter, which transforms lightweight plain text
13 markup into XHTML. It reads the site preference main_formatter and calls the
14 corresponding formatter, either L<Text::Textile>, or L<Text::MultiMarkdown>.
15  
16 =head1 METHODS
17  
18 =head2 format_content_order
19  
20 Format order can be 1-99. The main formatter runs on 15.
21  
22 =cut
23  
24 620 ▶sub format_content_order { 15 }
Subroutine format_content_order: called CC=1 SCAR=0.0
Pod documented
25  
26 =head2 format_content
27  
28 Calls the formatter. Takes a ref to the content as well as the context object.
29 The latter is needed in order to determine the main formatter via a call to
30 C<< $c->pref('main_formatter') >>.
31  
32 =cut
33  
34 124 ▶sub format_content {
Subroutine format_content: called CC=2 SCAR=6.9
Pod documented
35 124 my ( $class, $content, $c ) = @_;
36  
37 # dispatch to the preferred formatter
38 124 ▶ if ($c->pref('main_formatter') eq 'MojoMojo::Formatter::Textile') {
Branch: 1 branch
BranchTrueFalseTotal
if ($c->pref('main_formatter') eq 'MojoMojo::Formatter::Textile') { } 30 94 124
39 30 require MojoMojo::Formatter::Textile;
40 30 $$content = MojoMojo::Formatter::Textile->main_format_content($content);
41 } else {
42 94 require MojoMojo::Formatter::Markdown;
43 94 $$content = MojoMojo::Formatter::Markdown->main_format_content($content);
44 }
45 }
46  
47 =head1 SEE ALSO
48  
49 L<MojoMojo>, L<Module::Pluggable::Ordered>, L<Text::Textile>
50  
51 =head1 AUTHORS
52  
53 Marcus Ramberg <mramberg@cpan.org>
54  
55 =head1 LICENSE
56  
57 This library is free software. You can redistribute it and/or modify
58 it under the same terms as Perl itself.
59  
60 =cut
61  
62 26 1;
« lib/MojoMojo/Formatter/CPANHyperlink.pm ↑ Summary lib/MojoMojo/Formatter/File/Text.pm »