X-Git-Url: https://pere.pagekite.me/gitweb/text-madewithcc.git/blobdiff_plain/161d3e8cd91162b2dd3f10055e37d6b50561b89e..09716550cdf80f9c5f33d8390a1af64192a43af4:/fixup-docbook.rb diff --git a/fixup-docbook.rb b/fixup-docbook.rb index fb72e87..329d599 100755 --- a/fixup-docbook.rb +++ b/fixup-docbook.rb @@ -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