| 1 | package Text::HTML::Turndown::HighlightedCodeBlock 0.12; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use 5.020; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use experimental 'signatures'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use List::MoreUtils 'all'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | our $highlightRegExp = qr/highlight-(?:text|source)-([a-z0-9]+)/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | our %RULES = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | highlightedCodeBlock => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 217 | ▶ | filter => sub ($rule, $node, $options) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 217 | my $firstChild = $node->firstChild; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 217 | ▶ | uc $node->nodeName eq 'DIV' && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%6/9
uc $node->nodeName eq 'DIV' && $node->className =~ /$Text::HTML::Turndown::HighlightedCodeBlock::highlightRegExp/u && $firstChild && uc $firstChild->nodeName eq 'PRE'
uc $node->nodeName eq "DIV" and $node->className =~ /$Text::HTML::Turndown::HighlightedCodeBlock::highlightRegExp/u and $firstChild
uc $node->nodeName eq "DIV" and $node->className =~ /$Text::HTML::Turndown::HighlightedCodeBlock::highlightRegExp/u
MC/DC25%1/4
uc $node->nodeName eq 'DIV' && $node->className =~ /$Text::HTML::Turndown::HighlightedCodeBlock::highlightRegExp/u && $firstChild && uc $firstChild->nodeName eq 'PRE'
uc $node->nodeName eq "DIV"
$node->className =~ /$Text::HTML::Turndown::HighlightedCodeBlock::highlightRegExp/u
$firstChild
uc $firstChild->nodeName eq 'PRE'
Truth table40%2/5
A and B and C && D
A= uc $node->nodeName eq "DIV"B= $node->className =~ /$Text::HTML::Turndown::HighlightedCodeBlock::highlightRegExp/uC= $firstChildD= uc $firstChild->nodeName eq 'PRE'
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | $node->className =~ /$highlightRegExp/ && | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | $firstChild && | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | uc $firstChild->nodeName eq 'PRE' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | ▶ | replacement => sub( $content, $node, $options, $context ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | ▶ | my $className = $node->className || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$node->className || ''
MC/DC0%0/1
$node->className || ''
$node->className
Truth table50%1/2
A
A= $node->className
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | my $language = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | ▶ | if( $className =~ /$highlightRegExp/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | $language = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | "\n\n" . $options->{fence} . $language . "\n" . | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | $node->firstChild->textContent . | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | "\n" . $options->{fence} . "\n\n" | |||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 22 | ▶ | sub install ($class, $target) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
install: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 22 | for my $key (keys %RULES) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 22 | $target->addRule($key, $RULES{$key}) | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | =head1 REPOSITORY | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | The public repository of this module is | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | L<https://github.com/Corion/Text-HTML-Turndown>. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | =head1 SUPPORT | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | The public support forum of this module is L<https://perlmonks.org/>. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | =head1 BUG TRACKER | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | Please report bugs in this module via the Github bug queue at | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | L<https://github.com/Corion/Text-HTML-Turndown/issues> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | Max Maischein C<corion@cpan.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | =head1 COPYRIGHT (c) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | Copyright 2025- by Max Maischein C<corion@cpan.org>. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | This module is released under the Artistic License 2.0. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||