This package has been deprecated

Author message:

jade is now pug, please use pug-walk-extract-text

jade-walk-extract-text

0.1.1 • Public • Published

jade-walk-extract-text npm version npm downloads Build Status Dependency Status Unlicense

A small module for extracting text (e.g. inline script and style tags) from Jade files!

Used by eslint-plugin-jade.

Installation

Install with npm, obviously:

npm install --save-dev jade-parser jade-lexer jade-walk-extract-text

Usage

var lexer = require('jade-lexer')
var parser = require('jade-parser')
var walkExtract = require('jade-walk-extract-text')
 
function shouldExtract (node) {
    return node.type === 'Tag' && (node.name === 'script' || node.name === 'style')
}
 
var filename = 'some-file.jade'
var text = fs.readFileSync(filename, { encoding: 'utf-8' })
var results = walkExtract(parser(lexer(text, filename), filename), text, shouldExtract)
// [
//   { text: "body { background: #efefef; color: #444; }\n  html { font-size: 105%; }",
//     indent: 6, line: 9,
//     node: { attrs: [], ..., name: 'style', type: 'Tag' } },
//   { text: "console.log({\n  scri: 'pt'\n})",
//     indent: 6, line: 15,
//     node: { attrs: [], ..., name: 'script', type: 'Tag' } },
// ]

Contributing

Please feel free to submit pull requests! Bugfixes and simple non-breaking improvements will be accepted without any questions :-)

By participating in this project you agree to follow the Contributor Code of Conduct.

License

This is free and unencumbered software released into the public domain.
For more information, please refer to the UNLICENSE file or unlicense.org.

Readme

Keywords

Package Sidebar

Install

npm i jade-walk-extract-text

Weekly Downloads

8

Version

0.1.1

License

Unlicense

Last publish

Collaborators

  • valpackett