line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MojoMojo::Formatter::Textile; |
2
|
|
|
|
|
|
|
|
3
|
27
|
|
|
27
|
|
143265
|
use parent 'MojoMojo::Formatter'; |
|
27
|
|
|
|
|
511
|
|
|
27
|
|
|
|
|
218
|
|
4
|
|
|
|
|
|
|
|
5
|
27
|
|
|
27
|
|
3657
|
use Text::Textile; |
|
27
|
|
|
|
|
121630
|
|
|
27
|
|
|
|
|
1306
|
|
6
|
27
|
|
|
27
|
|
10882
|
use Text::SmartyPants; |
|
27
|
|
|
|
|
80
|
|
|
27
|
|
|
|
|
437
|
|
7
|
|
|
|
|
|
|
my $textile = Text::Textile->new( |
8
|
|
|
|
|
|
|
flavor => 'xhtml1', |
9
|
|
|
|
|
|
|
charset => 'utf-8', |
10
|
|
|
|
|
|
|
char_encoding => 0, # don't encode any other entities than <, >, " and & |
11
|
|
|
|
|
|
|
); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# We do not want Text::Textile to encode HTML entities at all because that will |
14
|
|
|
|
|
|
|
# conflict with with <pre> tags generated by SyntaxHighlight. SyntaxHighlight |
15
|
|
|
|
|
|
|
# already converts C<< < >> and C<< > >> to C<<> and C<>,> and letting |
16
|
|
|
|
|
|
|
# Textile process that again will produce C<&lt;> and C<&gt;> |
17
|
|
|
|
|
|
|
{ |
18
|
27
|
|
|
27
|
|
1266
|
no strict 'refs'; |
|
27
|
|
|
|
|
63
|
|
|
27
|
|
|
|
|
839
|
|
19
|
27
|
|
|
27
|
|
146
|
no warnings; |
|
27
|
|
|
|
|
63
|
|
|
27
|
|
|
|
|
3595
|
|
20
|
43
|
|
|
43
|
|
13152
|
*{"Text::Textile::encode_html"} = sub { my ($self, $html) = @_; return $html; }; |
|
43
|
|
|
|
|
193
|
|
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 NAME |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
MojoMojo::Formatter::Textile - Texile+SmartyPants formatting for your content |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 DESCRIPTION |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
This formatter processes content using L<Text::Textile> (a syntax for writing |
30
|
|
|
|
|
|
|
human-friendly formatted text), then post-processes that using L<Text::SmartyPants> |
31
|
|
|
|
|
|
|
(which transforms plain ASCII punctuation characters into "smart" typographic |
32
|
|
|
|
|
|
|
punctuation HTML entities, such as smart quotes or the ellipsis character). |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Textile reference: <http://hobix.com/textile/> |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 METHODS |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 main_format_content |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Calls the formatter. Takes a ref to the content as well as the |
41
|
|
|
|
|
|
|
context object. Note that this is different from the format_content method |
42
|
|
|
|
|
|
|
of non-main formatters. This is because we don't want all main formatters |
43
|
|
|
|
|
|
|
to be called when iterating over pluggable modules in |
44
|
|
|
|
|
|
|
L<MojoMojo::Schema::ResultSet::Content::format_content>. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
C<main_format_content> will only be called by <MojoMojo::Formatter::Main>. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub main_format_content { |
51
|
36
|
|
|
36
|
1
|
192
|
my ( $class, $content ) = @_; |
52
|
|
|
|
|
|
|
|
53
|
36
|
|
|
|
|
217
|
$$content = $textile->process($$content); |
54
|
36
|
|
|
|
|
8285
|
$$content = Text::SmartyPants->process($$content); |
55
|
|
|
|
|
|
|
# for uniformity with Markdown, make sure the output ends with *one* newline. |
56
|
|
|
|
|
|
|
# See justification in L<MojoMojo::Formatter::Markdown/format_content>. |
57
|
36
|
|
|
|
|
446
|
$$content =~ s/\n*$/\n/; |
58
|
36
|
|
|
|
|
174
|
return $$content; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 SEE ALSO |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
L<MojoMojo>, L<Module::Pluggable::Ordered>, L<Text::Textile> |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 AUTHORS |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Marcus Ramberg <mramberg@cpan.org> |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 LICENSE |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
This library is free software. You can redistribute it and/or modify |
72
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |