line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Markdent::Dialect::GitHub::SpanParser; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
3161
|
use strict; |
|
5
|
|
|
|
|
15
|
|
|
5
|
|
|
|
|
169
|
|
4
|
5
|
|
|
5
|
|
29
|
use warnings; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
151
|
|
5
|
5
|
|
|
5
|
|
30
|
use namespace::autoclean; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
47
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.40'; |
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
|
510
|
use Markdent::Event::AutoLink; |
|
5
|
|
|
|
|
16
|
|
|
5
|
|
|
|
|
196
|
|
10
|
5
|
|
|
5
|
|
2379
|
use Markdent::Event::EndStrikethrough; |
|
5
|
|
|
|
|
20
|
|
|
5
|
|
|
|
|
209
|
|
11
|
5
|
|
|
5
|
|
42
|
use Markdent::Event::LineBreak; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
141
|
|
12
|
5
|
|
|
5
|
|
3322
|
use Markdent::Event::StartStrikethrough; |
|
5
|
|
|
|
|
23
|
|
|
5
|
|
|
|
|
210
|
|
13
|
|
|
|
|
|
|
|
14
|
5
|
|
|
5
|
|
44
|
use Moose::Role; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
55
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
with 'Markdent::Role::Dialect::SpanParser'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _build_emphasis_start_delimiter_re { |
19
|
19
|
|
|
19
|
|
59
|
my $self = shift; |
20
|
|
|
|
|
|
|
|
21
|
19
|
|
|
|
|
658
|
return qr/(?:\*|(?<=\W)_|(?<=^)_)/; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) |
25
|
|
|
|
|
|
|
sub _emphasis_end_delimiter_re { |
26
|
10
|
|
|
10
|
|
14
|
my $self = shift; |
27
|
10
|
|
|
|
|
18
|
my $delim = shift; |
28
|
|
|
|
|
|
|
|
29
|
10
|
100
|
|
|
|
117
|
return $delim eq '*' ? qr/\Q$delim\E/ : qr/\Q$delim\E(?=$|\W)/; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
## use critic |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
around _possible_span_matches => sub { |
34
|
|
|
|
|
|
|
my $orig = shift; |
35
|
|
|
|
|
|
|
my $self = shift; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my @look_for = $self->$orig(); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my %open = $self->_open_start_events_for_span( 'code', 'link' ); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
push @look_for, $self->_look_for_strikethrough |
42
|
|
|
|
|
|
|
unless $open{code}; |
43
|
|
|
|
|
|
|
push @look_for, 'bare_link' |
44
|
|
|
|
|
|
|
unless $open{link}; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
return @look_for; |
47
|
|
|
|
|
|
|
}; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub _look_for_strikethrough { |
50
|
69
|
|
|
69
|
|
125
|
my $self = shift; |
51
|
|
|
|
|
|
|
|
52
|
69
|
|
|
|
|
170
|
my %open = $self->_open_start_events_for_span('strikethrough'); |
53
|
|
|
|
|
|
|
|
54
|
69
|
100
|
|
|
|
177
|
if ( $open{strikethrough} ) { |
55
|
2
|
|
|
|
|
66
|
return ( [ 'strikethrough_end', $open{strikethrough}->delimiter ] ); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
67
|
|
|
|
|
152
|
return ('strikethrough_start'); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) |
62
|
|
|
|
|
|
|
sub _match_bare_link { |
63
|
57
|
|
|
57
|
|
95
|
my $self = shift; |
64
|
57
|
|
|
|
|
94
|
my $text = shift; |
65
|
|
|
|
|
|
|
|
66
|
57
|
100
|
|
|
|
90
|
return unless ${$text} =~ m{ \G |
|
57
|
|
|
|
|
276
|
|
67
|
|
|
|
|
|
|
(?: |
68
|
|
|
|
|
|
|
(?<=^) |
69
|
|
|
|
|
|
|
| |
70
|
|
|
|
|
|
|
(?<=\W) |
71
|
|
|
|
|
|
|
) |
72
|
|
|
|
|
|
|
( |
73
|
|
|
|
|
|
|
https? |
74
|
|
|
|
|
|
|
:// |
75
|
|
|
|
|
|
|
\S+ |
76
|
|
|
|
|
|
|
) |
77
|
|
|
|
|
|
|
}xgc; |
78
|
|
|
|
|
|
|
|
79
|
5
|
|
|
|
|
27
|
my $link = $self->_make_event( AutoLink => uri => $1 ); |
80
|
|
|
|
|
|
|
|
81
|
5
|
|
|
|
|
33
|
$self->_markup_event($link); |
82
|
|
|
|
|
|
|
|
83
|
5
|
|
|
|
|
30
|
return 1; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub _match_strikethrough_start { |
87
|
57
|
|
|
57
|
|
106
|
my $self = shift; |
88
|
57
|
|
|
|
|
100
|
my $text = shift; |
89
|
|
|
|
|
|
|
|
90
|
57
|
100
|
|
|
|
291
|
my ($delim) = $self->_match_delimiter_start( $text, qr/\~\~/ ) |
91
|
|
|
|
|
|
|
or return; |
92
|
|
|
|
|
|
|
|
93
|
1
|
|
|
|
|
12
|
my $event |
94
|
|
|
|
|
|
|
= $self->_make_event( StartStrikethrough => delimiter => $delim ); |
95
|
|
|
|
|
|
|
|
96
|
1
|
|
|
|
|
9
|
$self->_markup_event($event); |
97
|
|
|
|
|
|
|
|
98
|
1
|
|
|
|
|
6
|
return 1; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub _match_strikethrough_end { |
102
|
2
|
|
|
2
|
|
5
|
my $self = shift; |
103
|
2
|
|
|
|
|
3
|
my $text = shift; |
104
|
2
|
|
|
|
|
4
|
my $delim = shift; |
105
|
|
|
|
|
|
|
|
106
|
2
|
100
|
|
|
|
22
|
$self->_match_delimiter_end( $text, qr/\Q$delim\E/ ) |
107
|
|
|
|
|
|
|
or return; |
108
|
|
|
|
|
|
|
|
109
|
1
|
|
|
|
|
5
|
my $event = $self->_make_event( EndStrikethrough => delimiter => $delim ); |
110
|
|
|
|
|
|
|
|
111
|
1
|
|
|
|
|
14
|
$self->_markup_event($event); |
112
|
|
|
|
|
|
|
|
113
|
1
|
|
|
|
|
16
|
return 1; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
## use critic |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
around _text_end_res => sub { |
119
|
|
|
|
|
|
|
my $orig = shift; |
120
|
|
|
|
|
|
|
my $self = shift; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
return ( |
123
|
|
|
|
|
|
|
$self->$orig(), |
124
|
|
|
|
|
|
|
qr{https?://}, |
125
|
|
|
|
|
|
|
qr/\~\~/, |
126
|
|
|
|
|
|
|
); |
127
|
|
|
|
|
|
|
}; |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
1; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
# ABSTRACT: Span parser for GitHub Markdown |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
__END__ |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=pod |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=encoding UTF-8 |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 NAME |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Markdent::Dialect::GitHub::SpanParser - Span parser for GitHub Markdown |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 VERSION |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
version 0.40 |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 DESCRIPTION |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
This role adds parsing for some of the Markdown extensions used on GitHub. See |
150
|
|
|
|
|
|
|
http://github.github.com/github-flavored-markdown/ for details. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 ROLES |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
This role does the L<Markdent::Role::Dialect::SpanParser> role. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 BUGS |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
See L<Markdent> for bug reporting details. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Bugs may be submitted at L<https://github.com/houseabsolute/Markdent/issues>. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
I am also usually active on IRC as 'autarch' on C<irc://irc.perl.org>. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 SOURCE |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
The source code repository for Markdent can be found at L<https://github.com/houseabsolute/Markdent>. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 AUTHOR |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
This software is copyright (c) 2021 by Dave Rolsky. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
177
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
The full text of the license can be found in the |
180
|
|
|
|
|
|
|
F<LICENSE> file included with this distribution. |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=cut |