line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Markdent::Dialect::GitHub::SpanParser; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
3396
|
use strict; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
166
|
|
4
|
5
|
|
|
5
|
|
25
|
use warnings; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
166
|
|
5
|
5
|
|
|
5
|
|
26
|
use namespace::autoclean; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
46
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.39'; |
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
|
548
|
use Markdent::Event::AutoLink; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
187
|
|
10
|
5
|
|
|
5
|
|
2181
|
use Markdent::Event::EndStrikethrough; |
|
5
|
|
|
|
|
19
|
|
|
5
|
|
|
|
|
215
|
|
11
|
5
|
|
|
5
|
|
45
|
use Markdent::Event::LineBreak; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
131
|
|
12
|
5
|
|
|
5
|
|
3145
|
use Markdent::Event::StartStrikethrough; |
|
5
|
|
|
|
|
21
|
|
|
5
|
|
|
|
|
214
|
|
13
|
|
|
|
|
|
|
|
14
|
5
|
|
|
5
|
|
46
|
use Moose::Role; |
|
5
|
|
|
|
|
15
|
|
|
5
|
|
|
|
|
50
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
with 'Markdent::Role::Dialect::SpanParser'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _build_emphasis_start_delimiter_re { |
19
|
19
|
|
|
19
|
|
48
|
my $self = shift; |
20
|
|
|
|
|
|
|
|
21
|
19
|
|
|
|
|
579
|
return qr/(?:\*|(?<=\W)_|(?<=^)_)/; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) |
25
|
|
|
|
|
|
|
sub _emphasis_end_delimiter_re { |
26
|
10
|
|
|
10
|
|
24
|
my $self = shift; |
27
|
10
|
|
|
|
|
14
|
my $delim = shift; |
28
|
|
|
|
|
|
|
|
29
|
10
|
100
|
|
|
|
123
|
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
|
|
128
|
my $self = shift; |
51
|
|
|
|
|
|
|
|
52
|
69
|
|
|
|
|
193
|
my %open = $self->_open_start_events_for_span('strikethrough'); |
53
|
|
|
|
|
|
|
|
54
|
69
|
100
|
|
|
|
178
|
if ( $open{strikethrough} ) { |
55
|
2
|
|
|
|
|
53
|
return ( [ 'strikethrough_end', $open{strikethrough}->delimiter ] ); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
67
|
|
|
|
|
170
|
return ('strikethrough_start'); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) |
62
|
|
|
|
|
|
|
sub _match_bare_link { |
63
|
57
|
|
|
57
|
|
104
|
my $self = shift; |
64
|
57
|
|
|
|
|
103
|
my $text = shift; |
65
|
|
|
|
|
|
|
|
66
|
57
|
100
|
|
|
|
89
|
return unless ${$text} =~ m{ \G |
|
57
|
|
|
|
|
291
|
|
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
|
|
|
|
|
29
|
$self->_markup_event($link); |
82
|
|
|
|
|
|
|
|
83
|
5
|
|
|
|
|
35
|
return 1; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub _match_strikethrough_start { |
87
|
57
|
|
|
57
|
|
130
|
my $self = shift; |
88
|
57
|
|
|
|
|
95
|
my $text = shift; |
89
|
|
|
|
|
|
|
|
90
|
57
|
100
|
|
|
|
247
|
my ($delim) = $self->_match_delimiter_start( $text, qr/\~\~/ ) |
91
|
|
|
|
|
|
|
or return; |
92
|
|
|
|
|
|
|
|
93
|
1
|
|
|
|
|
10
|
my $event |
94
|
|
|
|
|
|
|
= $self->_make_event( StartStrikethrough => delimiter => $delim ); |
95
|
|
|
|
|
|
|
|
96
|
1
|
|
|
|
|
8
|
$self->_markup_event($event); |
97
|
|
|
|
|
|
|
|
98
|
1
|
|
|
|
|
6
|
return 1; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub _match_strikethrough_end { |
102
|
2
|
|
|
2
|
|
4
|
my $self = shift; |
103
|
2
|
|
|
|
|
3
|
my $text = shift; |
104
|
2
|
|
|
|
|
3
|
my $delim = shift; |
105
|
|
|
|
|
|
|
|
106
|
2
|
100
|
|
|
|
22
|
$self->_match_delimiter_end( $text, qr/\Q$delim\E/ ) |
107
|
|
|
|
|
|
|
or return; |
108
|
|
|
|
|
|
|
|
109
|
1
|
|
|
|
|
6
|
my $event = $self->_make_event( EndStrikethrough => delimiter => $delim ); |
110
|
|
|
|
|
|
|
|
111
|
1
|
|
|
|
|
5
|
$self->_markup_event($event); |
112
|
|
|
|
|
|
|
|
113
|
1
|
|
|
|
|
6
|
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.39 |
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 |