| 1 | package Text::HTML::Turndown::Node 0.12; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 6 | ▶ | use 5.020; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use experimental 'signatures'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use stable 'postderef'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 6 | our @blockElements = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 'ADDRESS', 'ARTICLE', 'ASIDE', 'AUDIO', 'BLOCKQUOTE', 'BODY', 'CANVAS', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 'CENTER', 'DD', 'DIR', 'DIV', 'DL', 'DT', 'FIELDSET', 'FIGCAPTION', 'FIGURE', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 'FOOTER', 'FORM', 'FRAMESET', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'HEADER', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 'HGROUP', 'HR', 'HTML', 'ISINDEX', 'LI', 'MAIN', 'MENU', 'NAV', 'NOFRAMES', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 'NOSCRIPT', 'OL', 'OUTPUT', 'P', 'PRE', 'SECTION', 'TABLE', 'TBODY', 'TD', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 'TFOOT', 'TH', 'THEAD', 'TR', 'UL' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 6 | our %blockElements = map { $_ => 1, lc $_ => 1 } @blockElements; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 3246 | ▶ | sub _isBlock ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_isBlock: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 3246 | $blockElements{ $self->nodeName } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 6 | our @voidElements = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 'AREA', 'BASE', 'BR', 'COL', 'COMMAND', 'EMBED', 'HR', 'IMG', 'INPUT', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 'KEYGEN', 'LINK', 'META', 'PARAM', 'SOURCE', 'TRACK', 'WBR' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 6 | our %voidElements = map { $_ => 1, lc $_ => 1 } @voidElements; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 6 | has '_node' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | handles => [qw[ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | parentNode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | firstChild | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | previousSibling | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | nextSibling | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | childNodes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | lastChild | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | nodeName | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | nodeValue | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | nodeType | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | textContent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | getAttribute | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | isEqual | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | toString | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | find | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | ]], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 1221 | ▶ | sub _isVoid( $self ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_isVoid: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 1221 | $voidElements{ $self->nodeName } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 1078 | ▶ | sub _hasVoid( $self ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_hasVoid: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 1078 | return _has($self, \%voidElements) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 6 | has ['isVoid', 'hasVoid', 'isBlock', 'isMeaningfulWhenBlank', 'hasMeaningfulWhenBlank', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 'isCode'] => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 4 | ▶ | sub className( $self ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
className: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 4 | $self->getAttribute('class'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 4715 | ▶ | sub _isCode( $self ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_isCode: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 4715 | ▶ | return 1 if uc $self->nodeName eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 4644 | my $p = $self->parentNode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 4644 | ▶ | if( $p and $p->can('nodeName')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$p and $p->can("nodeName")
MC/DC50%1/2
$p and $p->can("nodeName")
$p
$p->can("nodeName")
Truth table66%2/3
A and B
A= $pB= $p->can("nodeName")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 3637 | return _isCode($self->parentNode) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 6 | our @meaningfulWhenBlankElements = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 'A', 'TABLE', 'THEAD', 'TBODY', 'TFOOT', 'TH', 'TD', 'IFRAME', 'SCRIPT', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 'AUDIO', 'VIDEO' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 6 | our %meaningfulWhenBlankElements = map { $_ => 1, lc $_ => 1 } @meaningfulWhenBlankElements; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 1078 | ▶ | sub _isMeaningfulWhenBlank( $self ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_isMeaningfulWhenBlank: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 1078 | $meaningfulWhenBlankElements{ $self->nodeName } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 1078 | ▶ | sub _hasMeaningfulWhenBlank( $self ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_hasMeaningfulWhenBlank: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 1078 | _has( $self, \%meaningfulWhenBlankElements ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 2156 | ▶ | sub _has( $self, $nodeNames ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_has: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 2156 | ▶ | return if ! $self->can('getElementsByTagName'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 1514 | for my $tag (sort keys $nodeNames->%*) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 39451 | ▶ | return 1 if $self->getElementsByTagName($tag) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 54 | ▶ | sub firstNonBlankChild( $self ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
firstNonBlankChild: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 54 | return ([$self->_node->nonBlankChildNodes]->[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 757 | ▶ | sub isBlank( $self ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
isBlank: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 757 | ▶ | !$self->isVoid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%9/9
not $self->isVoid || $self->isMeaningfulWhenBlank and $self->textContent =~ /^\s*$/u and not $self->hasVoid
not $self->isVoid || $self->isMeaningfulWhenBlank and $self->textContent =~ /^\s*$/u
$self->isVoid || $self->isMeaningfulWhenBlank
MC/DC100%4/4
not $self->isVoid || $self->isMeaningfulWhenBlank and $self->textContent =~ /^\s*$/u and not $self->hasVoid
$self->isVoid
$self->isMeaningfulWhenBlank
$self->textContent =~ /^\s*$/u
not $self->hasVoid
Truth table100%5/5
not(A || B) and C and not(D)
A= $self->isVoidB= $self->isMeaningfulWhenBlankC= $self->textContent =~ /^\s*$/uD= not $self->hasVoid
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | && !$self->isMeaningfulWhenBlank | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | && $self->textContent =~ /^\s*$/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | && !$self->hasVoid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | && !$self->hasMeaningfulWhenBlank() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 1078 | ▶ | around BUILDARGS => sub( $orig, $class, %args ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=20.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 1078 | my $node = $args{ _node }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 1078 | ▶ | if( ! exists $args{ isVoid } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 1078 | $args{ isVoid } = _isVoid( $node ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 1078 | ▶ | if( ! exists $args{ hasVoid } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 1078 | $args{ hasVoid } = _hasVoid( $node ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 1078 | ▶ | if( ! exists $args{ isMeaningfulWhenBlank } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 1078 | $args{ isMeaningfulWhenBlank } = _isMeaningfulWhenBlank( $node ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 1078 | ▶ | if( ! exists $args{ hasMeaningfulWhenBlank } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 1078 | $args{ hasMeaningfulWhenBlank } = _hasMeaningfulWhenBlank( $node ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 1078 | ▶ | if( ! exists $args{ isCode } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 1078 | $args{ isCode } = _isCode( $node ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 1078 | ▶ | if( ! exists $args{ isBlock } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 1078 | $args{ isBlock } = _isBlock( $node ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 1078 | return $class->$orig(\%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 6 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 757 | ▶ | sub flankingWhitespace( $node, $options ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flankingWhitespace: called CC=8 SCAR=21.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 757 | ▶ | if( _isBlock($node) || ($options->{ preformattedCode } && isCode($node) )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
_isBlock($node) or $options->{"preformattedCode"} and isCode($node)
$options->{"preformattedCode"} and isCode($node)
MC/DC100%3/3
_isBlock($node) or $options->{"preformattedCode"} and isCode($node)
_isBlock($node)
$options->{"preformattedCode"}
isCode($node)
Truth table100%4/4
A or B and C
A= _isBlock($node)B= $options->{"preformattedCode"}C= isCode($node)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 651 | return { leading => '', trailing => '' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 106 | my $edges = edgeWhitespace( $node->textContent ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | # abandon leading ASCII WS if left-flanked by ASCII WS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 106 | ▶ | if ($edges->{leadingAscii} && isFlankedByWhitespace('left', $node, $options)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$edges->{"leadingAscii"} and isFlankedByWhitespace("left", $node, $options)
MC/DC0%0/2
$edges->{"leadingAscii"} and isFlankedByWhitespace("left", $node, $options)
$edges->{"leadingAscii"}
isFlankedByWhitespace("left", $node, $options)
Truth table66%2/3
A and B
A= $edges->{"leadingAscii"}B= isFlankedByWhitespace("left", $node, $options)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | $edges->{leading} = $edges->{leadingNonAscii}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | # abandon trailing ASCII WS if right-flanked by ASCII WS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 106 | ▶ | if ($edges->{trailingAscii} && isFlankedByWhitespace('right', $node, $options)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$edges->{"trailingAscii"} and isFlankedByWhitespace("right", $node, $options)
MC/DC0%0/2
$edges->{"trailingAscii"} and isFlankedByWhitespace("right", $node, $options)
$edges->{"trailingAscii"}
isFlankedByWhitespace("right", $node, $options)
Truth table66%2/3
A and B
A= $edges->{"trailingAscii"}B= isFlankedByWhitespace("right", $node, $options)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | $edges->{trailing} = $edges->{trailingNonAscii} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | return { leading => $edges->{leading}, trailing => $edges->{trailing}, } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 106 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 106 | ▶ | sub edgeWhitespace ($string) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
edgeWhitespace: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 106 | $string =~ /^(([ \t\r\n]*)(\s*))(?:(?=\S)[\s\S]*\S)?((\s*?)([ \t\r\n]*))$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 106 | leading => $1, # whole string for whitespace-only strings | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | leadingAscii => $2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | leadingNonAscii => $3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | trailing => $4, # empty for whitespace-only strings | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | trailingNonAscii => $5, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | trailingAscii => $6, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 16 | ▶ | sub isFlankedByWhitespace( $side, $node, $options) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
isFlankedByWhitespace: called CC=8 SCAR=21.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 16 | my $sibling; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | my $regExp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 16 | my $isFlanked; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 16 | ▶ | if ($side eq 'left') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 7 | $sibling = $node->previousSibling; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 7 | $regExp = qr/ $/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 9 | $sibling = $node->nextSibling; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 9 | $regExp = qr/^ /; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 16 | ▶ | if ($sibling) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 10 | ▶ | if ($sibling->nodeType == 3) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 6 | $isFlanked = $sibling->nodeValue =~ /$regExp/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | ▶ | } elsif ($options->{preformattedCode} && $sibling->nodeName eq 'CODE') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$options->{"preformattedCode"} and $sibling->nodeName eq "CODE"
MC/DC0%0/2
$options->{"preformattedCode"} and $sibling->nodeName eq "CODE"
$options->{"preformattedCode"}
$sibling->nodeName eq "CODE"
Truth table66%2/3
A and B
A= $options->{"preformattedCode"}B= $sibling->nodeName eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | $isFlanked = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | ▶ | } elsif ($sibling->nodeType == 1 && !_isBlock($sibling)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$sibling->nodeType == 1 and not _isBlock($sibling)
MC/DC0%0/2
$sibling->nodeType == 1 and not _isBlock($sibling)
$sibling->nodeType == 1
not _isBlock($sibling)
Truth table33%1/3
A and not(B)
A= $sibling->nodeType == 1B= not _isBlock($sibling)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 4 | $isFlanked = $sibling->textContent =~ /$regExp/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 16 | return $isFlanked | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | =head1 REPOSITORY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | The public repository of this module is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | L<https://github.com/Corion/Text-HTML-Turndown>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | =head1 SUPPORT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | The public support forum of this module is L<https://perlmonks.org/>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | =head1 BUG TRACKER | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | Please report bugs in this module via the Github bug queue at | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | L<https://github.com/Corion/Text-HTML-Turndown/issues> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | Max Maischein C<corion@cpan.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | =head1 COPYRIGHT (c) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | Copyright 2025- by Max Maischein C<corion@cpan.org>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | This module is released under the Artistic License 2.0. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||