Class: Nanoc::CLI::StreamCleaners::UTF8 Private

Inherits:
Abstract
  • Object
show all
Defined in:
lib/nanoc/cli/stream_cleaners/utf8.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Simplifies output by replacing UTF-8 characters with their ASCII decompositions.

Instance Method Summary collapse

Instance Method Details

#clean(str) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

See Also:



10
11
12
13
14
15
16
17
18
# File 'lib/nanoc/cli/stream_cleaners/utf8.rb', line 10

def clean(str)
  return str unless str.encoding.name == 'UTF-8'

  # FIXME: this decomposition is not generally usable
  str
    .unicode_normalize(:nfkd)
    .tr('─┼“”‘’', '-+""\'\'')
    .gsub('©', '(c)')
end