line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Kwiki::Formatter::Emphasis; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
58094
|
use warnings; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
53
|
|
4
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
411
|
|
5
|
1
|
|
|
1
|
|
2573
|
use Kwiki::Plugin '-Base'; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use mixin 'Kwiki::Installer'; |
7
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
const class_title => 'Emphasis'; |
10
|
|
|
|
|
|
|
const class_id => 'wikiemphasis'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub register { |
13
|
|
|
|
|
|
|
my $registry = shift; |
14
|
|
|
|
|
|
|
$registry->add(preload => $self->class_id); |
15
|
|
|
|
|
|
|
$registry->add(hook => 'formatter:all_phrases', |
16
|
|
|
|
|
|
|
post => 'add_emphasis_to_list', |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub init { |
21
|
|
|
|
|
|
|
super; |
22
|
|
|
|
|
|
|
my $formatter = $self->hub->load_class('formatter'); |
23
|
|
|
|
|
|
|
$formatter->table->{emphasis} = 'Kwiki::Formatter::Emphasis::Phrase'; |
24
|
|
|
|
|
|
|
$formatter->table->{em} = 'Kwiki::Formatter::Italicize'; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub add_emphasis_to_list { |
28
|
|
|
|
|
|
|
return [('emphasis', @{$_[-1]->returned})]; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
package Kwiki::Formatter::Emphasis::Phrase; |
32
|
|
|
|
|
|
|
use Spoon::Base -Base; |
33
|
|
|
|
|
|
|
use Kwiki ':char_classes'; |
34
|
|
|
|
|
|
|
use base 'Spoon::Formatter::Phrase'; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
const formatter_id => 'emphasis'; |
37
|
|
|
|
|
|
|
const pattern_start => qr/(^|(?<=[^$ALPHANUM]))\~(?=\S[^\~]*\~(?=\W|\z))/; |
38
|
|
|
|
|
|
|
const pattern_end => qr/\~(?=[^$ALPHANUM]|\z)/; |
39
|
|
|
|
|
|
|
const html_start => ""; |
40
|
|
|
|
|
|
|
const html_end => ""; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
package Kwiki::Formatter::Italicize; |
43
|
|
|
|
|
|
|
use Spoon::Base -Base; |
44
|
|
|
|
|
|
|
use base 'Spoon::Formatter::Phrase'; |
45
|
|
|
|
|
|
|
use Kwiki ':char_classes'; |
46
|
|
|
|
|
|
|
const formatter_id => 'em'; |
47
|
|
|
|
|
|
|
const pattern_start => qr/(^|(?<=[^$ALPHANUM]))\/(?=\S[^\/]*\/(?=\W|\z))/; |
48
|
|
|
|
|
|
|
const pattern_end => qr/\/(?=[^$ALPHANUM]|\z)/; |
49
|
|
|
|
|
|
|
const html_start => ""; |
50
|
|
|
|
|
|
|
const html_end => ""; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
package Kwiki::Formatter::Emphasis; |
53
|
|
|
|
|
|
|
1; # End of Kwiki::Formatter::Emphasis |
54
|
|
|
|
|
|
|
__DATA__ |