An HTML pre-processor for web typography
Typeset is an HTML pre-processor for web typography which provides typographic features used traditionally in fine printing which remain unavailable to browser layout engines. Typeset's processing brings the following to your webpages:
Typeset does not require any client-side JavaScript and uses less than a kilobyte of CSS. Processed HTML & CSS works in Internet Explorer 5 and without any CSS. Typeset can be used manually or as a plugin for Grunt and gulp.
$ npm i typesetconst typeset = require('typeset');
let html = '<p>"Hello," said the fox.</p>';
let output = typeset(html);Then tweak the CSS to match the metrics of your font and include it on your page.
…You can pass an options object to influence how your HTML is typeset:
const options = {
ignore: '.skip, #anything, .which-matches', // string of CSS selector(s) to ignore
only: '#only-typeset, .these-elements', // string of CSS selector(s) to exclusively apply typeset to
disable: ['hyphenate'] // array of typeset feature(s) to disable
};The following features may be disabled:
hyphenatehangingPunctuationligaturespunctuationquotessmallCapsspaces$ npm i -g typesetUsage: typeset-js [options] [<infile> [<outfile>]]
Options:
-h, --help output usage information
-V, --version output the version number
-i, --ignore string of CSS selector(s) to ignore
-O, --only string of CSS selector(s) to exclusively apply typeset to
--disable, string of typeset feature(s) to disable, separated by commasCompile a file and print it to stdout:
$ typeset-js inputFile.htmlTo create an output file, just add a second argument:
$ typeset-js inputFile.html outputFile.htmlUse the --ignore option to ignore specific CSS selectors:
$ typeset-js inputFile.html outputFile.html --ignore ".some-class, h3"Use the --disable option to disable typeset features:
$ typeset-js inputFile.html outputFile.html --disable "hyphenate,ligatures"CLI redirections:
$ cat index.html | typeset-js > outputFile.htmlIf you don't find the answer to your problem in our docs, or have a suggestion for improvements, submit your question here.
This software is dedicated to the public domain and licensed under Creative Commons Zero. See the LICENSE file for details.
No open issues yet, or sync has not completed.