var wo=null; var ofc=false; var lasttitle=' '; var lastcont=''; function butplus(thisf) { var idof=thisf.innerHTML.split(' id=\"')[1].split('\"')[0]; if (document.getElementById(idof).value.indexOf('+') != -1) { //alert('' + thisf.method + ' ... ' + idof); if (('' + thisf.method).toLowerCase() == 'get') { location.href=thisf.action + '?' + idof + '=' + encodeURIComponent(document.getElementById(idof).value); return false; } else if (encodeURIComponent(document.getElementById(idof).value).length <= 800) { thisf.method='GET'; location.href=thisf.action + '?' + idof + '=' + encodeURIComponent(document.getElementById(idof).value); return false; } else { //alert(document.getElementById(idof).value.replace(/\+/g,encodeURIComponent('+'))); document.getElementById(idof).value=document.getElementById(idof).value.replace(/\+/g,encodeURIComponent('+')); } } return true; } function ntofc() { ofc=false; } function tofc() { ofc=true; setTimeout(ntofc, 500); } function woit(ine) { var asttitle=''; var astcont=''; var rectis=ine.getBoundingClientRect(); if (wo) { wo.close(); wo=null; } if (('' + ine.type) == 'textarea' && ofc) { ofc=true; } else { // if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) { // wo=window.open('','_blank'); // } else { //alert(('' + ine.type) + ' ... ' + ine.outerHTML); // wo=window.open('','_blank','left=' + rectis.left + ',top=' + rectis.top + ',width=' + rectis.width + ',height=' + rectis.height); // } if (('' + ine.outerHTML).indexOf('') != -1) { //alert('0:' + ine.innerHTML); if (('' + ine.getAttribute('data-render')) != '') { var prefx=''; var sufx=''; if (('' + ine.getAttribute('data-render')).replace(/\>\;/g,'>').replace(/\<\;/g,'<').indexOf('') == -1) { prefx=''; sufx=''; } else if (('' + ine.getAttribute('data-render')).replace(/\>\;/g,'>').replace(/\<\;/g,'<').indexOf('') == -1) { prefx=''; sufx=''; } astcont=prefx + ('' + ine.getAttribute('data-render')).replace(/\>\;/g,'>').replace(/\<\;/g,'<').replace(/\&\#10004\;\ /g,'').replace(/\&\#10060\;\ /g,'') + sufx; if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) { wo=window.open('','_blank'); } else { //alert(('' + ine.type) + ' ... ' + ine.outerHTML); wo=window.open('','_blank','left=' + rectis.left + ',top=' + rectis.top + ',width=' + rectis.width + ',height=' + rectis.height); } wo.document.write(astcont); wo.document.title='PHP DOMDocument parsing passed onto web browser rendering'; lastcont=astcont; } else if (ine.innerHTML.indexOf('
' + String.fromCharCode(10) + '
' + String.fromCharCode(10) + '
' + String.fromCharCode(10)) != -1) { //alert('1:' + ine.innerHTML.split('
' + String.fromCharCode(10) + '
' + String.fromCharCode(10) + '
' + String.fromCharCode(10))[1]); astcont=ine.innerHTML.split('
' + String.fromCharCode(10) + '
' + String.fromCharCode(10) + '
' + String.fromCharCode(10))[1].replace(/\>\;/g,'>').replace(/\<\;/g,'<').replace(/\&\#10004\;\ /g,'').replace(/\&\#10060\;\ /g,'').replace(/\&\#10067\;\ /g,''); asttitle='PHP DOMDocument parsing passed onto web browser rendering'; //wo.document.write(ine.innerHTML.split('
' + String.fromCharCode(10) + '
' + String.fromCharCode(10) + '
' + String.fromCharCode(10))[1].replace(/\>\;/g,'>').replace(/\<\;/g,'<').replace(/\&\#10004\;\ /g,'').replace(/\&\#10060\;\ /g,'').replace(/\&\#10067\;\ /g,'')); if (asttitle != lasttitle || astcont != lastcont) { if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) { wo=window.open('','_blank'); } else { //alert(('' + ine.type) + ' ... ' + ine.outerHTML); wo=window.open('','_blank','left=' + rectis.left + ',top=' + rectis.top + ',width=' + rectis.width + ',height=' + rectis.height); } wo.document.write(astcont); lastcont=astcont; } } else { //alert('2:' + ine.innerHTML); astcont=ine.innerHTML.replace(/\>\;/g,'>').replace(/\<\;/g,'<').replace(/\&\#10004\;\ /g,'').replace(/\&\#10060\;\ /g,'').replace(/\&\#10067\;\ /g,'').replace(/^\ \.\.\.\ /g,''); asttitle='PHP DOMDocument parsing passed onto web browser rendering'; if (asttitle != lasttitle || astcont != lastcont) { //wo.document.write(ine.innerHTML.replace(/\>\;/g,'>').replace(/\<\;/g,'<').replace(/\&\#10004\;\ /g,'').replace(/\&\#10060\;\ /g,'').replace(/\&\#10067\;\ /g,'').replace(/^\ \.\.\.\ /g,'')); if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) { wo=window.open('','_blank'); } else { //alert(('' + ine.type) + ' ... ' + ine.outerHTML); wo=window.open('','_blank','left=' + rectis.left + ',top=' + rectis.top + ',width=' + rectis.width + ',height=' + rectis.height); } wo.document.write(astcont); lastcont=astcont; } wo.document.title='PHP DOMDocument parsing passed onto web browser rendering'; lasttitle='PHP DOMDocument parsing passed onto web browser rendering'; } } else if (('' + ine.type) != 'textarea') { //alert(ine.outerHTML.split('')[0].split('>')[1]); //if (('' + ine.outerHTML).indexOf('DOMDocument') != -1) { //wo.document.write(ine.outerHTML.split('')[0].split('>')[1].replace(/\>\;/g,'>').replace(/\<\;/g,'<').replace(/\&\#10004\;\ /g,'').replace(/\&\#10060\;\ /g,'').replace(/\&\#10067\;\ /g,'').replace(/^\ \.\.\.\ /g,'')); //wo.document.title='PHP DOMDocument parsing passed onto web browser rendering'; //} else { astcont=ine.outerHTML.split('')[0].split('>')[1].replace(/\>\;/g,'>').replace(/\<\;/g,'<'); asttitle='PHP tidy module parsing passed onto web browser rendering'; if (asttitle != lasttitle || astcont != lastcont) { if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) { wo=window.open('','_blank'); } else { //alert(('' + ine.type) + ' ... ' + ine.outerHTML); wo=window.open('','_blank','left=' + rectis.left + ',top=' + rectis.top + ',width=' + rectis.width + ',height=' + rectis.height); } //wo.document.write(ine.outerHTML.split('')[0].split('>')[1].replace(/\>\;/g,'>').replace(/\<\;/g,'<')); wo.document.write(astcont); lastcont=astcont; wo.document.title='PHP tidy module parsing passed onto web browser rendering'; lasttitle='PHP tidy module parsing passed onto web browser rendering'; //} } } else { astcont=ine.value; if (document.URL.indexOf('localhost') != -1) { asttitle='Your proposed HTML passed onto web browser rendering'; } else { asttitle='Your proposed HTML passed onto web browser rendering'; } if (asttitle != lasttitle || astcont != lastcont) { if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) { wo=window.open('','_blank'); } else { //alert(('' + ine.type) + ' ... ' + ine.outerHTML); wo=window.open('','_blank','left=' + rectis.left + ',top=' + rectis.top + ',width=' + rectis.width + ',height=' + rectis.height); } //wo.document.write(ine.value); wo.document.write(astcont); lastcont=astcont; if (document.URL.indexOf('localhost') != -1) { wo.document.title='Your proposed HTML passed onto web browser rendering'; lasttitle='Your proposed HTML passed onto web browser rendering'; } else { wo.document.title='Your proposed HTML passed onto web browser rendering'; lasttitle='Your proposed HTML passed onto web browser rendering'; } } } } } "; $htmlin = '

first

test bogus'; if (isset($_GET['yourhtml'])) { $incv="tidy_parse_string"; if (strpos($_GET['yourhtml'], '+') !== false && strpos($_GET['yourhtml'], ' ') === false) { $htmlin=str_replace(':plus:','+',str_replace('+',' ',urldecode(str_replace('%2B',':plus:',$_GET['yourhtml'])))); } else { $htmlin=$_GET['yourhtml']; } //file_put_contents('x.x', $_GET['yourhtml'] . "\n\n" . urldecode($_GET['yourhtml']) . "\n\n" . $htmlin . "\n ... via ...\n" . str_replace('%2B','plus',$_GET['yourhtml'])); if (strpos(strtolower($htmlin), 'appendChild($docx->importNode($e, true)); $dfx=$docx->saveHTML(); if ($ioff == -2 && strpos(strtolower($dfx), 'importNode($n->cloneNode(true),true); $d->appendChild($b); $h = $d->saveHTML(); // remove outter tags if (!$outer) { $h = substr($h,strpos($h,'>')+1,-(strlen($n->nodeName)+4)); } else { if ($ioff == -2 && strpos(strtolower($h), '','>',str_replace('<','<',str_replace(' ','',str_replace(' ','',str_replace("\n",'',str_replace("\r",'',str_replace("\r\n",'',str_replace("'",'',str_replace('"','',('' . $lasth)))))))))) . "\n\n" . str_replace('>','>',str_replace('<','<',str_replace(' ','',str_replace(' ','',str_replace("\n",'',str_replace("\r",'',str_replace("\r\n",'',str_replace("'",'',str_replace('"','',('' . $h))))))))))); if (strpos(str_replace('>','>',str_replace('<','<',str_replace(' ','',str_replace(' ','',str_replace("\n",'',str_replace("\r",'',str_replace("\r\n",'',str_replace("'",'',str_replace('"','',('' . $lasth)))))))))), str_replace('>','>',str_replace('<','<',str_replace(' ','',str_replace(' ','',str_replace("\n",'',str_replace("\r",'',str_replace("\r\n",'',str_replace("'",'',str_replace('"','',('' . $h))))))))))) !== false) { return '❓ ' . $h; } $lasth=""; return '✔ ' . $h; } else if (1 == 1) { //file_put_contents('x.x','' . $h . "\n" . str_replace('"','',$origh)); if (stripos($h, '') === false) { $lasth='❌ ' . $h; return $lasth; } else { $lasth=""; return '❌ ' . $h; } } return '' . $h; } if (function_exists($incv)) { try { $tidy = tidy_parse_string($htmlin); $twc='' . tidy_warning_count($tidy) . ' warnings'; $tec='' . tidy_error_count($tidy) . ' errors

' . str_replace('>','>',str_replace('<','<',tidy_get_output($tidy))) . '
'; } catch (Exception $ex) { $there=false; $tec='No tidy module detected.'; } } else { $tec='No tidy module detected.'; $there=false; $doc = new DOMDocument(); $doc->loadHTML($htmlin); //foreach ($doc->childNodes as $itemcn) { //if ($rest == "") { $rest = " +++ "; } //$rest.=' ' . str_replace('>','>',str_replace('<','<',nodeContent($itemcn, false))); //} foreach ($doc->getElementsByTagName("*") as $item) { $elecnt++; if ($rest == "") { $rest = " ... "; } //$rest.='
' . str_replace('>','>',str_replace('<','<',outerHTML($item))); $h4more=" onclick=woit(this); id=tidyoutdd title='PHP DOMDocument parses HTML to look like below and click here to show web browser rendering'"; $rest.='
' . str_replace('>','>',str_replace('<','<',nodeContent($item, true))); $unrest.=str_replace('✔ ','', str_replace('❌ ','',str_replace('❓ ','',str_replace('>','>',str_replace('<','<',nodeContent($item, true)))))); } if ($unrest != '') { //file_put_contents('x.x',$unrest); $sh4=" function laterh4() { document.getElementById('myh4').setAttribute(\"data-render\", \"" . str_replace("\n","",str_replace("\r\n","",str_replace('"','" + String.fromCharCode(34) + "',$unrest))) . "\"); } setTimeout(laterh4, 2000); "; } //if ($rest != '') { $rest.=''; } $twc='Number of elements detected is ' . ($ioff + $elecnt) . $rest; } //echo tidy_error_count($tidy) . "\n"; //1 //echo tidy_warning_count($tidy) . "\n"; //5 if (!$there && strpos($_SERVER['SERVER_NAME'], 'localhost') === false) { echo "Using tidy" . $scr . "

Using tidy

RJM Programming - March, 2022 - Thanks to https://www.php.net/manual/en/function.tidy-warning-count.php

" . $tec . "

" . $twc . "

Mac OS X or macOS MAMP


Windows MAMP


PHP DomDocument


" . $sh4 . ""; } else if (!$isthere) { echo "Using tidy" . $scr . "

Using tidy

RJM Programming - March, 2022 - Thanks to https://www.php.net/manual/en/function.tidy-warning-count.php

" . $tec . "

" . $twc . "



" . $sh4 . ""; } else { echo "Using tidy" . $scr . "

Using tidy

RJM Programming - March, 2022 - Thanks to https://www.php.net/manual/en/function.tidy-warning-count.php

" . $twc . "

" . $twc . "



" . $sh4 . ""; } ?>