https://github.com/doches/rtypeset
An HTML Preprocessor for Web Typography, based on Typeset.js
https://github.com/doches/rtypeset
Last synced: 11 months ago
JSON representation
An HTML Preprocessor for Web Typography, based on Typeset.js
- Host: GitHub
- URL: https://github.com/doches/rtypeset
- Owner: doches
- License: mit
- Created: 2015-08-18T06:41:20.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-11-18T02:57:57.000Z (over 10 years ago)
- Last Synced: 2024-04-14T11:56:47.050Z (over 2 years ago)
- Language: Ruby
- Size: 23.4 KB
- Stars: 16
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# An HTML pre-processor for web typography
[](http://badge.fury.io/rb/rtypeset)
[](https://travis-ci.org/doches/rtypeset)
[](https://inch-ci.org/github/doches/rtypeset)
[](https://codeclimate.com/github/doches/rtypeset)
[](https://codeclimate.com/github/doches/rtypeset/coverage)
A pure Ruby typographic pre-processor for HTML inspired by [Typeset.js](https://github.com/davidmerfield/Typeset) 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 = <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".":
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"})