Method: ReVIEW::EPUBMaker#remove_hidden_title

Defined in:
lib/review/epubmaker.rb

#remove_hidden_title(basetmpdir, htmlfile) ⇒ Object



340
341
342
343
344
345
346
347
348
349
# File 'lib/review/epubmaker.rb', line 340

def remove_hidden_title(basetmpdir, htmlfile)
  File.open("#{basetmpdir}/#{htmlfile}", "r+") do |f|
    body = f.read.
           gsub(/<h\d .*?hidden=['"]true['"].*?>.*?<\/h\d>\n/, '').
           gsub(/(<h\d .*?)\s*notoc=['"]true['"]\s*(.*?>.*?<\/h\d>\n)/, '\1\2')
    f.rewind
    f.print body
    f.truncate(f.tell)
  end
end