X-Git-Url: https://pere.pagekite.me/gitweb/text-madewithcc.git/blobdiff_plain/abceb51dd587940a4508ee523297a5df9973b12a..22e7e264e91d54d6cb84727f4f1e031ef2435159:/fixup-docbook.rb diff --git a/fixup-docbook.rb b/fixup-docbook.rb index 5219e45..a050496 100755 --- a/fixup-docbook.rb +++ b/fixup-docbook.rb @@ -38,8 +38,8 @@ xml.css('articleinfo').each do |node| XML node.last_element_child.after(<<'XML') - Gunnar Wolf -
Mexico City
+ Instituto de Investigaciones Económicas +
Universidad Nacional Autónoma de México
XML end @@ -53,8 +53,8 @@ partreplace(xml, 'colophon', 'colophon') partreplace(xml, 'dedication', 'dedication') partreplace(xml, 'foreword', 'preface') partreplace(xml, 'introduction', 'preface') -partreplace(xml, 'bibliography', 'chapter') -partreplace(xml, 'acknowledgments', 'chapter') +partreplace(xml, 'bibliography', 'appendix') +partreplace(xml, 'acknowledgments', 'appendix') log 0, 'place part introduction into ' s = xml.xpath("//part/title[text()='The Case Studies']")[0] @@ -89,6 +89,45 @@ if ! xml.css('dedication title').empty? xml.css('dedication title')[0].content = "" end +log 0, 're-styling dedication, preface and introduction authors' +xml.css('dedication').each do |ded| +# Take content out of the quote marks, and into the blockquote + quote = ded.css('quote').first + auth = ded.css('itemizedlist').first + quote_c = quote.content + auth_c = auth.content + # Styling the attribution (including the introducing hyphen) should + # be left to the following layers + auth_c.gsub!(/\s+/, ' ') + c = ded.css('quote').first.content + quote.parent.remove # remove the '' containing the quote + auth.remove + ded.last_element_child.after('
%s%s
' % + [quote_c, auth_c]) +end + +%w(preface#foreword preface#introduction).each do |spec| + sect = xml.css(spec)[0] + paras = sect.css('para emphasis') + auth = '
' + auth += paras.map{|p| p.content}.join('') + auth += '
' + sect.last_element_child.after(auth) + paras.each {|i| i.parent.remove} # Remove both the 'emphasis' and its parent 'para' +end + +auth = xml.css('chapter')[0].css('para')[0] +auth.content =~ /^\s*Paul Stacey\s*$/ or + raise RuntimeError, 'Error finding author name in chapter 1 -- ' + auth.content +auth.before('
Paul Stacey
') +auth.remove + +auth = xml.css('chapter')[1].css('para')[0] +auth.content =~ /^\s*Sarah Hinchliff Pearson.*$/ or + raise RuntimeError, 'Error finding author name in chapter 2 -- ' + auth.content +auth.before('
Sarah Hinchliff Pearson
') +auth.remove + log 0, 'move legal notice to bookinfo' xml.css('book bookinfo')[0].last_element_child.after('') ln = xml.css('book bookinfo legalnotice')[0] @@ -189,6 +228,15 @@ xml.css('figure').each do |fig| seq = seq + 1 end +log 0, 'Set epigraph line in each case study' +xml.css('blockquote para').select {|p| p.inner_text =~ /Profile written by/}.each do |epi| + p = epi.parent + by = epi.inner_text + epi.remove + p.last_element_child.after('%s' % by) +end + + # Disabled as dblatex do not understand chapter/chapterinfo/author, # see . if false