Class: AnyStyle::Normalizer::Punctuation

Inherits:
AnyStyle::Normalizer show all
Defined in:
lib/anystyle/normalizer/punctuation.rb

Instance Attribute Summary

Attributes inherited from AnyStyle::Normalizer

#keys, #skip

Instance Method Summary collapse

Methods inherited from AnyStyle::Normalizer

#append, #detect_language, #detect_scripts, #doi_extract, #each_value, #initialize, #keys_for, #map_values, #name, #skip?

Constructor Details

This class inherits a constructor from AnyStyle::Normalizer

Instance Method Details

#normalize(item, **opts) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/anystyle/normalizer/punctuation.rb', line 15

def normalize(item, **opts)
  each_value(item) do |_, value|
    value.gsub!(/\s*[\)\]\.,:;\p{Pd}\p{Z}\p{C}。、》〉]+$/, '')
    value.gsub!(/[,:;》〉]+$/, '')
    value.gsub!(/^[\(\[《〈]/, '')
    value.gsub!(/<\/?(italic|bold)>/, '')
  end
end