| | | | | | | | | | | | | | | $current=($env:current).trimend('\'); | | $enc=New-Object System.Text.UTF8Encoding $False; | | $files=@(dir -literal $current -recurse|?{('.xhtml' -eq $_.Extension) -and ($_ -is [System.IO.FileInfo])}); | | for($i=0;$i -lt $files.length;$i++){ | | if($files[$i].Directory.Name -eq 'juans'){ | | write-host $files[$i].FullName.Substring($current.length); | | $text=[IO.File]::ReadAllText($files[$i].FullName, $enc); | | $text=[regex]::replace($text, '(<body(?:\s[^>]+?)?>)([\s\S]+?)</body>', { | | param($m1); | | $content=[regex]::replace($m1.groups[2].value, '(>)([^<>]+?)(<)', { | | param($m2); | | if($m2.groups[2].value.trim() -ne ''){ | | return ($m2.groups[1].value+'<span class="text_1">'+$m2.groups[2].value+'</span>'+$m2.groups[3].value); | | }else{return $m2.groups[0].value;} | | }); | | return ($m1.groups[1].value+$content+$m1.groups[1].value); | | }); | | [IO.File]::WriteAllText($files[$i].FullName, $text, $enc); | | } | | }COPY |
|