
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
gulp-htmlbook
Advanced tools
Contains gulp plugins to convert from HTMLBook to HTML.
Layout content in a templates, and replace variables in the content
Adds prev_url
, next_url
, prev_label
, next_label
variables to each file
Create the navigation html by passing the nav json through a template
Create the index html by passing the index json through a template
Split the content from a single HTMLBook file into chunks, at the chapter or section level
Run through a stream of documents and generate reference objects for each file and every id, returns json
Find all index terms in a stream of documents and sort them, returns json
Find all the headers in a stream of documents and create the nav for the Table of Contents, returns json.
processes parts of the content, most require content to have been mapped
Adds ids for all chapter
, section
, a[data-type='indexterm']
, div[data-type]
, aside
, figure
elements that don't have one.
Removes spaces from indexterm elements
Replaces headers with nice labels, such as Section 1.2
Adds translated header text to admonition elements (en
only for now)
Removes comments
Replaces cross-refrenced link with the correct url and text
Replaces cdata in pre elements, escapes their content
Collection of helper functions
Map a document
Generates Id's based on hashed content, these will always be the same if the content is the same.
npm install gulp-htmlbook
var htmlbook = require("gulp-htmlbook");
###Usage
See the example gulpfile.js for how to process a sample HTMLBook source.
A compile task should process the source content and output it for mapping and templating. If the content is in markdown, asciidoc or docbook it must be transformed prior to this step.
var outputPath = "compiled/";
gulp.task('compile', [], function() {
return gulp.src("*.html")
.pipe(htmlbook.process.ids())
.pipe(htmlbook.process.indexterms())
.pipe(htmlbook.process.admonitions())
.pipe(htmlbook.process.comments())
.pipe(gulp.dest(outputPath));
});
Next map the compiled content. This map is used with many other plugins.
var order = require('gulp-order');
gulp.task('map', ['compile'], function() {
return gulp.src(outputPath+"*.html")
.pipe(order(['chap_1.html','chap_2.html'])) // Must be ordered
.pipe(htmlbook.generate.map())
.pipe(gulp.dest(outputPath));
});
Finaly, wrap each chunk in an html template.
gulp.task('template', ['compile', 'map'], function() {
var map = require("./map.json"); // Load the map
return gulp.src(outputPath+"*.html")
.pipe(htmlbook.layout.ordering(['chap_1.html','chap_2.html'], map))
.pipe(htmlbook.layout.template())
.pipe(gulp.dest(outputPath));
});
FAQs
Render HTMLBook
We found that gulp-htmlbook demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.