Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
134 lines (86 sloc) 3.89 KB
title type order
Typography
guide
20

Wordsmith provides a nice collection of functions for applying nice web typography treatments to your text, prettifying quotes, avoiding 'widows', etc.

Wordsmith's typography methods include:

Typography

amp

An alias of wrapAmps.

Provided for backwards compatibility, so that Wordsmith can be a drop-in replacement for the Typogrify plugin.

caps

An alias of wrapCaps.

Provided for backwards compatibility, so that Wordsmith can be a drop-in replacement for the Typogrify plugin.

typogrify

Typogrify applies a veritable kitchen sink of typographic treatments to beautify your web typography:

  • Pretty quotes — Smart handling of ‘single’ and “double” curly quotation marks
  • Pretty punctuation
    • em and en dashes, wrapped by   characters
    • ellipses (…)
    • trademarks (™), copyright (©), and service marks
    • math symbols (5×5×5=53)
    • fractions (½)
    • ordinal suffixes (1st, 2nd)
  • Smart hyphenation — Adds ­ characters into words to enable responsive hyphenation
  • Space control:
    • widow protection
    • gluing values to units
    • forced internal wrapping of long URLs and email addresses
  • CSS class wrapping for styling special characters
    • ampersands
    • uppercase words
    • numbers
    • initial quotes & guillemets
  • settings — An array of ad-hoc settings to override the defaults for this instance of the filter.
{% filter typogrify
    On the 1st day of Christmas my "true love" gave to me:
    1/2 of a Patridge(TM) in a pear tree.
{% endfilter %}
{{ 'Mark & Sons: "industry leaders" in... stuff.' | typogrify

typogrifyFeed

Applies suite of typographic treatments from to beautify your type, but in a way that is appropriate for RSS (or similar) feeds — i.e. excluding processes that may cause issues in contexts with limited character set intelligence.

  • settings — An array of ad-hoc settings to override the defaults for this instance of the filter.
{% set myFeed = include('feeds/myFeedTemplate') | typogrifyFeed %} 

smartypants

Parses 'ugly' quotes into smart ‘single’ and “double” curly quotation marks.

Provided for backwards compatibility, so that Wordsmith can be a drop-in replacement for the Typogrify plugin. The typogrify function already applies smart quotes.

widont

Replaces the space between the last two words in a string with a   to prevent widowing.

{% filter widont %}
    Lorem ipsum dolor sit amet.
{% endfilter %}

wrapAmps

Wraps ampersands in <span class="amp"> so they can be styled with CSS.

  • class ('amp') — The class name to apply
{{ 'Pixel & Tonic' | wrapAmps }}
{{ 'Pixel &amp; Tonic' | wrapAmps }}

(The typogrify function applies wrapAmps by default, unless you disable it in the settings.)

wrapCaps

Wraps all-uppercase words in <span class="caps"> so they can be styled with CSS.

  • class ('caps') — The class name to apply
{{ 'The CIA called the GCHQ about the KGB, but everyone there was MIA.' | wrapCaps }}

(The typogrify function applies wrapCaps by default, unless you disable it in the settings.)

Transliteration

Wordsmith also provides a method for transliterating symbols from other languages into their closest corresponding letters from the current alphabet.