Module: Jekyll::TypogrifyFilter

Defined in:
lib/jekyll/typogrify.rb

Instance Method Summary collapse

Instance Method Details

#amp(text) ⇒ String

converts a & surrounded by optional whitespace or a non-breaking space to the HTML entity and surrounds it in a span with a styled class.

Parameters:

  • text (String)

    input text

Returns:

  • (String)

    input text with ampersands wrapped



15
16
17
# File 'lib/jekyll/typogrify.rb', line 15

def amp(text)
  return Typogruby.amp(text.to_s)
end

#caps(text) ⇒ String

surrounds two or more consecutive capital letters, perhaps with interspersed digits and periods in a span with a styled class.

Parameters:

  • text (String)

    input text

Returns:

  • (String)

    input text with caps wrapped



24
25
26
# File 'lib/jekyll/typogrify.rb', line 24

def caps(text)
  return Typogruby.caps(text.to_s)
end

#entities(text) ⇒ String

Converts special characters (excluding HTML tags) to HTML entities.

Parameters:

  • text (String)

    input text

Returns:

  • (String)

    input text with all special characters converted to HTML entities.



33
34
35
# File 'lib/jekyll/typogrify.rb', line 33

def entities(text)
  return Typogruby.entities(text.to_s)
end

#improve(text) ⇒ String

main function to do all the functions from the method.

Parameters:

  • text (String)

    input text

Returns:

  • (String)

    input text with all filters applied



41
42
43
# File 'lib/jekyll/typogrify.rb', line 41

def improve(text)
  return Typogruby.improve(text.to_s)
end

#initial_quotes(text) ⇒ String

encloses initial single or double quote, or their entities (optionally preceeded by a block element and perhaps an inline element) with a span that can be styled.

Parameters:

  • text (String)

    input text

Returns:

  • (String)

    input text with initial quotes wrapped



52
53
54
# File 'lib/jekyll/typogrify.rb', line 52

def initial_quotes(text)
  return Typogruby.initial_quotes(text.to_s)
end

#jt_caps(text) ⇒ String

surrounds two or more consecutive capital letters, perhaps with interspersed digits and periods in a span with a styled class.

Parameters:

  • text (String)

    input text

Returns:

  • (String)

    input text with caps wrapped



102
103
104
# File 'lib/jekyll/typogrify.rb', line 102

def jt_caps(text)
  return custom_caps(text.to_s)
end

#letter_spacing(text) ⇒ String

wraps words in a span class that can look like something else

Parameters:

  • text (String)

    input text

Returns:

  • (String)

    input text with words that look strange in a span



90
91
92
93
94
95
# File 'lib/jekyll/typogrify.rb', line 90

def letter_spacing(text)
  text.gsub(/(click\S*|clint\S*|final\S*|curt\S*|flick\S*)\b/im) { |str|
    tag, before, word = $1, $2, $3
    "#{before}<span class=\"fix-letter-spacing\">#{str}</span>"
  }
end

#smartypants(text) ⇒ String

Applies smartypants to a given piece of text

Parameters:

  • text (String)

    input text

Returns:

  • (String)

    input text with smartypants applied

See Also:



61
62
63
# File 'lib/jekyll/typogrify.rb', line 61

def smartypants(text)
  return Typogruby.smartypants(text.to_s)
end

#titlecase(text) ⇒ String

convert a given piece of text to titlecase

Parameters:

  • text (String)

    input text

Returns:

  • (String)

    input text convert to titlecase



82
83
84
# File 'lib/jekyll/typogrify.rb', line 82

def titlecase(text)
  return text.to_s.titlecase
end

#widont(text) ⇒ String

replaces space(s) before the last word (or tag before the last word) before an optional closing element (a, em, span, strong) before a closing tag (p, h[1-6], li, dt, dd) or the end of the string.

Parameters:

  • text (String)

    input text

Returns:

  • (String)

    input text with non-breaking spaces inserted

See Also:



74
75
76
# File 'lib/jekyll/typogrify.rb', line 74

def widont(text)
  return Typogruby.widont(text.to_s)
end