Class: EpubTools::XHTMLCleaner

Inherits:
Object
  • Object
show all
Defined in:
lib/epub_tools/xhtml_cleaner.rb

Instance Method Summary collapse

Constructor Details

#initialize(filename, class_config = 'text_style_classes.yaml') ⇒ XHTMLCleaner

Returns a new instance of XHTMLCleaner.



8
9
10
11
# File 'lib/epub_tools/xhtml_cleaner.rb', line 8

def initialize(filename, class_config = 'text_style_classes.yaml')
  @filename = filename
  @classes = YAML.load_file(class_config).transform_keys(&:to_sym)
end

Instance Method Details

#callObject



13
14
15
16
17
18
19
20
21
# File 'lib/epub_tools/xhtml_cleaner.rb', line 13

def call
  raw_content = read_and_strip_problematic_hr
  doc = parse_xml(raw_content)
  remove_empty_paragraphs(doc)
  remove_bold_spans(doc)
  replace_italic_spans(doc)
  unwrap_remaining_spans(doc)
  write_pretty_output(doc)
end