You appear to be a bot. Output may be restricted
Description
Extracts @import
and @charset
rules from the supplied CSS. These rules must not be preceded by any other rules, or they will be ignored. (From the CSS 2.1 specification: "CSS 2.1 user agents must ignore any '@import' rule that occurs inside a block or after any non-ignored statement other than an @charset or an @import rule." Note also that @charset
is case sensitive whereas @import
is not.)
Usage
$string[] = CssInliner::extractImportAndCharsetRules( $css );
Parameters
- $css
- ( string ) required – CSS with comments removed
Returns
string[] The first element is the CSS with the valid @import
and @charset
rules removed. The second element contains a concatenation of the valid @import
rules, each followed by whatever whitespace followed it in the original CSS (so that either unminified or minified formatting is preserved); if there were no @import
rules, it will be an empty string. The (valid) @charset
rules are discarded.
Source
File name: woocommerce/vendor/pelago/emogrifier/src/Emogrifier/CssInliner.php
Lines:
private function extractImportAndCharsetRules($css) { $possiblyModifiedCss = $css; $importRules = ''; while ( \preg_match( '/^\\s*+(@((?i)import(?-i)|charset)\\s[^;]++;\\s*+)/', $possiblyModifiedCss, $matches ) ) { list($fullMatch, $atRuleAndFollowingWhitespace, $atRuleName) = $matches; if (\strtolower($atRuleName) === 'import') { $importRules .= $atRuleAndFollowingWhitespace; } $possiblyModifiedCss = \substr($possiblyModifiedCss, \strlen($fullMatch)); } return [$possiblyModifiedCss, $importRules]; }