Module: Truty::French

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

Overview

Module with specific French typography fixes.

Author:

  • Matěj Kašpar Jirásek

Instance Method Summary collapse

Instance Method Details

#french(input, convert = [:all]) ⇒ String

Improves the French 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)

Returns:

  • (String)

    Paragraph with improved typography.



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

def french(input, convert = [:all])
  output = input
  output = soft_hyphens(output, "fr") if (convert.include?(:all) || convert.include?(:hyphens))
  output = general(output, convert)
  output = french_double_quotes(output) if (convert.include?(:all) || convert.include?(:quotes))
  output
end

#french_double_quotes(input) ⇒ String

Converts double quotes to the typograhic ones, guillemets.

Parameters:

  • input (String)

    The paragraph which will be converted.

Returns:

  • (String)

    Paragraph with correct double quotes.



25
26
27
# File 'lib/truty/french.rb', line 25

def french_double_quotes(input)
  quotes(input, '"“”„«»', "« ", " »")
end