Inject a style tag pointed at the minified CSS. Attempt to insert the shim before the closing head tag.
434808
function inject_stylesheet_shim () {
      if (options.include_css) {
        var style_tag = '<link rel="stylesheet" type="text/css" href="' + options.include_css + '">';
        if (options.css_insert_marker && html.indexOf(options.css_insert_marker) !== -1) {
          html = html.replace(options.css_insert_marker, style_tag);
        }
        else {
          var shims = ["</head>", "<body>", "</html>"];
          inject(style_tag, shims);
        }
      }
    }
1263133
function cssFilesToStyleTag(dom) {
    const rootDir = `${__dirname}/`;

    const styles = m('div', {}, cssFiles.map(file => m('link', { rel: 'stylesheet', href: rootDir + file })));

    m.render(dom, styles);
  }
1061345
def start_inline(self,stylestack=None):
        
        self.stack.append('inline')
        if self.dirty:
            self.escpos._raw(' ')
        if stylestack:
            self.style(stylestack)
32028
function startTagInHeadNoScript(p, token) {
    const tn = token.tagName;

    if (tn === $.HTML) {
        startTagInBody(p, token);
    } else if (
        tn === $.BASEFONT ||
        tn === $.BGSOUND ||
        tn === $.HEAD ||
        tn === $.LINK ||
        tn === $.META ||
        tn === $.NOFRAMES ||
        tn === $.STYLE
    ) {
        startTagInHead(p, token);
    } else if (tn === $.NOSCRIPT) {
        p._err(ERR.nestedNoscriptInHead);
    } else {
        tokenInHeadNoScript(p, token);
    }
}
246770
function updateHTMLTag(editor, node, width, height) {
	const srcAttr = getAttribute(node, 'src');
	const widthAttr = getAttribute(node, 'width');
	const heightAttr = getAttribute(node, 'height');

	editor.transact(() => {
		// apply changes from right to left, first for height, then for width
		let point;
		const quote = getAttributeQuote(editor, widthAttr || heightAttr || srcAttr);

		if (!heightAttr) {
			// no `height` attribute, add it right after `width` or `src`
			point = widthAttr ? widthAttr.end : srcAttr.end;
			editor.setTextInBufferRange([point, point], ` height=${quote}${height}${quote}`);
		} else {
			editor.setTextInBufferRange(getRange(heightAttr.value), String(height));
		}

		if (!widthAttr) {
			// no `width` attribute, add it right before `height` or after `src`
			point = heightAttr ? heightAttr.start : srcAttr.end;
			editor.setTextInBufferRange([point, point], `${!heightAttr ? ' ' : ''}width=${quote}${width}${quote}${heightAttr ? ' ' : ''}`);
		} else {
			editor.setTextInBufferRange(getRange(widthAttr.value), String(width));
		}
	});
}
956060
function setStylesheet(s) {
	var id = "AMMLcustomStyleSheet";
	var n = document.getElementById(id);
	if(document.createStyleSheet) {
		// Test for IE's non-standard createStyleSheet method
		if(n)
			n.parentNode.removeChild(n);
		// This failed without the &nbsp;
		document.getElementsByTagName("head")[0].insertAdjacentHTML("beforeEnd","&nbsp;<style id='" + id + "'>" + s + "</style>");
	} else {
		if(n) {
			n.replaceChild(document.createTextNode(s),n.firstChild);
		} else {
			n = document.createElement("style");
			n.type = "text/css";
			n.id = id;
			n.appendChild(document.createTextNode(s));
			document.getElementsByTagName("head")[0].appendChild(n);
		}
	}
}
1020323
protected function injectCSS() {
            if (!$this->isCLI && !self::$cssInjected) {
                self::$cssInjected = true;
                if (file_exists($this->config->cssPath)) {
                    echo '<style type="text/css">';
                    /** @noinspection PhpIncludeInspection */
                    include $this->config->cssPath;
                    echo '</style>';
                } else {
                    echo 'The AloFramework handlers\' CSS file could not be found: ' . $this->config->cssPath . PHP_EOL;
                }
            }
        }
694306
def insert_by_tag_and_context!(inserter, snippet, context, tag)
      raise "must be passed snippet" unless snippet.is_a?(Snippet)

      src = insert_func(snippet, context, tag)

      options[:margin_top].times { inserter.insert "" }
      # @snip -> @snippet
      inserter.insert tag.to_snippet_tag unless snippet.no_tag?
      # insert snippet text
      inserter.insert src
      options[:margin_bottom].times { inserter.insert "" }

      visit tag
    end
63270
CssFormatter append( String str ) {
        if( inlineMode ) {
            str = UrlUtils.removeQuote( str );
        }
        output.append( str );
        return this;
    }
94449
def add_cssfile(self, src: str) -> None:
        """"""
        self.head.appendChild(Link(rel='stylesheet', href=src))
1144599
def apply_styles(self, html, styles):
        
        index = html.find('</head>')
        if index >= 0:
            return ''.join((html[:index], styles, html[index:]))
        return html
1025597
public XHTMLText appendOpenBlockQuoteTag(String style) {
        text.halfOpenElement(BLOCKQUOTE);
        text.optAttribute(STYLE, style);
        text.rightAngleBracket();
        return this;
    }
1110950
function minifyHtml($) {
  $('style:not([type]), style[type="text/css"]').each(function() {
    var el      = $(this);
    el.text( new cleancss({noAdvanced: true}).minify(el.text()) )
  });
  $('*').contents().filter(function(_, node) {
    if (node.type === 'comment'){
      return true;
    } else if (node.type === 'text') {
      // return true if the node is only whitespace
      return !((/\S/).test(node.data));
    }
  }).remove();
}
760198
def css(self, path):
        
        if self.settings.embed_content:
            content = codecs.open(path, 'r', encoding='utf8').read()
            tag = Style(content, type="text/css")
        else:
            tag = Link(href=path, rel="stylesheet", type_="text/css")
        self.head.append(tag)
1274322
def closest(self, tag):
        """"""

        return CSSMatch(self.selectors, tag, self.namespaces, self.flags).closest()
1053186
function appendStyle(style, doc) {
    if (!_.isString(style) || !doc) {
        console.log('invalid document or style string...', style, doc);
        return;
    }
    let docEl = (doc.getElementsByTagName('document')).item(0);
    let styleString = ['<style>', style, '</style>'].join('');
    let headTag = doc.getElementsByTagName('head');

    headTag = headTag && headTag.item(0);
    if (!headTag) {
        headTag = doc.createElement('head');
        docEl.insertBefore(headTag, docEl.firstChild);
    }
    headTag.innerHTML = styleString;
}
302274
function injectElementWithStyles( rule, callback, nodes, testnames ) {
    var mod = 'modernizr';
    var style;
    var ret;
    var node;
    var docOverflow;
    var div = createElement('div');
    var body = getBody();

    if ( parseInt(nodes, 10) ) {
      // In order not to give false positives we create a node for each test
      // This also allows the method to scale for unspecified uses
      while ( nodes-- ) {
        node = createElement('div');
        node.id = testnames ? testnames[nodes] : mod + (nodes + 1);
        div.appendChild(node);
      }
    }

    // <style> elements in IE6-9 are considered 'NoScope' elements and therefore will be removed
    // when injected with innerHTML. To get around this you need to prepend the 'NoScope' element
    // with a 'scoped' element, in our case the soft-hyphen entity as it won't mess with our measurements.
    // msdn.microsoft.com/en-us/library/ms533897%28VS.85%29.aspx
    // Documents served as xml will throw if using &shy; so use xml friendly encoded version. See issue #277
    style = ['&#173;','<style id="s', mod, '">', rule, '</style>'].join('');
    div.id = mod;
    // IE6 will false positive on some tests due to the style element inside the test div somehow interfering offsetHeight, so insert it into body or fakebody.
    // Opera will act all quirky when injecting elements in documentElement when page is served as xml, needs fakebody too. #270
    (!body.fake ? div : body).innerHTML += style;
    body.appendChild(div);
    if ( body.fake ) {
      //avoid crashing IE8, if background image is used
      body.style.background = '';
      //Safari 5.13/5.1.4 OSX stops loading if ::-webkit-scrollbar is used and scrollbars are visible
      body.style.overflow = 'hidden';
      docOverflow = docElement.style.overflow;
      docElement.style.overflow = 'hidden';
      docElement.appendChild(body);
    }

    ret = callback(div, rule);
    // If this is done after page load we don't want to remove the body so check if body exists
    if ( body.fake ) {
      body.parentNode.removeChild(body);
      docElement.style.overflow = docOverflow;
      // Trigger layout so kinetic scrolling isn't disabled in iOS6+
      docElement.offsetHeight;
    } else {
      div.parentNode.removeChild(div);
    }

    return !!ret;

  }