FormidableLabs/gulp-html-extract

Name: gulp-html-extract

Owner: Formidable

Description: Extract HTML text in your gulp pipeline.

Created: 2014-04-28 14:20:14.0

Updated: 2017-04-19 18:46:10.0

Pushed: 2017-04-13 20:22:04.0

Homepage: null

Size: 26

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

gulp-html-extract Build Status

Extract text from HTML content into pseudo-files for further Gulp processing.

Install

Install with npm

install --save-dev gulp-html-extract
Example

A good use case is extracting JavaScript from <script> tags and then piping to gulp-jshint. Here, we extract JavaScript from <script> tags and anything matching the code.javascript CSS selector:

gulp = require("gulp"),
hint = require("gulp-jshint"),
tract = require("gulp-html-extract");

.task("jshint:html", function () {
lp
.src("site/**/*.html")
.pipe(extract({
  sel: "script, code.javascript"
}))
.pipe(jshint())
.pipe(jshint.reporter("default"))
.pipe(jshint.reporter("fail"));

Pseudo-Files

The plugin extracts each text snippet from an HTML source as an independent faux Vinyl file, with a path of: HTML_PATH-ELEMENT_ID or HTML_PATH-TAG_NAME-INDEX (if no id attribute).

Some examples:

/to/file1.html-CODE-1
/to/file2.html-my-identifier
API
extract(opts)
opts.sel

CSS selector string to match on. Default: script.

opts.strip

Strip to indented level of first non-whitespace character. Removes whitespace- only starting and ending lines around real text. Default: false

opts.pad

Pad text with newlines to start line in source file. Useful if line numbering of original source file is important (for eslint, stack traces, etc.). Default: false


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.