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, convert = [:all], 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.

  • convert (Array) (defaults to: [:all])

    Array of symbols with features that should be improved (possibilities: all, hyphens, quotes, ellipsis, dashes, abbreviations, prepositions, numbers, dates, characters, brackets, multiplication, units, widows)

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

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

Returns:

  • (String)

    Paragraph with improved typography.



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

def english(input, convert = [:all], country = "us")
  output = input
  output = soft_hyphens(output, "en_" + country) if (convert.include?(:all) || convert.include?(:hyphens))
  output = general(output, convert)
  output = english_double_quotes(output) if (convert.include?(:all) || convert.include?(:quotes))
  output = english_single_quotes(output) if (convert.include?(:all) || convert.include?(:quotes))
  output
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.



35
36
37
# File 'lib/truty/english.rb', line 35

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.



27
28
29
# File 'lib/truty/english.rb', line 27

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