An HTML pre-processor for web typography¶ ↑
a pure Ruby typographic pre-processor for HTML inspired by Typeset.js that gives you:
* Real hanging punctuation * Soft hyphen insertion * Optical margin outdents * Small-caps conversion * Punctuation substitution * Space substitution
Installation¶ ↑
gem install rtypeset
Usage¶ ↑
Just require the typeset
gem and then call #typeset
to receive beautifully-formatted HTML:
require 'typeset' raw_html = <<HTM <p>Yjarni Sigurðardóttir spoke to NATO from Iceland yesterday: "Light of my life, fire of my florins -- my sin, my soul. The tip of the tongue taking a trip to 118° 19' 43.5".":</p> HTM # Output beautifully-formatted HTML puts Typeset.typeset(raw_html)
Customisation¶ ↑
Want more control over your typesetting?
Disabling Features¶ ↑
You can selectively disable Typeset
features by passing in an options hash to #typeset
:
# Disable hyphenation and small caps conversion. options = {:disable => [:hyphenate, :small-caps]} Typeset.typeset(raw_html, options)
The full list of modules is: :quotes
, :hanging_punctuation
, :spaces
, :small_caps
, :hyphenate
, :ligatures
and :punctuation
.
Hyphenation Language¶ ↑
If you’re using hyphenation (it’s on by default!) you may want to specify the language (the default is en_us
):
Typeset.typeset(raw_html, {:language => "en_us"})