All Projects → yoshuawuyts → extract-html-class

yoshuawuyts / extract-html-class

Licence: MIT license
Extract all classes from html

Programming Languages

javascript
184084 projects - #8 most used programming language

extract-html-class stability

npm version build status downloads js-standard-style

Extract all classes from html

Usage

var extract = require('extract-html-class')
var assert = require('assert')

var html = `
  <div class="foo bar">
    <p class="bin baz">hello planet</p>
  </div>
`
var expected = [ 'foo', 'bar', 'bin', 'baz' ]
assert.deepEqual(extract(html), expected, 'array was same')

API

classes = extract(html)

Get an array of classes for the given string. Uses a regex so safe to run on non-html strings too. Returns an empty array if no matches are found.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].