Socket
Socket
Sign inDemoInstall

postcss-normalize-charset

Package Overview
Dependencies
11
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    postcss-normalize-charset

Add necessary or remove extra charset with PostCSS


Version published
Weekly downloads
8.7M
decreased by-15.87%
Maintainers
1
Install size
1.55 MB
Created
Weekly downloads
 

Package description

What is postcss-normalize-charset?

The postcss-normalize-charset npm package is a PostCSS plugin that ensures that a single @charset rule is present at the top of your CSS files. It can remove unnecessary @charset rules and can add one if not present when a non-ASCII character is found in the file. This helps in maintaining the proper character encoding in your CSS, which is important for the correct rendering of text in web pages.

What are postcss-normalize-charset's main functionalities?

Adding @charset rule

This feature automatically adds an @charset rule to the CSS if the file contains non-ASCII characters and no @charset rule is present.

const postcss = require('postcss');
const normalizeCharset = require('postcss-normalize-charset');

postcss([normalizeCharset()])
  .process('a { content: "\2014" }', { from: undefined })
  .then(result => {
    console.log(result.css);
    // Output: '@charset "utf-8";\na { content: "\2014" }'
  });

Removing unnecessary @charset rules

This feature removes duplicate or unnecessary @charset rules, ensuring that only one is present at the top of the CSS file.

const postcss = require('postcss');
const normalizeCharset = require('postcss-normalize-charset');

postcss([normalizeCharset()])
  .process('@charset "utf-8";\n@charset "utf-8";\na { color: black; }', { from: undefined })
  .then(result => {
    console.log(result.css);
    // Output: '@charset "utf-8";\na { color: black; }'
  });

Other packages similar to postcss-normalize-charset

Readme

Source

postcss-normalize-charset Build Status

Add necessary or remove extra charset with PostCSS

a{
  content: "©";
}
@charset "utf-8";
a{
  content: "©";
}

Usage

postcss([ require('postcss-normalize-charset') ])

See PostCSS docs for examples for your environment.

MIT © Bogdan Chadkin

Keywords

FAQs

Last updated on 14 Sep 2015

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc