line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Markdent::Dialect::GitHub::BlockParser; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
2602
|
use strict; |
|
5
|
|
|
|
|
16
|
|
|
5
|
|
|
|
|
160
|
|
4
|
5
|
|
|
5
|
|
28
|
use warnings; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
134
|
|
5
|
5
|
|
|
5
|
|
27
|
use namespace::autoclean; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
43
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.40'; |
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
|
2729
|
use Markdent::Event::CodeBlock; |
|
5
|
|
|
|
|
22
|
|
|
5
|
|
|
|
|
232
|
|
10
|
5
|
|
|
5
|
|
1715
|
use Markdent::Regexes qw( $BlockStart $HorizontalWS ); |
|
5
|
|
|
|
|
21
|
|
|
5
|
|
|
|
|
718
|
|
11
|
|
|
|
|
|
|
|
12
|
5
|
|
|
5
|
|
38
|
use Moose::Role; |
|
5
|
|
|
|
|
15
|
|
|
5
|
|
|
|
|
51
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
with 'Markdent::Role::Dialect::BlockParser'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
around _possible_block_matches => sub { |
17
|
|
|
|
|
|
|
my $orig = shift; |
18
|
|
|
|
|
|
|
my $self = shift; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my @look_for = $self->$orig(); |
21
|
|
|
|
|
|
|
unshift @look_for, 'fenced_code_block'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
return @look_for; |
24
|
|
|
|
|
|
|
}; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) |
27
|
|
|
|
|
|
|
sub _match_fenced_code_block { |
28
|
37
|
|
|
37
|
|
65
|
my $self = shift; |
29
|
37
|
|
|
|
|
68
|
my $text = shift; |
30
|
|
|
|
|
|
|
|
31
|
37
|
100
|
|
|
|
57
|
return unless ${$text} =~ / \G |
|
37
|
|
|
|
|
543
|
|
32
|
|
|
|
|
|
|
$BlockStart |
33
|
|
|
|
|
|
|
``` |
34
|
|
|
|
|
|
|
$HorizontalWS?\{?\.?([\w-]+)?\}?$HorizontalWS* # optional language name |
35
|
|
|
|
|
|
|
\n |
36
|
|
|
|
|
|
|
( # code block content |
37
|
|
|
|
|
|
|
(?:.|\n)+? |
38
|
|
|
|
|
|
|
) |
39
|
|
|
|
|
|
|
\n |
40
|
|
|
|
|
|
|
``` |
41
|
|
|
|
|
|
|
\n |
42
|
|
|
|
|
|
|
/xmgc; |
43
|
|
|
|
|
|
|
|
44
|
7
|
|
|
|
|
25
|
my $lang = $1; |
45
|
7
|
|
|
|
|
15
|
my $code = $2; |
46
|
|
|
|
|
|
|
|
47
|
7
|
0
|
|
|
|
197
|
$self->_debug_parse_result( |
|
|
50
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$code, |
49
|
|
|
|
|
|
|
'code block', |
50
|
|
|
|
|
|
|
( $lang ? [ language => $lang ] : () ), |
51
|
|
|
|
|
|
|
) if $self->debug; |
52
|
|
|
|
|
|
|
|
53
|
7
|
100
|
|
|
|
42
|
$self->_send_event( |
54
|
|
|
|
|
|
|
'CodeBlock', |
55
|
|
|
|
|
|
|
code => $code, |
56
|
|
|
|
|
|
|
( defined $lang ? ( language => $lang ) : () ), |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
|
59
|
7
|
|
|
|
|
860
|
return 1; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
## use critic |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# ABSTRACT: Block parser for GitHub Markdown |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=pod |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=encoding UTF-8 |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 NAME |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Markdent::Dialect::GitHub::BlockParser - Block parser for GitHub Markdown |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 VERSION |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
version 0.40 |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 DESCRIPTION |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This role adds parsing for some of the Markdown extensions used on GitHub. See |
84
|
|
|
|
|
|
|
http://github.github.com/github-flavored-markdown/ for details. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 ROLES |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This role does the L<Markdent::Role::Dialect::BlockParser> role. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 BUGS |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
See L<Markdent> for bug reporting details. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Bugs may be submitted at L<https://github.com/houseabsolute/Markdent/issues>. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
I am also usually active on IRC as 'autarch' on C<irc://irc.perl.org>. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 SOURCE |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
The source code repository for Markdent can be found at L<https://github.com/houseabsolute/Markdent>. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 AUTHOR |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
This software is copyright (c) 2021 by Dave Rolsky. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
111
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
The full text of the license can be found in the |
114
|
|
|
|
|
|
|
F<LICENSE> file included with this distribution. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=cut |