Module: EvilFront::Typograph

Included in:
English, Russian
Defined in:
lib/evil-front/typograph.rb

Overview

Abstract module to be used in ‘Russian` and `English` typographs.

Instance Method Summary collapse

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
# 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)
  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