| 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))}
}
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))}
}
| |||||||||||||||||||||||||||||
| 18 | 0 | ▶ | my $list = Text::ANSI::Highlight::run([ $COMMAND[0], '--lang-list' ], '') // ''; | ||||||||||||||||||||||||||
|
Condition0%0/2
Text::ANSI::Highlight::run([$COMMAND[0], "--lang-list"], "") // ""
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"], "")
| |||||||||||||||||||||||||||||
| 19 | 0 | ▶ | +{ map { /^(\S+) = (\S+)\.lang$/ && $2 ne 'nohilite' ? ($1 => 1) : () } split /\n/, $list }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
/^(\S+) = (\S+)\.lang$/u and $2 ne "nohilite"
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"
| |||||||||||||||||||||||||||||
| 20 | }; | ||||||||||||||||||||||||||||
| 21 | 0 | ▶ | $language->{$_[0]} ? $_[0] : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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; | |||||||||||||||||||||||||||