Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
T

Typeset

> 编程语言
Open source

An HTML pre-proces­sor for web ty­pog­ra­phy

2.7K stars0 likes1 views
WebsiteGitHub

About

An HTML pre-proces­sor for web ty­pog­ra­phy

Typeset

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:

  • Hanging punctuation
  • Ligatures
  • Optical margin alignment
  • Punctuation substitution
  • Small caps
  • Soft hyphen insertion

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.


Getting Started

Install

bash
$ npm i typeset

Usage

javascript
const typeset = require('typeset');
let html = '<p>"Hello," said the fox.</p>';
let output = typeset(html);

CSS

Then tweak the CSS to match the metrics of your font and include it on your page.

…

Options

You can pass an options object to influence how your HTML is typeset:

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

Features

The following features may be disabled:

  • hyphenate
  • hangingPunctuation
  • ligatures
  • punctuation
  • quotes
  • smallCaps
  • spaces

CLI Usage

bash
$ npm i -g typeset
bash
Usage: 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 commas

Examples:

Compile a file and print it to stdout:

bash
$ typeset-js inputFile.html

To create an output file, just add a second argument:

bash
$ typeset-js inputFile.html outputFile.html

Use the --ignore option to ignore specific CSS selectors:

bash
$ typeset-js inputFile.html outputFile.html --ignore ".some-class, h3"

Use the --disable option to disable typeset features:

bash
$ typeset-js inputFile.html outputFile.html --disable "hyphenate,ligatures"

CLI redirections:

bash
$ cat index.html | typeset-js > outputFile.html

Plugins

  • Grunt
  • gulp.

Support

If you don't find the answer to your problem in our docs, or have a suggestion for improvements, submit your question here.


License

This software is dedicated to the public domain and licensed under Creative Commons Zero. See the LICENSE file for details.


To Do:

  • Language options & support
  • Widows & orphans.
  • Incorporate features from Normalize Opentype

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

JavaScript

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言