2017 © Pedro Peláez
 

library e-css-tractor

Extracts CSS from HTML (Style-Tags)

image

spazzmarticus/e-css-tractor

Extracts CSS from HTML (Style-Tags)

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 3 % Grown

The README.md

eCSStractor Build Status

Extracts CSS from HTML <style>-Tags, (*1)

(Also the lamest wordplay I could possibly come up with...), (*2)

How

Installation

Install via composer, (*3)

composer require spazzmarticus/e-css-tractor, (*4)

Usage

//Your HTML-Document with one or more <style>-Tags
$html = '<html><head><style>p { color: blue; }</style></head>...<style>h1 { background-color: green; }</style></html>'; 
$eCSStractor = new eCSStractor();
$css = $eCCStractor->extract($html);

header("Content-type: text/css");
echo $css;
p { color: blue; }
h1 { background-color: green; }

Example

Check out the example/ directory. The styles from input.html are extracted in css.php and used in usage.html., (*5)

What not

This doesn't optimize the styles. GIGO ;), (*6)

Why

I built a tool to send newsletters with. The editor for the newsletter-content had to be able to work with multiple templates (each containing unique styles). By extracting the styles from the templates I was able to dynamically change the template for a preview (outside the editor) and the styles in the editor accordingly., (*7)

Before sending the newsletter the styles are written inline by emogrifier so there was no need to change anyting., (*8)

The Versions

18/09 2015

dev-develop

dev-develop

Extracts CSS from HTML (Style-Tags)

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

css extract stylesheet

18/09 2015

dev-master

9999999-dev

Extracts CSS from HTML (Style-Tags)

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

css extract stylesheet

18/09 2015

0.2.0

0.2.0.0

Extracts CSS from HTML (Style-Tags)

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

css extract stylesheet

15/09 2015

0.1.0

0.1.0.0

Extracts CSS from HTML (Style-Tags)

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

css extract stylesheet