Skip to content

fengyiyi/Typeset

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Demo

Typeset is an html pre-proces­sor for web ty­pog­ra­phy. It uses no client-side JavaScript but gives you hang­ing punc­tu­a­tion, soft hy­phen in­ser­tion, op­ti­cal mar­gin out­dents, small-caps con­ver­sion and punctuation substitution. See the results on the demo. The library is idempotent and runs on the server using Node – I'll adapt it to work on the client soon. The processed HTML & CSS renders correctly in IE5 and without any CSS!

npm install typeset
Usage
var typeset = require('typeset');
var html = '<p>"Hello," said the fox.</p>';
var output = typeset(html);

Then tweak typeset.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:

var options = {
  ignore: '.skip, #anything, .which-matches', // string of a CSS selector to skip
  only: '#only-typeset, .these-elements'    // string of a CSS selector to only apply typeset
};
CLI Usage
$ npm install -g typeset
Usage: typeset-js <entry file> [options]

Options:

  -h, --help      output usage information
  -V, --version   output the version number
  -o, --outfile   write Typeset output to this file (if unspecified, Typeset will print to stdout)
  -i, --ignore    string of CSS selector(s) to ignore
  -O, --only      string of CSS selector(s) to exclusively apply typeset to

Example:

$ typeset-js inputFile.html -o outputFile.html --ignore ".some-class, h3"
Building locally

Clone this repo then fetch its dependencies using npm install. You can then edit the code in /src.

To Do
  • Add a build file
  • Make this work on the client
  • Incorporate features from Normalize Opentype?
  • Remove recursion from eachTextNode.js
  • Consolidate functions which use eachTextNode.js
Who uses this library
  • Blot - a blogging platform I made, uses this to typeset blog posts
  • You? Contact me or submit a pull request to add it here!

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 61.5%
  • HTML 21.4%
  • CSS 17.1%