Module: Truty::English

Included in:
Truty
Defined in:
lib/truty/english.rb

Overview

Module with specific English typography fixes.

Author:

  • Matěj Kašpar Jirásek

Instance Method Summary collapse

Instance Method Details

#english(input, country = "us") ⇒ String

Improves the English typography of single paragraph. If you supply more paragraphs you might lose some improvements like widows. For improving longer text see General#fix.

Parameters:

  • input (String)

    The paragraph which will be converted.

  • country (String) (defaults to: "us")

    The country (“uk” or “us”).

Returns:

  • (String)

    Paragraph with improved typography.



13
14
15
16
17
18
# File 'lib/truty/english.rb', line 13

def english(input, country = "us")
  input = soft_hyphens(input, "en_" + country)
  input = general(input)
  input = english_double_quotes(input)
  input = english_single_quotes(input)
end

#english_double_quotes(input) ⇒ String

Converts double quotes to the typograhic ones.

Parameters:

  • input (String)

    The paragraph which will be converted.

Returns:

  • (String)

    Paragraph with correct double quotes.



32
33
34
# File 'lib/truty/english.rb', line 32

def english_double_quotes(input)
  quotes(input)
end

#english_single_quotes(input) ⇒ String

Converts single quotes to the typograhic ones.

Parameters:

  • input (String)

    The paragraph which will be converted.

Returns:

  • (String)

    Paragraph with correct single quotes.



24
25
26
# File 'lib/truty/english.rb', line 24

def english_single_quotes(input)
  quotes(input, "'", "", "")
end