Highlight/sourcehighlight.pm

filter: Statementstmt 55.0% 11 / 20 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 50.0% 3 / 6 Podpod 0.0% 0 / 3 totaltotal 30.4% 14 / 46 CC 6 SCAR 31.6
CC
6
Cov
34%
language
42.0
markdown
2.0
highlight
2.0
CRAP 23.5
« Highlight.pm ↑ Summary Highlight/pandoc.pm »
1 package Text::ANSI::Highlight::sourcehighlight;
2  
3 1 ▶use v5.16;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Text::ANSI::Highlight ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 # source-highlight of GNU, with esc.style, the style which comes with
8 # it: the colors that less shows by its lesspipe. The language is
9 # given after it by -s.
10 1 our @COMMAND = qw(source-highlight -f esc --style-file=esc.style);
11  
12 # The languages, and the extensions of the files, that the command
13 # knows (source-highlight --lang-list)
14 1 my $language;
15  
16 0 ▶sub language {
Subroutine language: not called CC=6 SCAR=37.4
Pod undocumented
17 0 ▶ $language //= do {
Condition0%0/3
$language //= do { my $list = Text::ANSI::Highlight::run([$COMMAND[0], "--lang-list"], "") // ""; +{map({/^(\S+) = (\S+)\.lang$/u && $2 ne "nohilite" ? ($1, 1) : ();} split(/\n/u, $list, 0))} }
l!l&&r!l&&!r
000
MC/DC0%0/2
$language //= do { my $list = Text::ANSI::Highlight::run([$COMMAND[0], "--lang-list"], "") // ""; +{map({/^(\S+) = (\S+)\.lang$/u && $2 ne "nohilite" ? ($1, 1) : ();} split(/\n/u, $list, 0))} }
$language do { my $list = Text::ANSI::Highlight::run([$COMMAND[0], "--lang-list"], "") // ""; +{map({/^(\S+) = (\S+)\.lang$/u && $2 ne "nohilite" ? ($1, 1) : ();} split(/\n/u, $list, 0))} }
Truth table0%0/3
A //= B
A= $languageB= do { my $list = Text::ANSI::Highlight::run([$COMMAND[0], "--lang-list"], "") // ""; +{map({/^(\S+) = (\S+)\.lang$/u && $2 ne "nohilite" ? ($1, 1) : ();} split(/\n/u, $list, 0))} }
ABresult
1X1
011
000
18 0 ▶ my $list = Text::ANSI::Highlight::run([ $COMMAND[0], '--lang-list' ], '') // '';
Condition0%0/2
Text::ANSI::Highlight::run([$COMMAND[0], "--lang-list"], "") // ""
l!l
00
MC/DC0%0/1
Text::ANSI::Highlight::run([$COMMAND[0], "--lang-list"], "") // ""
Text::ANSI::Highlight::run([$COMMAND[0], "--lang-list"], "")
Truth table0%0/2
A
A= Text::ANSI::Highlight::run([$COMMAND[0], "--lang-list"], "")
Aresult
11
00
19 0 ▶ +{ map { /^(\S+) = (\S+)\.lang$/ && $2 ne 'nohilite' ? ($1 => 1) : () } split /\n/, $list };
Branch: 1 branch
BranchTrueFalseTotal
/^(\S+) = (\S+)\.lang$/u && $2 ne 'nohilite' ? : 0 0 0
Condition0%0/3
/^(\S+) = (\S+)\.lang$/u and $2 ne "nohilite"
!ll&&!rl&&r
000
MC/DC0%0/2
/^(\S+) = (\S+)\.lang$/u and $2 ne "nohilite"
/^(\S+) = (\S+)\.lang$/u $2 ne "nohilite"
Truth table0%0/3
A and B
A= /^(\S+) = (\S+)\.lang$/uB= $2 ne "nohilite"
ABresult
0X0
100
111
20 };
21 0 ▶ $language->{$_[0]} ? $_[0] : undef;
Branch: 1 branch
BranchTrueFalseTotal
$$language{$_[0]} ? : 0 0 0
22 }
23  
24 # It has no definition of Markdown: the text around the code of a
25 # Markdown text is left as it is.
26 0 ▶sub markdown { 0 }
Subroutine markdown: not called CC=1 SCAR=6.9
Pod undocumented
27  
28 # The command runs once for each text.
29 0 ▶sub highlight {
Subroutine highlight: not called CC=1 SCAR=6.9
Pod undocumented
30 map {
31 0 my($lang, $text) = @$_;
32 0 Text::ANSI::Highlight::run([ @COMMAND, '-s', $lang ], $text);
33 } @_;
34 }
35  
36 1 1;
« Highlight.pm ↑ Summary Highlight/pandoc.pm »