Socket
Book a DemoInstallSign in
Socket

gulp-html-extract

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-html-extract

Extract HTML text in your gulp pipeline.

0.3.0
latest
Source
npmnpm
Version published
Weekly downloads
574
14.57%
Maintainers
1
Weekly downloads
 
Created
Source

gulp-html-extract Build Status

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

Install

Install with npm

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:

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

gulp.task("jshint:html", function () {
  gulp
    .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:

path/to/file1.html-CODE-1
path/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

Keywords

gulp

FAQs

Package last updated on 13 Apr 2017

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.