npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gulp-htmlbook

v0.0.41

Published

Render HTMLBook

Downloads

38

Readme

gulp HTMLBook

Contains gulp plugins to convert from HTMLBook to HTML.

layout

layout.template()

Layout content in a templates, and replace variables in the content

layout.ordering()

Adds prev_url, next_url, prev_label, next_label variables to each file

layout.navigation()

Create the navigation html by passing the nav json through a template

layout.index()

Create the index html by passing the index json through a template

layout.chunk()

Split the content from a single HTMLBook file into chunks, at the chapter or section level

generate

generate.map()

Run through a stream of documents and generate reference objects for each file and every id, returns json

generate.index()

Find all index terms in a stream of documents and sort them, returns json

generate.nav()

Find all the headers in a stream of documents and create the nav for the Table of Contents, returns json.

process

processes parts of the content, most require content to have been mapped

process.ids()

Adds ids for all chapter, section, a[data-type='indexterm'], div[data-type], aside, figure elements that don't have one.

process.indexterms()

Removes spaces from indexterm elements

process.labels()

Replaces headers with nice labels, such as Section 1.2

process.admonitions()

Adds translated header text to admonition elements (en only for now)

process.comments()

Removes comments

process.xrefs()

Replaces cross-refrenced link with the correct url and text

process.escape()

Replaces cdata in pre elements, escapes their content

tools

tools.helpers()

Collection of helper functions

tools.mapper()

Map a document

tools.generateid()

Generates Id's based on hashed content, these will always be the same if the content is the same.

Installation

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));
});