Project

typohero

0.0
No commit activity in last 3 years
No release in over 3 years
TypoHero improves web typography by applying various filters (similar to rubypants, typogruby, typogrify).
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

TypoHero

TypoHero has come to enhance your typography. There are no options, there is no documentation. He knows what you need.

require 'typohero'
TypoHero.enhance('Some text...')
TypoHero.truncate('Long text with tags...', max_words_or_separator)
TypoHero.strip_tags('Text with tags...')

Features

  • TypoHero.enhance - Typography enhancer
    • Special character treatment for quotes, dashes and ellipsis
    • Widon't with Unicode non-breaking space
    • Skips special tags like <script>
    • Styling enhancements
      • Capital letters are wrapped in <span class="caps">
      • Initial quotes are wrapped in <span class="quo">
      • Ampersands are wrapped in <span class="amp">
      • Ordinals are wrapped in <span class="ord">
      • Hyphenated words are wrapped in <span class="nobr">
    • LaTeX support
      • Some LaTeX commands are replaced by their Unicode counterpart
      • Mathjax code is skipped
  • TypoHero.truncate - Truncate which ensures that all tags are closed correctly
    • Supports maximum number of words and/or separator String/Regexp
  • TypoHero.strip_tags - Strip tags from content, keep only text
  • All methods keeps the string html_safe?

Why?

There is already SmartyPants, RubyPants, Typogruby, Typogrify, Fast-Aleck? So why?!

  • It is simpler, faster and more reliable than the others
  • More features
  • And I like regular expressions :)

But why not improve the existing libraries?

  • SmartyPants is Perl
  • RubyPants is good but too much of a direct Perl port
  • Typogruby has nice features but the implementation seems more like a hack
  • Typogrify is Python
  • Fast-Aleck is C, but I don't want to use C since Ruby is already a perfect text processing language!

Similar libraries

Smartypants (Perl), Typogrify (Python), Typography-Helper (Ruby), RubyPants (Ruby), Tyogruby (Ruby), Typography (Ruby), Typographer (Ruby), Typogrify (Ruby), Typogrowth (Ruby), Typogr.js (Javascript), Richtypo.js (Javascript), List of javascript typography libraries ...

License

The MIT License

Copyright (c) 2014 Daniel Mendler

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.