Markdent/Dialect/GitHub/BlockParser.pm

filter: Statementstmt 100% 36 / 36 Branchbran 62.5% 5 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 94.2% 49 / 52 CC 5 SCAR 10.0
CC
5
Cov
93%
_match_fenced_code_block
5.1
BEGIN
1.0
BEGIN
1.0
CRAP 2.7
« Markdent/Role/HTMLStream.pm ↑ Summary Markdent/Role/Simple.pm »
1 package Markdent::Dialect::GitHub::BlockParser;
2  
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 5 our $VERSION = '0.41';
8  
9 5 ▶use Markdent::Event::CodeBlock;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 ▶use Markdent::Regexes qw( $BlockStart $HorizontalWS );
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 5 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 5 with 'Markdent::Role::Dialect::BlockParser';
15  
16 37 ▶around _possible_block_matches => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
17 37 my $orig = shift;
18 37 my $self = shift;
19  
20 37 my @look_for = $self->$orig();
21 37 unshift @look_for, 'fenced_code_block';
22  
23 37 return @look_for;
24 5 };
25  
26 ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines)
27 37 ▶sub _match_fenced_code_block {
Subroutine _match_fenced_code_block: called CC=5 SCAR=16.4
28 37 my $self = shift;
29 37 my $text = shift;
30  
31 37 ▶ return unless ${$text} =~ / \G
Branch: 1 branch
BranchTrueFalseTotal
unless ${$text;} =~ / \G $Markdent::Dialect::GitHub::BlockParser::BlockStart ``` $Markdent::Dialect::GitHub::BlockParser::HorizontalWS?\{?\.?([\w-]+)?\}?$Markdent::Dialect::GitHub::BlockParser::HorizontalWS* # optional language name \n ( # code block content (?:.|\n)+? ) \n ``` \n /cgmx 30 7 37
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 my $lang = $1;
45 7 my $code = $2;
46  
47 7 ▶ $self->_debug_parse_result(
Branch: 2 branches
BranchTrueFalseTotal
if $self->debug 0 7 7
$lang ? : 0 0 0
48 $code,
49 'code block',
50 ( $lang ? [ language => $lang ] : () ),
51 ) if $self->debug;
52  
53 7 ▶ $self->_send_event(
Branch: 1 branch
BranchTrueFalseTotal
defined $lang ? : 4 3 7
54 'CodeBlock',
55 code => $code,
56 ( defined $lang ? ( language => $lang ) : () ),
57 );
58  
59 7 return 1;
60 }
61 ## use critic
62  
63 5 1;
64  
65 # ABSTRACT: Block parser for GitHub Markdown
66  
67 __END__
« Markdent/Role/HTMLStream.pm ↑ Summary Markdent/Role/Simple.pm »