| Server IP : 104.21.80.248 / Your IP : 172.71.28.156 Web Server : Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30 System : Windows NT WIN-ECQAAA40806 6.2 build 9200 (Windows Server 2012 Standard Edition) i586 User : SYSTEM ( 0) PHP Version : 5.6.30 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : E:/Inetpub/www/game/vendor/mpdf/mpdf/src/Css/ |
Upload File : |
<?php
namespace Mpdf\Css;
class CommentParser
{
/**
* Remove mPDF-specific and general HTML comments from content.
*
* Removes <!--mpdf and mpdf--> markers and all HTML comments.
*
* @param string $html HTML content to clean
* @return string HTML with comments removed
*/
public function removeHtmlComments($html)
{
$html = preg_replace('/<!--mpdf/i', '', $html);
$html = preg_replace('/mpdf-->/i', '', $html);
$html = preg_replace('/<!--.*?-->/s', ' ', $html);
return $html;
}
/**
* Remove HTML and CSS comments from style blocks.
*
* Removes both HTML comments (<!-- -->) and CSS comments from
* <style> tag contents while preserving the structure.
*
* @param string $html HTML content with style tags
* @return string HTML with cleaned style blocks
*/
public function removeCommentsFromStyleBlocks($html)
{
preg_match_all('/<style.*?>(.*?)<\/style>/si', $html, $m);
if (count($m[1]) === 0) {
return $html;
}
foreach ($m[1] as $style) {
$sub = str_replace(['<!--', '-->'], ' ', $style);
$sub = '>' . preg_replace('|/\*.*?\*/|s', ' ', $sub) . '</style>';
$html = str_replace('>' . $style . '</style>', $sub, $html);
}
return $html;
}
}