Module: EvilFront::Typograph
Overview
Abstract module to be used in ‘Russian` and `English` typographs.
Instance Method Summary collapse
-
#typograph(text) ⇒ Object
Insert non-break spaces and mark quotes to have nice text.
-
#typograph_html(html) ⇒ Object
Like ‘typograph`, but process only text nodes in HTML.
Instance Method Details
#typograph(text) ⇒ Object
Insert non-break spaces and mark quotes to have nice text.
EvilFront::Russian.typograph(article)
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/evil-front/typograph.rb', line 18 def typograph(text) return text if text.nil? or text.empty? text.gsub! '"', '"' text = use_right_symbols(text) text.gsub!(/([^\s" ]+)-([^\s" ]+)/, '\1‑\2') tiny_words.each { |regexp| text.gsub! regexp, "\\1\\2 " } text end |
#typograph_html(html) ⇒ Object
Like ‘typograph`, but process only text nodes in HTML.
EvilFront::Russian.typograph_html(article.html)
11 12 13 |
# File 'lib/evil-front/typograph.rb', line 11 def typograph_html(html) process_html(html) { |text| typograph(text) } end |