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; } $iqs=0; $emore=''; //if (file_exists('/tmp/tidy_example_error.log')) { // $emore='
' . file_get_contents('/tmp/tidy_example_error.log') . '
'; // unlink('/tmp/tidy_example_error.log'); //} if (function_exists($incv)) { try { libxml_use_internal_errors(true); $tidy = tidy_parse_string($htmlin); $tidy->cleanRepair(); foreach (libxml_get_errors() as $error) { // thanks to https://www.php.net/manual/en/function.libxml-get-errors.php // handle errors here if ($emore == '') { $emore.='

' . $within . ''; } switch ($error->level) { case LIBXML_ERR_WARNING: $emore .= "tidy_parse_string(\$html); Warning $error->code: "; break; case LIBXML_ERR_ERROR: $emore .= "tidy_parse_string(\$html); Error $error->code: "; break; case LIBXML_ERR_FATAL: $emore .= "tidy_parse_string(\$html); Fatal Error $error->code: "; break; } $emore.=$error->message . ' at line ' . $error->line . ' ' . $error->line . ', column ' . $error->column . ' ' . $qs[($iqs % sizeof($qs))] . '
'; if ($error->column == 0) { $betterbws[-1 + $error->line]='' . $error->line . '' . $qs[($iqs % sizeof($qs))] . '' . $betterbws[-1 + $error->line]; } else { $betterbws[-1 + $error->line]=substr($betterbws[-1 + $error->line],0,$error->column) . '' . $error->line . '' . $qs[($iqs % sizeof($qs))] . '' . substr($betterbws[-1 + $error->line],$error->column); } $betterwithin=str_replace($bws[-1 + $error->line], $betterbws[-1 + $error->line], $betterwithin); } libxml_clear_errors(); if ($emore != '') { //$betterwithin=str_replace('>','~',str_replace('<','`',$betterwithin)); $emore=str_replace($within, str_replace('</SUP>','',str_replace('<SUP>','',str_replace('</SUB>','',str_replace('<SUB>','',str_replace('<BR>','
',str_replace('>','>',str_replace('<','<',$betterwithin))))))), $emore) . '

'; } $twc='' . tidy_warning_count($tidy) . ' warnings'; $tec='' . tidy_error_count($tidy) . ' errors
' . $emore . '

' . str_replace('>','>',str_replace('<','<',tidy_get_output($tidy))) . '
'; } catch (Exception $ex) { $there=false; $tec='No tidy module detected.'; } } else { $there=false; libxml_use_internal_errors(true); $doc = new DOMDocument(); $doc->validateOnParse = true; $doc->loadHTML($htmlin); $betterwithin=str_replace("\n","
",$htmlin); $within=str_replace("\n","
",str_replace('>','~',str_replace('<','`',$htmlin))); $bws=explode("
", $betterwithin); $betterbws=explode("
", $betterwithin); $errarr=[]; $errline=[]; $lastline=-1; foreach (libxml_get_errors() as $error) { // thanks to https://www.php.net/manual/en/function.libxml-get-errors.php if ($error->line != $lastline) { $iqs=0; if (sizeof($errline) != 0) { $lastone=$errarr[-1 + sizeof($errarr)]; for ($jj=(-1 + sizeof($errline)); $jj>=0; $jj--) { $errarr[-1 + sizeof($errarr)]=$errline[$jj]; } $errarr[sizeof($errarr)]=$lastone; $errline=[]; } $errarr[sizeof($errarr)]=$error; $lastline=$error->line; } else { $iqs++; $errline[sizeof($errline)]=$error; } if ($emore == '') { $emore.='

' . $within . ''; } switch ($error->level) { case LIBXML_ERR_WARNING: $emore .= "DOMDocument::loadHTML(); Warning $error->code: "; break; case LIBXML_ERR_ERROR: $emore .= "DOMDocument::loadHTML(); Error $error->code: "; break; case LIBXML_ERR_FATAL: $emore .= "DOMDocument::loadHTML(); Fatal Error $error->code: "; break; } $emore.=$error->message . ' at line ' . $error->line . ' ' . $error->line . ', column ' . $error->column . ' ' . $qs[($iqs % sizeof($qs))] . '
'; } if (sizeof($errline) != 0) { $lastone=$errarr[sizeof($errarr)]; for ($jj=(-1 + sizeof($errline)); $ii>=0; $ii--) { $errarr[sizeof($errarr)]=$errline[$jj]; } $errarr[sizeof($errarr)]=$lastone; $errline=[]; } $iqs=0; //foreach (libxml_get_errors() as $error) { // thanks to https://www.php.net/manual/en/function.libxml-get-errors.php for ($ii=0; $iicolumn == 0) { $betterbws[-1 + $error->line]='' . $error->line . '' . $qs[($iqs % sizeof($qs))] . '' . $betterbws[-1 + $error->line]; } else { $betterbws[-1 + $error->line]=substr($betterbws[-1 + $error->line],0,(-1 + $error->column)) . '' . $error->line . '' . $qs[($iqs % sizeof($qs))] . '' . substr($betterbws[-1 + $error->line],(-1 + $error->column)); } if (($ii + 1) == sizeof($errarr)) { $iqs=0; $betterwithin=str_replace($bws[-1 + $error->line], $betterbws[-1 + $error->line], $betterwithin); } else if ($errarr[$ii + 1]->line != $errarr[$ii]->line) { $iqs=0; $betterwithin=str_replace($bws[-1 + $error->line], $betterbws[-1 + $error->line], $betterwithin); } else { $iqs++; } } libxml_clear_errors(); if ($emore != '') { //$betterwithin=str_replace('>','~',str_replace('<','`',$betterwithin)); $emore=str_replace($within, str_replace('</SUP>','',str_replace('<SUP>','',str_replace('</SUB>','',str_replace('<SUB>','',str_replace('<BR>','
',str_replace('>','>',str_replace('<','<',$betterwithin))))))), $emore) . '

'; } $tec='No tidy module detected.' . $emore; //foreach ($doc->childNodes as $itemcn) { //if ($rest == "") { $rest = " +++ "; } //$rest.=' ' . str_replace('>','>',str_replace('<','<',nodeContent($itemcn, false))); //} $onediv="
"; 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'"; $lcont=str_replace('>','>',str_replace('<','<',nodeContent($item, true))); if ($lcont != '') { $rest.='
' . $onediv . $lcont; $onediv=''; } $unrest.=str_replace('✔ ','', str_replace('❌ ','',str_replace('❓ ','',str_replace('>','>',str_replace('<','<',nodeContent($item, true)))))); } if ($unrest != '') { $rest.='
'; //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 or DOMDocument as PHP Online HTML Validator" . $scr . "

Using tidy or DOMDocument as PHP Online HTML Validator

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 . ""; echo "Using tidy or DOMDocument as PHP Online HTML Validator" . $scr . "

Using tidy or DOMDocument as PHP Online HTML Validator

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

" . $tec . "

" . $twc . "


Mac OS X or macOS MAMPWindows MAMP ... or ...PHP DOMDocument






" . $sh4 . ""; } else if (!$isthere) { echo "Using tidy or DOMDocument as PHP Online HTML Validator" . $scr . "

Using tidy or DOMDocument as PHP Online HTML Validator

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

" . $tec . "

" . $twc . "




" . $sh4 . ""; } else { echo "Using tidy or DOMDocument as PHP Online HTML Validator" . $scr . "

Using tidy or DOMDocument as PHP Online HTML Validator

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

" . $twc . "

" . $twc . "




" . $sh4 . ""; } ?>