]> pere.pagekite.me Git - text-madewithcc.git/blobdiff - fixup-docbook-translated.rb
Forming the legal information file for the Spanish edition (outside of the translatio...
[text-madewithcc.git] / fixup-docbook-translated.rb
index 57958d48e4cd9f713d1b3f269bc99e3f903a4f93..696c0dd97874f67d90a55840af4502f09419abd8 100644 (file)
@@ -21,6 +21,13 @@ def log(level,what)
   end
 end
 
+log 0, 'Including the Spanish version introduction'
+if intro = File.open('extra/es/intro_es.xml', 'r').read rescue nil
+  xml.search('preface').last.after( intro )
+else
+  log 0, ' -!- Introduction text not found or empty'
+end
+
 log 0, 'replace images with translated versions'
 xml.search('imagedata').each do |img|
   # Included images are in the 'Pictures' directory. Translated images
@@ -36,6 +43,28 @@ xml.search('imagedata').each do |img|
   end
 end
 
+log 0, 'Final editorial requests: Attributions on top, as in other chapters, also for prefaces'
+xml.search('preface').each do |pref|
+  title = pref.search('title').first
+  attrib = pref.search('blockquote').last
+  attrib_text =  attrib.inner_text.gsub(/\s+/,' ')
+
+  # Some formatting issues we need to modify
+  attrib_text.gsub!(/Paul y Sarah/, 'Paul <?latex \textup{>y<?latex } > Sarah')
+  attrib_text.gsub!(/Merkley (CEO.*)/, 'Merkley <citetitle>\1</citetitle>')
+  attrib_text.gsub!(/Wolf (Ins.*)/, 'Wolf <citetitle>\1</citetitle>')
+
+  attrib.remove
+  title.after('<blockquote><attribution>%s</attribution></blockquote>' % attrib_text)
+  log 1, 'Moved: %s' % attrib_text
+end
+
+log 0, 'Replace colophon + legalinfo by the information assembled by our publisher'
+if legal = File.open('extra/es/legal_info.xml', 'r').read rescue nil
+  xml.search('colophon').first.inner_html = legal
+end
+
+
 log 0, 'Writing processed file'
 # Unable to figure out API way to replace DOCTYPE
 data = xml.to_xml()