PPI-HTML-CodeFolder
view release on metacpan or search on metacpan
lib/PPI/HTML/CodeFolder.pm view on Meta::CPAN
#
# original html may have no style, so we've got to add OR replace
#
$html=~s|</head>|$style</head>|s
unless ($html=~s|<style type="text/css">.+</style>|$style|s);
#
# force spans to end before line endings
#
$html=~s!(<br>\s*)</span>!</span>$1!g;
#
# split multiline comments into 2 spans: 1st line (in case its midline)
# and the remainder; note that the prior substitution avoids
# doing this to single line comments
#
$html=~s/(?!<br>\s+)(<span class=['"]comment['"]>[^<]+)<br>\n/$1<\/span><br>\n<span class="comment">/g;
#
# keep folded fragments here for later insertion
# as fold DIVs; key is starting line number,
# value is [ number of lines, text ]
#
my %folddivs = ( 1 => [ 0, '', 0, 0 ]);
</span></pre></div>
<div id='ft692' class='folddiv'><pre id='preft692'><span class="ct">#</span>
<span class="ct"># expand tabs as needed (we use 4 space tabs)
# have to adjust some spans that confuse tab processing
# </span></pre></div>
<div id='ft703' class='folddiv'><pre id='preft703'><span class="ct">#</span>
<span class="ct"># scan for and replace tabs; adjust positions
# of extracted tags as needed
# </span></pre></div>
<div id='ft745' class='folddiv'><pre id='preft745'><span class="ct">#</span>
<span class="ct"># split multiline comments into 2 spans: 1st line (in case its midline)
# and the remainder; note that the prior substitution avoids
# doing this to single line comments
# </span></pre></div>
<div id='ft751' class='folddiv'><pre id='preft751'><span class="ct">#</span>
<span class="ct"># keep folded fragments here for later insertion
# as fold DIVs; key is starting line number,
# value is [ number of lines, text ]
# </span></pre></div>
<div id='ft757' class='folddiv'><pre id='preft757'><span class="ct">#</span>
<span class="ct"># count <br> tags, and looks for any of
</span></pre></div>
<div id='ft692' class='folddiv'><pre id='preft692'><span class="ct">#</span>
<span class="ct"># expand tabs as needed (we use 4 space tabs)
# have to adjust some spans that confuse tab processing
# </span></pre></div>
<div id='ft703' class='folddiv'><pre id='preft703'><span class="ct">#</span>
<span class="ct"># scan for and replace tabs; adjust positions
# of extracted tags as needed
# </span></pre></div>
<div id='ft745' class='folddiv'><pre id='preft745'><span class="ct">#</span>
<span class="ct"># split multiline comments into 2 spans: 1st line (in case its midline)
# and the remainder; note that the prior substitution avoids
# doing this to single line comments
# </span></pre></div>
<div id='ft751' class='folddiv'><pre id='preft751'><span class="ct">#</span>
<span class="ct"># keep folded fragments here for later insertion
# as fold DIVs; key is starting line number,
# value is [ number of lines, text ]
# </span></pre></div>
<div id='ft757' class='folddiv'><pre id='preft757'><span class="ct">#</span>
<span class="ct"># count <br> tags, and looks for any of
( run in 1.468 second using v1.01-cache-2.11-cpan-71847e10f99 )