class Nanoc::CLI::StreamCleaners::UTF8

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

Public Instance Methods

clean(str) click to toggle source

@see Nanoc::CLI::StreamCleaners::Abstract#clean

# 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