Concatenate and compress a list of CSS stylesheets. When compressing a
 :datauri or :mhtml variant, post-processes the result to embed
 referenced assets.
19867
def compress_css(paths, variant=nil, asset_url=nil)
      @asset_contents = {}
      css = concatenate_and_tag_assets(paths, variant)
      css = @css_compressor.compress(css) if Jammit.compress_assets
      case variant
      when nil      then return css
      when :datauri then return with_data_uris(css)
      when :mhtml   then return with_mhtml(css, asset_url)
      else raise PackageNotFound, "\"#{variant}\" is not a valid stylesheet variant"
      end
    end
215398
protected function combineCssFiles()
	{
		// Check the need for combination
		if (count($this->cssFiles) < 2)
			return;

		$cssFiles = array();
		$toBeCombined = array();
		foreach ($this->cssFiles as $url => $media)
		{
			$file = $this->getLocalPath($url);

			if ($file === false)
				$cssFiles[$url] = $media;
			else
			{
				$media = strtolower($media);
				if ($media === '')
					$media = 'all';
				if (!isset($toBeCombined[$media]))
					$toBeCombined[$media] = array();
				$toBeCombined[$media][$url] = $file;
			}
		}

		foreach ($toBeCombined as $media => $files)
		{
			if ($media === 'all')
				$media = '';

			if (count($files) === 1)
				$url = key($files);
			else
			{
				// get unique combined filename
				$fname = $this->getCombinedFileName($this->cssFileName, $files, $media);
				$fpath = Yii::app()->assetManager->getBasePath() . DIRECTORY_SEPARATOR . $fname;

				// check exists file
				if ($valid = file_exists($fpath))
				{
					$mtime = filemtime($fpath);
					foreach ($files as $file)
					{
						if ($mtime < filemtime($file))
						{
							$valid = false;
							break;
						}
					}
				}

				// re-generate the file
				if (!$valid)
				{
					$urlRegex = '#url\s*\(\s*([\'"])?(?!/|http://|data\:)([^\'"\s])#i';
					$fileBuffer = '';
					foreach ($files as $url => $file)
					{
						$contents = file_get_contents($file);
						if ($contents)
						{
							// Reset relative url() in css file
							if (preg_match($urlRegex, $contents))
							{
								$reurl = $this->getRelativeUrl(Yii::app()->assetManager->baseUrl, dirname($url));
								$contents = preg_replace($urlRegex, 'url(${1}' . $reurl . '/${2}', $contents);
							}
							
							if ($this->optimizeCssFiles && strpos($file, '.min.') === false && strpos($file, '.pack.') === false)
							{
								$contents = $this->optimizeCssCode($contents);
							}
							$fileBuffer .= (($this->optimizeCssFiles == true) ? preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $contents) : $contents);
						}
					}
					file_put_contents($fpath, $fileBuffer);
					//Yii::app()->cache->set('combineJs' . md5($fpath) . md5($fname), true);
				}
				// real url of combined file
				$url = Yii::app()->assetManager->getBaseRelUrl() . '/' . $fname;
			}
			$cssFiles[$url] = $media;
		}
		// use new cssFiles list replace old ones
		$this->cssFiles = $cssFiles;
	}
213114
def html_assets(cls, core=True, extras=True, backends=None, script=False):
        
        if backends is None:
            backends = [cls.backend] if cls.backend else []

        # Get all the widgets and find the set of required js widget files
        widgets = [wdgt for r in [Renderer]+Renderer.__subclasses__()
                   for wdgt in r.widgets.values()]
        css = list({wdgt.css for wdgt in widgets})
        basejs = list({wdgt.basejs for wdgt in widgets})
        extensionjs = list({wdgt.extensionjs for wdgt in widgets})

        # Join all the js widget code into one string
        path = os.path.dirname(os.path.abspath(__file__))

        def open_and_read(path, f):
            with open(find_file(path, f), 'r') as f:
                txt = f.read()
            return txt

        widgetjs = '\n'.join(open_and_read(path, f)
                             for f in basejs + extensionjs if f is not None)
        widgetcss = '\n'.join(open_and_read(path, f)
                              for f in css if f is not None)

        dependencies = {}
        if core:
            dependencies.update(cls.core_dependencies)
        if extras:
            dependencies.update(cls.extra_dependencies)
        for backend in backends:
            dependencies[backend] = Store.renderers[backend].backend_dependencies

        js_html, css_html = '', ''
        for _, dep in sorted(dependencies.items(), key=lambda x: x[0]):
            js_data = dep.get('js', [])
            if isinstance(js_data, tuple):
                for js in js_data:
                    if script:
                        js_html += js
                    else:
                        js_html += '\n<script type="text/javascript">%s</script>' % js
            elif not script:
                for js in js_data:
                    js_html += '\n<script src="%s" type="text/javascript"></script>' % js
            css_data = dep.get('css', [])
            if isinstance(js_data, tuple):
                for css in css_data:
                    css_html += '\n<style>%s</style>' % css
            else:
                for css in css_data:
                    css_html += '\n<link rel="stylesheet" href="%s">' % css
        if script:
            js_html += widgetjs
        else:
            js_html += '\n<script type="text/javascript">%s</script>' % widgetjs
        css_html += '\n<style>%s</style>' % widgetcss

        comm_js = cls.comm_manager.js_manager
        if script:
            js_html += comm_js
        else:
            js_html += '\n<script type="text/javascript">%s</script>' % comm_js

        return unicode(js_html), unicode(css_html)
224259
def process_scripts (out)
      out.gsub /(<script\b[^>]*?>([\s\S]*?)<\/script>)\s*/i do
        js = $2
        m = $1.gsub /^<script\s([^>]+)>/i do |m|
          attrs(m, 'script', true)
        end
        begin
          js_compressed = HtmlPress.js_compressor js, @options[:js_minifier_options]
          m.gsub!(">#{js}<\/script>", ">#{js_compressed}<\/script>")
        rescue MultiJs::ParseError => e
          log e.message
        end
        reserve m
      end
    end
1095033
function appendCSS(cssText, element) {
  console.log(element);
  const styleElement = document.createElement('style');
  styleElement.setAttribute('type', 'text/css');
  styleElement.innerHTML = cssText;
  const refNode = element.hasChildNodes() ? element.children[0] : null;
  element.insertBefore(styleElement, refNode);
}
162791
function inliner(css) {
  var css = fs.readFileSync(css).toString();
  var mqCss = siphon(css);

  var pipe = lazypipe()
    .pipe($.inlineCss, {
      applyStyleTags: false,
      removeStyleTags: true,
      preserveMediaQueries: true,
      removeLinkTags: false
    })
    .pipe($.replace, '<!-- <style> -->', `<style>${mqCss}</style>`)
    .pipe($.replace, '<link rel="stylesheet" type="text/css" href="css/app.css">', '')
    .pipe($.htmlmin, {
      collapseWhitespace: true,
      minifyCSS: true
    });

  return pipe();
}
175670
def list_concat(input, **params):
    
    PARAM_SOURCE_FIELDS = 'src.fields'
    PARAM_DEST_FIELD = 'dest.field'

    field_list = params.get(PARAM_SOURCE_FIELDS)
    for row in input:
        res = []
        for field in field_list:
            res += row[field]
        row[params.get(PARAM_DEST_FIELD)] = res
    return input
1001504
function toCssModule(styles) {
    var done = false;
    var res;

    new modules().load(styles, prefix + uni()).then(function(next) {
      done = true;
      res = next;
    });

    deasync.loopWhile(function() {
      return !done;
    });

    return res;
  }
698160
def css( self, filelist ):
        """"""
      
        if isinstance( filelist, basestring ):
            self.link( href=filelist, rel='stylesheet', type='text/css', media='all' )
        else:
            for file in filelist:
                self.link( href=file, rel='stylesheet', type='text/css', media='all' )
283712
function cssTemplate(params) {
    // Localize parameters
    var items = params.items,
    options = params.options;

    params.options.retina = params.options.image.indexOf('@2x') !== -1;
    if (params.options.retina) {
        params.options.bgWidth = Math.round(options.size.width / 2);
        params.options.bgHeight = Math.round(options.size.height / 2);
        params.options.className = params.options.className.replace('@2x', '');
        params.options.image2x = params.options.image;
        params.options.image = params.options.image.replace('@2x', '');
    }

    items.forEach(function (item) {
        if (item.x === -99999) {
            item.px.offset_x = 'right';
        }

        if (params.options.retina) {
            if (item.px.offset_x !== 'right') {
                item.px.offset_x = Math.round(parseFloat(item.px.offset_x) / 2) + 'px';
            }
            item.px.offset_y = Math.round(parseFloat(item.px.offset_y) / 2) + 'px';
            item.px.width = Math.round(parseFloat(item.px.width) / 2) + 'px';
            item.px.height = Math.round(parseFloat(item.px.height) / 2) + 'px';
        }
    });

    // Render and return CSS
    var css = mustache.render(tmpl, params);
    return css;
}
913522
def stylesheet(*urls)
      urls << {} unless urls.last.respond_to? :to_hash
      urls.last[:type] ||= mime_type(:css)
      link(:stylesheet, *urls)
    end
408265
function bundleCSS() {
    const glob      = require('glob');
    const srcmap    = require('./srcmap');
    const BUILT_PATH = path.join(__dirname, '..', config.dir.built);

    glob.sync('**/*.css', {
        cwd: BUILT_PATH
    }).forEach((file) => {
        const src = fs.readFileSync(path.join(BUILT_PATH, file)).toString()
            .replace(/^\ufeff/gm, '')
            .replace(/\r\n/gm, '\n')
        ;
        const node = srcmap.getNodeFromCode(src);
        node.prepend(banner('.css', path.basename(file, '.css')));
        const bundleSrc = '\ufeff' + srcmap.getCodeFromNode(node, (srcPath) => {
            const regex_src = new RegExp(`${config.dir.src}\\/${config.dir.stylesheet}\\/`);
            return srcPath
                .replace(/\.\.\//g, '')
                .replace(regex_src, SOURCE_MAP_NAMESPACE)
            ;
        }, { multiline: true });
        fs.writeFileSync(path.join(BUILT_PATH, file), bundleSrc);
        fs.writeFileSync(path.join(DST_PATH, file), bundleSrc);
    });
}
814969
function joinFlairs(data) {
  let result = []
  for (let [ targetStringArray, ...rest ] of data) {
    // Raw flair containing only one flair don’t need to be modified.
    if (targetStringArray.length < 2) {
      result.push([ targetStringArray, ...rest ])
      continue
    }
    // Concatenate the flairs using one, two and three spaces.
    for (let i = 1; i <= 3; i++) {
      const SPACES = pad('', i)
      result.push([ targetStringArray.join(SPACES), ...rest ])
    }
  }
  return result
}
519627
function parseCss (ctx, done) {
  var result
  try {
    result = postcss()
      .process(ctx.src, {
        map: {
          sourcesContent: true,
          annotation: false,
          prev: ctx.map
        },
        from: ctx.filename
      })
    ctx.src = result.css
    ctx.map = result.map.toJSON()
    done(null, ctx)
  } catch (e) {
    var msg = e.message
    var ext = extname(ctx.filename).slice(1).toLowerCase()
    if (ext !== 'css') {
      msg += ' (Try to use appropriate parser for ' + ext + ')'
    }
    done(new Error(msg))
  }
}
1193457
function Sakugawa(styles, options) {

  if (typeof styles !== 'string') {
    throw new Error('styles must be a string');
  }

  if (styles.length < 1) {
    throw new Error('styles must not be empty');
  }

  options = options || {};
  this.maxSelectors = options.maxSelectors || 4090;
  this.maxImports = options.maxImports || 4;
  this.mediaQueries = options.mediaQueries || 'normal';
  this.filename = options.filename || 'input.css';
  this.minSheets = options.minSheets || 1;

  this.ast = css.parse(styles);
}
237076
protected function _compress() {
        //$before = '(?<=[:(, ])';
        //$after = '(?=[ ,);}])';
        //$units = '(em|ex|%|px|cm|mm|in|pt|pc|ch|rem|vh|vw|vmin|vmax|vm)';

        foreach ($this->_data as $value) {
            $this->_concatContent .= $value;
        }

        if ($this->_type == 'css') {
            $this->_concatContent = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $this->_concatContent);
            $this->_concatContent = str_replace(': ', ':', $this->_concatContent);
            $this->_concatContent = str_replace(["\r\n", "\r", "\n", "\t", '  ', '    ', '    '], '', $this->_concatContent);
        }
    }
1045354
function processContentWithPostCSS(options, href) {
	/**
	 * @param  {String} content [css to process]
	 * @return {Object}         [object with css tokens and css itself]
	 */
	return function (content) {
		if (options.generateScopedName) {
			options.generateScopedName = typeof options.generateScopedName === 'function' ?
				/* istanbul ignore next */
				options.generateScopedName :
				genericNames(options.generateScopedName, {context: options.root});
		} else {
			options.generateScopedName = function (local, filename) {
				return Scope.generateScopedName(local, path.relative(options.root, filename));
			};
		}

		// Setup css-modules plugins 💼
		var runner = postcss([
			Values,
			LocalByDefault,
			ExtractImports,
			new Scope({generateScopedName: options.generateScopedName}),
			new Parser({fetch: fetch})
		].concat(options.plugins));

		function fetch(_to, _from) {
			// Seems ok 👏
			var filePath = normalizePath(_to, options.root, _from);

			return new Promise(function (resolve, reject) {
				return fs.readFile(filePath, 'utf8', function (err, content) {
					/* istanbul ignore next: just error handler */
					if (err) {
						return reject(err);
					}

					return runner.process(content, {from: filePath})
						.then(function (result) {
							return resolve(result.root.tokens);
						}).catch(reject);
				});
			});
		}

		return runner.process(content, {from: normalizePath(href, options.root, options.from)});
	};
}