Module: Jekyll::TypogrifyFilter
- Defined in:
- lib/jekyll/typogrify.rb
Instance Method Summary collapse
-
#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.
-
#caps(text) ⇒ String
surrounds two or more consecutive capital letters, perhaps with interspersed digits and periods in a span with a styled class.
-
#entities(text) ⇒ String
Converts special characters (excluding HTML tags) to HTML entities.
-
#improve(text) ⇒ String
main function to do all the functions from the method.
-
#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.
-
#jt_caps(text) ⇒ String
surrounds two or more consecutive capital letters, perhaps with interspersed digits and periods in a span with a styled class.
-
#letter_spacing(text) ⇒ String
wraps words in a span class that can look like something else.
-
#smartypants(text) ⇒ String
Applies smartypants to a given piece of text.
-
#titlecase(text) ⇒ String
convert a given piece of text to titlecase.
-
#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.
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.
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.
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.
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.
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.
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.
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
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
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
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.
74 75 76 |
# File 'lib/jekyll/typogrify.rb', line 74 def widont(text) return Typogruby.widont(text.to_s) end |