Maps the CSS from the style nodes to visual HTML attributes.

@return CssToAttributeConverter fluent interface
322167
public function convertCssToVisualAttributes()
    {
        /** @var \DOMElement $node */
        foreach ($this->getAllNodesWithStyleAttribute() as $node) {
            $inlineStyleDeclarations = $this->parseCssDeclarationsBlock($node->getAttribute('style'));
            $this->mapCssToHtmlAttributes($inlineStyleDeclarations, $node);
        }

        return $this;
    }
694184
def initialize_css_style_conversion
      @defined_style_conversions = {
        # styles shared or common logic across all node types go here.
        # Special conversion lambdas such as :_border can be
        # defined here for reuse across several AST nodes. Care must
        # be taken to avoid possible naming conflicts, hence the underscore.
        # AST class keys should be stored with their names converted from
        # camelcase to lowercased snakecase, i.e. TestCase = test_case
        node: {
          'background-color' => lambda { |v|
            return 'shd', { val: 'clear', fill: v.delete('#') }
          },
          _border: lambda { |v|
            props = { sz: 2, val: 'single', color: '000000' }
            vals = v.split
            vals[1] = 'single' if vals[1] == 'solid'
            #
            props[:sz] = @defined_style_conversions[:node][:_sz].call(vals[0])
            props[:val] = vals[1] if vals[1]
            props[:color] = vals[2].delete('#') if vals[2]
            #
            return props
          },
          _sz: lambda { |v|
            return nil unless v
            (2 * Float(v.gsub(/[^\d.]/, '')).ceil).to_s
          },
          'text-align' => ->(v) { return 'jc', v }
        },
        # Styles specific to the Table AST class
        table: {
          'border' => lambda { |v|
            props = @defined_style_conversions[:node][:_border].call(v)
            #
            return 'tblBorders', [
              { top: props }, { start: props }, { bottom: props },
              { end: props }, { insideH: props }, { insideV: props }
            ]
          },
          'margin' => lambda { |v|
            vals = v.split.map do |s|
              @defined_style_conversions[:node][:_sz].call(s)
            end
            #
            props = [vals[0], vals[0], vals[0], vals[0]] if vals.length == 1
            props = [vals[0], vals[1], vals[0], vals[1]] if vals.length == 2
            props = [vals[0], vals[1], vals[2], vals[1]] if vals.length == 3
            props = [vals[0], vals[1], vals[2], vals[3]] if vals.length > 3
            return 'tblCellMar', [
              { top: { w: props[0], type: 'dxa' } },
              { end: { w: props[1], type: 'dxa' } },
              { bottom: { w: props[2], type: 'dxa' } },
              { start: { w: props[3], type: 'dxa' } }
            ]
          },
          'cellspacing' => lambda { |v|
            v = @defined_style_conversions[:node][:_sz].call(v)
            return 'tblCellSpacing', { w: v, type: 'dxa' }
          },
          'width' => lambda { |v|
            v = @defined_style_conversions[:node][:_sz].call(v)
            return 'tblW', { w: v, type: 'dxa' }
          }
        },
        # Styles specific to the TableCell AST class
        table_cell: {
          'border' => lambda { |v|
            value = @defined_style_conversions[:table]['border'].call(v)[1]
            return 'tcBorders', value
          },
          'colspan' => ->(v) { return 'gridSpan', v },
          'margin' => lambda { |v|
            value = @defined_style_conversions[:table]['margin'].call(v)[1]
            return 'tcMar', value
          },
          'rowspan' => lambda { |v|
            return 'vMerge', 'restart' if v == 'start'
            return 'vMerge', v if v == 'continue'
            return 'vMerge', nil if v == 'end'
          },
          'vertical-align' => ->(v) { return 'vAlign', v },
          'white-space' => lambda { |v|
            return 'noWrap', nil if v == 'nowrap'
            return 'tcFitText', 'true' if v == 'fit'
          },
          'width' => lambda { |v|
            value = @defined_style_conversions[:table]['width'].call(v)[1]
            return 'tcW', value
          }
        },
        # Styles specific to the Paragraph AST class
        paragraph: {
          'border' => lambda { |v|
            props = @defined_style_conversions[:node][:_border].call(v)
            #
            return 'pBdr', [
              { top: props }, { bottom: props },
              { left: props }, { right: props }
            ]
          },
          'vertical-align' => ->(v) { return 'textAlignment', v }
        },
        # Styles specific to a run of text
        run: {
          'color' => ->(v) { return 'color', v.delete('#') },
          'font-size' => lambda { |v|
            return 'sz', @defined_style_conversions[:node][:_sz].call(v)
          },
          'font-style' => lambda { |v|
            return 'b', nil if v =~ /bold/
            return 'i', nil if v =~ /italic/
          },
          'font-weight' => ->(v) { return 'b', nil if v =~ /bold/ },
          'text-decoration' => lambda { |v|
            supported = %w[line-through underline]
            props = v.split
            return props[0], 'true' unless supported.include? props[0]
            return 'strike', 'true' if props[0] == 'line-through'
            return 'u', 'single' if props.length == 1
            return 'u', { val: props[1], color: 'auto' } if props.length == 2
            return 'u', { val: props[1], color: props[2].delete('#') }
          },
          'vertical-align' => lambda { |v|
            return 'vertAlign', 'subscript' if v =~ /sub/
            return 'vertAlign', 'superscript' if v =~ /super/
          }
        }
      }
    end
939291
protected function _getFromCSS()
    {
        // styles to apply
        $styles = array();

        // list of the selectors to get in the CSS files
        $getit  = array();

        // get the list of the selectors of each tags
        $lst = array();
        $lst[] = $this->value['id_lst'];
        for ($i=count($this->table)-1; $i>=0; $i--) {
            $lst[] = $this->table[$i]['id_lst'];
        }

        // foreach selectors in the CSS files, verify if it match with the list of selectors
        foreach ($this->cssKeys as $key => $num) {
            if ($this->_getReccursiveStyle($key, $lst)) {
                $getit[$key] = $num;
            }
        }

        // if we have selectors
        if (count($getit)) {
            // get them, but in the definition order, because of priority
            asort($getit);
            foreach ($getit as $key => $val) $styles = array_merge($styles, $this->css[$key]);
        }

        return $styles;
    }
1329021
protected function renderAttributes()
    {
        return ArrayMap::of($this->attributes)
            ->map(function ($value, $name) {
                return $this->renderAttribute($name, $value);
            })
            ->join(' ');
    }
1308354
public function htmlAttr()
    {
        $attributes = [
            'data-template' => $this->templateName(),
            'data-debug'    => $this->debug() ? 'true' : false,
            'lang'          => $this->lang(),
            'locale'        => $this->locale(),
            'class'         => $this->htmlClasses()
        ];

        return html_build_attributes($attributes);
    }
542946
function convertStyleToRules( style ) {
		var styleDef = style.getDefinition(),
			rules = {},
			rule,
			attrs = styleDef.attributes;

		rules[ styleDef.element ] = rule = {
			styles: styleDef.styles,
			requiredStyles: styleDef.styles && CKEDITOR.tools.objectKeys( styleDef.styles )
		};

		if ( attrs ) {
			attrs = copy( attrs );
			rule.classes = attrs[ 'class' ] ? attrs[ 'class' ].split( /\s+/ ) : null;
			rule.requiredClasses = rule.classes;
			delete attrs[ 'class' ];
			rule.attributes = attrs;
			rule.requiredAttributes = attrs && CKEDITOR.tools.objectKeys( attrs );
		}

		return rules;
	}
519884
public function getStyleAttributeArray(): array
    {
        $value = $this->getAttribute('style')['value'];

        if ($value === null) {
            return [];
        }

        $value = explode(';', substr(trim($value), 0, -1));
        $result = [];
        foreach ($value as $attr) {
            $attr = explode(':', $attr);
            $result[$attr[0]] = $attr[1];
        }

        return $result;
    }
1270155
public function generatePageIconsCss()
    {
        $css = '';
        $classes = ClassInfo::subclassesFor(SiteTree::class);
        foreach ($classes as $class) {
            $iconURL = SiteTree::singleton($class)->getPageIconURL();
            if ($iconURL) {
                $cssClass = Convert::raw2htmlid($class);
                $selector = sprintf('.page-icon.class-%1$s, li.class-%1$s > a .jstree-pageicon', $cssClass);
                $css .= sprintf('%s { background: transparent url(\'%s\') 0 0 no-repeat; }', $selector, $iconURL);
            }
        }
        return $css;
    }
644938
protected function renderAttribs()
    {
        $strHtml = '';
        foreach ($this->aAttribs as $strKey => $mValue) {
            $strHtml .= is_bool($mValue)
                ? ($mValue ? $strKey : '') // just the attribute name for booleans
                : $strKey . '="' . $mValue . '"'; // otherwise key="value"
        }
        return $strHtml;
    }
142587
protected function renderAttributes()
    {
        $output = '';

        foreach($this->_attr as $key => $value) {
            $output .= $key.' = "'.$value.'" ';
        }

        return $output;
    }
749050
public function htmlAttributes()
    {
        if ($this->direction() === 'rtl' || $this->direction() !== $this->script()->direction()) {
            return 'lang="' . $this->languageTag() . '" dir="' . $this->direction() . '"';
        } else {
            return 'lang="' . $this->languageTag() . '"';
        }
    }
1140491
public function getCssCode()
    {
        $html = '';
        foreach ($this->css as $css) {
            $html .= sprintf('<link rel="stylesheet" href="%s"/>', $css);
        }
        return $html;
    }
774148
public function css($attributes = null)
	{
		if( ! $this->css)
			return '';

		$assets = ($this->pipeline) ? array($this->cssPipeline()) : $this->css;

		if($attributes instanceof Closure)
			return $attributes->__invoke($assets);

		// Build attributes
		$attributes = (array) $attributes;
		unset($attributes['href']);

		if( ! array_key_exists('type', $attributes))
			$attributes['type'] = 'text/css';

		if( ! array_key_exists('rel', $attributes))
			$attributes['rel'] = 'stylesheet';

		$attributes = $this->buildTagAttributes($attributes);

		// Build tags
		$output = '';
		foreach($assets as $asset)
			$output .= '<link href="' . $asset . '"' . $attributes . " />\n";

		return $output;
	}
261918
function(styles) {

	var computedStyles = document.defaultView.getComputedStyle(this._node),
		i,
		eachStyle,
		cssMap = {}

	// String case, just return the correct style
	if (typeof styles == "string") {
		return computedStyles[styles]
	}

	for (i=0; eachStyle = styles[i]; i++) {
		cssMap[eachStyle] = computedStyles[eachStyle]
	}
	return cssMap
}
439317
private function getCSS()
    {
        $this->domCrawler->filter('style')->each(function ($crawler){$this->css .= $crawler->text();foreach ($crawler as $node){$node->parentNode->removeChild($node);}});
        $parser = new CSS\Parser($this->css);
        $css = $parser->parse();
        if(!$css){
            throw new \Exception('There are no CSS rules provided.');
        }
        return $css;
    }
35405
public function htmlattributes() {
        $return = get_html_lang(true);
        $attributes = array();
        if ($this->page->theme->doctype !== 'html5') {
            $attributes['xmlns'] = 'http://www.w3.org/1999/xhtml';
        }

        // Give plugins an opportunity to add things like xml namespaces to the html element.
        // This function should return an array of html attribute names => values.
        $pluginswithfunction = get_plugins_with_function('add_htmlattributes', 'lib.php');
        foreach ($pluginswithfunction as $plugins) {
            foreach ($plugins as $function) {
                $newattrs = $function();
                unset($newattrs['dir']);
                unset($newattrs['lang']);
                unset($newattrs['xmlns']);
                unset($newattrs['xml:lang']);
                $attributes += $newattrs;
            }
        }

        foreach ($attributes as $key => $val) {
            $val = s($val);
            $return .= " $key=\"$val\"";
        }

        return $return;
    }
344501
protected function getWrappedTemplate()
	{
		$this->attributes['style']['width']    = '100%';
		$this->attributes['style']['height']   = '100%';
		$this->attributes['style']['position'] = 'absolute';
		$this->attributes['style']['left']     = '0';

		$outerStyle = 'display:inline-block;width:100%;max-width:' . $this->attributes['width'] . 'px';
		$innerStyle = 'display:block;overflow:hidden;position:relative;' . $this->getResponsivePadding();

		$template  = '<span>' . $this->generateAttributes(['style' => $outerStyle]);
		$template .= '<span>' . $this->generateAttributes(['style' => $innerStyle]);
		$template .= $this->getContentTemplate();
		$template .= '</span></span>';

		return $template;
	}