Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

css_dead_class

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css_dead_class

  • 1.0.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

CSSDeadClass

Remove undefined CSS class attributes from your HTML.

Purpose

This Gem will, given a set of HTML files and a set of CSS files, remove any mentions in the class attributes of HTML objects classes that are not defined in the CSS files.

Sample Usage

Given the following files

index.html

<html>
<body>
	<h1 class="happy sad">Heading</h1>
	<p class="red blue">Hello</p>
</body>
</html>

app.css

.red {
	color: red;
}

.happy {
	color: black;
}

Running CSSDeadClass on those two files will change index.html to the following, remove calls to .sad and .blue, as they do not exist:

<html>
<body>
	<h1 class="happy">Heading</h1>
	<p class="red">Hello</p>
</body>
</html>

Installation

Install using gem css_dead_class.

Configuration

CSSDeadClass takes three options:

:css_files

An array of file paths to CSS files to scan.

:html_files

An array of file paths to HTML files to scan.

:classes_to_keep

An array of CSS classes to keep, regardless of presence in the HTML files. Can either be of the form .classname or classname.

Usage

Sample usage in a ruby program:

require 'css_dead_classes'

css_deadfiles = CSSDeadClass.new({
	html_files: Dir.glob("**/*.html"),
	css_files: Dir.glob("**/*.css"),
	classes_to_keep: [
		".no-js",
		"blue"
	]
})
css_deadfiles.parse

FAQs

Package last updated on 03 Jul 2016

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc