🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

postcss-html

Package Overview
Dependencies
Maintainers
4
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-html

PostCSS syntax for parsing HTML (and HTML-like)

1.8.0
latest
Source
npm
Version published
Weekly downloads
1.4M
-11.11%
Maintainers
4
Weekly downloads
 
Created

What is postcss-html?

The postcss-html npm package is a tool that allows PostCSS to be used with HTML, including HTML-like syntaxes such as XML, XHTML, and HTML with inline styles. It enables developers to process styles within `<style>` tags or inline `style` attributes using PostCSS plugins.

What are postcss-html's main functionalities?

Processing inline styles

This feature allows processing of inline styles within HTML. The code sample demonstrates how to use postcss-html to process a string containing HTML with a `<style>` tag.

const postcssHtml = require('postcss-html');
const result = postcssHtml.process('<style>h1 { color: red; }</style>', { /* options */ }).then(result => {
  console.log(result.html);
});

Processing styles in HTML-like files

This feature processes styles within HTML-like files. The code sample shows how to read an HTML file, process it with postcss-html, and then write the processed HTML to a new file.

const postcssHtml = require('postcss-html');
const fs = require('fs');

fs.readFile('index.html', (err, html) => {
  if (err) throw err;
  postcssHtml.process(html, { /* options */ }).then(result => {
    fs.writeFile('index-processed.html', result.html, (err) => {
      if (err) throw err;
      console.log('The file has been saved!');
    });
  });
});

Other packages similar to postcss-html

Keywords

postcss

FAQs

Package last updated on 14 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts