/** * Compress HTML * * This is a heavy regex-based removal of whitespace, unnecessary comments and * tokens. IE conditional comments are preserved. There are also options to have * STYLE and SCRIPT blocks compressed by callback functions. * * A test suite is available. * * @package Minify * @author Stephen Clay */ namespace LiteSpeed\Lib ; defined( 'WPINC' ) || exit ; class HTML_MIN { /** * @var string */ protected $_html = ''; /** * @var boolean */ protected $_jsCleanComments = true; protected $_skipComments = array(); /** * "Minify" an HTML page * * @param string $html * * @param array $options * * 'cssMinifier' : (optional) callback function to process content of STYLE * elements. * * 'jsMinifier' : (optional) callback function to process content of SCRIPT * elements. Note: the type attribute is ignored. * * 'xhtml' : (optional boolean) should content be treated as XHTML1.0? If * unset, minify will sniff for an XHTML doctype. * * @return string */ public static function minify($html, $options = array()) { $min = new self($html, $options); return $min->process(); } /** * Create a minifier object * * @param string $html * * @param array $options * * 'cssMinifier' : (optional) callback function to process content of STYLE * elements. * * 'jsMinifier' : (optional) callback function to process content of SCRIPT * elements. Note: the type attribute is ignored. * * 'jsCleanComments' : (optional) whether to remove HTML comments beginning and end of script block * * 'xhtml' : (optional boolean) should content be treated as XHTML1.0? If * unset, minify will sniff for an XHTML doctype. */ public function __construct($html, $options = array()) { $this->_html = str_replace("\r\n", "\n", trim($html)); if (isset($options['xhtml'])) { $this->_isXhtml = (bool)$options['xhtml']; } if (isset($options['cssMinifier'])) { $this->_cssMinifier = $options['cssMinifier']; } if (isset($options['jsMinifier'])) { $this->_jsMinifier = $options['jsMinifier']; } if (isset($options['jsCleanComments'])) { $this->_jsCleanComments = (bool)$options['jsCleanComments']; } if (isset($options['skipComments'])) { $this->_skipComments = $options['skipComments']; } } /** * Minify the markeup given in the constructor * * @return string */ public function process() { if ($this->_isXhtml === null) { $this->_isXhtml = (false !== strpos($this->_html, '_replacementHash = 'MINIFYHTML' . md5($_SERVER['REQUEST_TIME']); $this->_placeholders = array(); // replace SCRIPTs (and minify) with placeholders $this->_html = preg_replace_callback( '/(\\s*)]*?>)([\\s\\S]*?)<\\/script>(\\s*)/i' ,array($this, '_removeScriptCB') ,$this->_html); // replace STYLEs (and minify) with placeholders $this->_html = preg_replace_callback( '/\\s*]*>)([\\s\\S]*?)<\\/style>\\s*/i' ,array($this, '_removeStyleCB') ,$this->_html); // remove HTML comments (not containing IE conditional comments). $this->_html = preg_replace_callback( '//' ,array($this, '_commentCB') ,$this->_html); // replace PREs with placeholders $this->_html = preg_replace_callback('/\\s*]*?>[\\s\\S]*?<\\/pre>)\\s*/i' ,array($this, '_removePreCB') ,$this->_html); // replace TEXTAREAs with placeholders $this->_html = preg_replace_callback( '/\\s*]*?>[\\s\\S]*?<\\/textarea>)\\s*/i' ,array($this, '_removeTextareaCB') ,$this->_html); // trim each line. // @todo take into account attribute values that span multiple lines. $this->_html = preg_replace('/^\\s+|\\s+$/m', '', $this->_html); // remove ws around block/undisplayed elements $this->_html = preg_replace('/\\s+(<\\/?(?:area|article|aside|base(?:font)?|blockquote|body' .'|canvas|caption|center|col(?:group)?|dd|dir|div|dl|dt|fieldset|figcaption|figure|footer|form' .'|frame(?:set)?|h[1-6]|head|header|hgroup|hr|html|legend|li|link|main|map|menu|meta|nav' .'|ol|opt(?:group|ion)|output|p|param|section|t(?:able|body|head|d|h||r|foot|itle)' .'|ul|video)\\b[^>]*>)/i', '$1', $this->_html); // remove ws outside of all elements $this->_html = preg_replace( '/>(\\s(?:\\s*))?([^<]+)(\\s(?:\s*))?$1$2$3<' ,$this->_html); // use newlines before 1st attribute in open tags (to limit line lengths) // $this->_html = preg_replace('/(<[a-z\\-]+)\\s+([^>]+>)/i', "$1\n$2", $this->_html); // fill placeholders $this->_html = str_replace( array_keys($this->_placeholders) ,array_values($this->_placeholders) ,$this->_html ); // issue 229: multi-pass to catch scripts that didn't get replaced in textareas $this->_html = str_replace( array_keys($this->_placeholders) ,array_values($this->_placeholders) ,$this->_html ); return $this->_html; } /** * From LSCWP 6.2: Changed the function to test for special comments that will be skipped. See: https://github.com/litespeedtech/lscache_wp/pull/622 */ protected function _commentCB($m) { // If is IE conditional comment return it. if(0 === strpos($m[1], '[') || false !== strpos($m[1], ' HTML Settings -> HTML Keep comments if(count($this->_skipComments) > 0){ foreach ($this->_skipComments as $comment) { if ($comment && strpos($m[1], $comment) !== false) { return $m[0]; } } } // Comment can be removed. return ''; } protected function _reservePlace($content) { $placeholder = '%' . $this->_replacementHash . count($this->_placeholders) . '%'; $this->_placeholders[$placeholder] = $content; return $placeholder; } protected $_isXhtml = null; protected $_replacementHash = null; protected $_placeholders = array(); protected $_cssMinifier = null; protected $_jsMinifier = null; protected function _removePreCB($m) { return $this->_reservePlace("_reservePlace("\\s*$)/', '', $css); // remove CDATA section markers $css = $this->_removeCdata($css); // minify $minifier = $this->_cssMinifier ? $this->_cssMinifier : 'trim'; $css = call_user_func($minifier, $css); return $this->_reservePlace($this->_needsCdata($css) ? "{$openStyle}/**/" : "{$openStyle}{$css}" ); } protected function _removeScriptCB($m) { $openScript = "_jsCleanComments) { $js = preg_replace('/(?:^\\s*\\s*$)/', '', $js); } // remove CDATA section markers $js = $this->_removeCdata($js); // minify /** * Added 2nd param by LiteSpeed * * @since 2.2.3 */ if ( $this->_jsMinifier ) { $js = call_user_func( $this->_jsMinifier, $js, trim( $m[ 2 ] ) ) ; } else { $js = trim( $js ) ; } return $this->_reservePlace($this->_needsCdata($js) ? "{$ws1}{$openScript}/**/{$ws2}" : "{$ws1}{$openScript}{$js}{$ws2}" ); } protected function _removeCdata($str) { return (false !== strpos($str, ''), '', $str) : $str; } protected function _needsCdata($str) { return ($this->_isXhtml && preg_match('/(?:[<&]|\\-\\-|\\]\\]>)/', $str)); } } GLOBAL GORKHA TIMES - Page 262 of 270 - सबै खबर एकै ठाँउमा
Breaking News

कुतियाकवरका बाढी प्रभावितहरूका लागि आश्रय बन्दै ‘सुरक्षित आवास’

दोधाराः कञ्चनपुरको दोधारा चाँदनी नगरपालिकास्थित कुतियाकवर बस्तीमा नगरपालिका, नेपाल राष्ट्रिय समाज कल्याण संघ (एनएनएसडब्ल्यूए) र निड्स नेपालद्वारा निमार्ण गरिएको सुरक्षित आवास कुतियाकवरका बाढी पीडितहरूका लागि महत्वपूर्ण आश्रयस्थल बनेको छ। दोधारा चाँदनी नगरपालिका-१० स्थित कुतियाकवर बस्तीमा बाढीबाट प्रभावित भएका स्थानिय बासिन्दाहरुका लागि दोधारा चाँदनी नगरपालिका, निड्स नेपाल, नेपाल राष्ट्रिय समाज कल्याण …

Read More »

कुतियाकवर विपद् व्यवस्थापन समितिद्वारा सेभहाउसमा ‘सुत्केरी’ भएकी महिलालाई सहयोग

दोधाराः दोधारा चाँदनी नगरपालिकामा सेभहाउसमा ‘सुत्केरी’ भएकी महिलालाई सहयोग गरिएको छ। दोधारा चाँदनी नगरपालिका वडा नम्बर-१० स्थित कुतियाकवर सामुदायिक विपद् व्यवस्थापन समितिले सेभहाउसमा ‘सुत्केरी’ भएकी गीता सुनारलाई सहयोग गरेको हो। गीता सुनारको घर गत भदौ २७ र २८ गतेको बाढीले पूर्णरूपमा क्षति भएपछि उहाँ नजिकै रहेको सेभहाउसमा परिवारसहित बस्दै आउनुभएको …

Read More »

दोधारामा विभिन्न कार्यक्रम गरि संविधान दिवस मनाईयो

कञ्चनपुरः कञ्चनपुरको दोधारा चाँदनी नगरपालिकामा विभिन्न कार्यक्रमको आयोजना गरि संविधान दिवस तथा राष्ट्रिय दिवस मनाईएको छ। दोधारा चाँदनी नगरपालिका स्तरीय उत्थानशील युवा सञ्जालको आयोजना तथा दोधारा चाँदनी नगरपालिकाको समन्वयमा संविधान दिवस तथा राष्ट्रिय दिवस २०८१ मनाईएको हो। दिवसका अवसरमा बिहान ७ बजे चाँदनी हाटबजारदेखि झोलुङ्गे पुलसम्म वृहत ऱ्याली, बिहान ९ …

Read More »

दोधारा चाँदनीका बाढी प्रभावित परिवारलाई आईएमई मार्फत नगद सहयोग

दोधाराः कञ्चनपुरको दोधारा चाँदनी नगरपालिकामा बाढीबाट पूर्ण क्षति भएका प्रभावित घर परिवारलाई आईएमई मार्फत नगद तथा खाद्यान्न सहयोग गरिएको छ। गत असार २२ गतेदेखि २४ गतेसम्म परेको अविरल वर्षासँगै आएको बाढीबाट प्रभावित भएका दोधारा चाँदनी नगरपालिकाका ८३ परिवारलाई प्रति घरपरिवार आईएमई मार्फत रू. ७ हजार ५ सय र खाद्यान्न सहयोग …

Read More »

संविधान दिवसको अवसरमा भीमदत्तमा वृहत वृक्षारोपण तथा सरसफाई कार्यक्रम सम्पन्न

कञ्चनपुरः कञ्चनपुरको भीमदत्त नगरपालिकामा संविधान दिवस तथा राष्ट्रिय दिवस-२०८१ को अवसरमा वृहत वृक्षारोपण तथा सरसफाई कार्यक्रम गरिएको छ। नेपाल राष्ट्रिय समाज कल्याण संघ (एनएनएसडब्ल्यूए) र डीसीए नेपालको साझेदारीमा सञ्चालित सुदृढ परियोजनाको गिफ्ट प्लान्टेशन सपोर्ट कार्यक्रमको आर्थिक तथा प्राविधिक सहयोग साथै कञ्चनपुर जिल्ला समन्वय समिति, भीमदत्त नगरपालिका, १८ नम्बर वडा कार्यालय, …

Read More »

संविधान दिवसको पूर्वसन्ध्यामा भीमदत्तमा सरसफाई, भोली ईको पार्कमा वृहत वृक्षारोपण गरिने

कञ्चनपुरः कञ्चनपुरको भीमदत्तमा संविधान दिवसको पूर्वसन्ध्यामा वृहत सरसफाई कार्यक्रमको आयोजना गरिएको छ। ‘सन्तुलित वातावरण सुशासन सहितको समाजबाद उन्मुख समृद्ध नगर, कृषि पर्यटन तथा प्रविधिमा आधारित अर्थतन्त्र विकासको आधार’ नारा सहित संविधान दिवसको पूर्वसन्ध्यामा कञ्चनपुरको महेन्द्रनगर बजार क्षेत्र वृहत सरसफाई कार्यक्रम गरिएको हो। भीमदत्त नगरपालिकाका नगर प्रमुख पदम बोगटीले १० औँ …

Read More »

कुतियाकवर बस्ती महाकाली नदीमा समाहित हुने सन्त्रास, वर्षेनीको कटानीले जमिन मासिदैँ

पप्पु गुरूङ्ग/दोधाराः विगतका दिनहरूमा कुतियाकवरलगायतका क्षेत्रमा उत्पादन हुने परवल साथै अन्य तरकारी भारतका विभिन्न शहरहरूमा निर्यात गरिन्थ्यो। जसबाट किसानहरूले मनग्य आम्दानी गर्थे। परवल उत्पादनबाट किसानहरूको जीवनस्तरमा सुधार आएको थियो। भारतीय सुरक्षाकर्मीहरूले परवल निर्यात गर्न रोक लगाएसँगै दोधारा चाँदनी नगरपालिकाका किसानहरूले परवलको खेती गर्न छाडेका छन्। दोधारा चाँदनी नगरपालिका वडा नं. …

Read More »

दोधारा चाँदनीका १ सय ७० बाढी प्रभावित परिवारलाई गैर खाद्य सामग्री वितरण

दोधाराः कञ्चनपुरको दोधारा चाँदनी नगरपालिकाका बाढी प्रभावितहरुलाई गैर खाद्य सामग्री वितरण गरिएको छ। अक्सफाम र निड्स नेपालको सहयोग तथा दोधारा चाँदनी नगरपालिकाको सहकार्यमा वडा नं. १० का १ सय ७० परिवारलाई गैर खाद्य सामग्री वितरण गरिएको हो। पूर्वानुमानमा आधारित पूर्वकार्यअन्तर्गत दोधारा चाँदनी नगरपालिकाका १ सय ७० घरपरिवारलाई गैर खाद्य सामग्री …

Read More »

पुनर्वासमा बाढी प्रभावित २०० परिवारलाई १७ लाख बराबरको गैर खाद्य सामग्री वितरण

कञ्चनपुरः कञ्चनपुरको पुनर्वास नगरपालिकाका बाढी प्रभावित परिवारहरूलाई गैर खाद्य सामग्री वितरण गरिएको छ। सेव द चिल्ड्रेन अन्तर्राष्ट्रिय र नेपाल राष्ट्रिय समाज कल्याण संघ (एनएनएसडब्ल्यूए) ले पुनर्वास नगरपालिकासँगको समन्वयमा बाढी प्रभावित २ सय परिवारलाई १७ लाख बराबरको अत्यावश्यक सामग्री सहयोग गरेको हो। बाढी प्रभावित परिवारहरूलाई हाईजिन किट, सेल्टर किट, किचन किट, …

Read More »

कुतियाकवर सामुदायिक विपद् व्यवस्थापन समितिद्वारा बाढी प्रभावितलाई खाद्यान्न सहयोग

कञ्चनपुरः कञ्चनपुरको दोधारा चाँदनी नगरपालिका-१० कुतियाकवरमा कुतियाकवर सामुदायिक विपद् व्यवस्थापन समितिले बाढी प्रभावितहरूलाई खाद्यान्न वितरण गरेको छ। कुतियाकवर सामुदायिक विपद् व्यवस्थापन समितिले नेपाल राष्ट्रिय समाज कल्याण संघ (एनएनएसडब्ल्यूए) र डीसीए नेपालको  सहयोग तथा दोधारा चाँदनी नगरपालिका-१० वडा कार्यालयसँगको समन्वयमा बाढी प्रभावित ४२ घर परिवारलाई खाद्यान्न वितरण गरेको हो। बाढी प्रभावित …

Read More »