]>
pere.pagekite.me Git - text-madewithcc.git/blob - fixup-docbook-translated.rb
2d084a9479f7137068af77659478bad125b59b82
7 raise ArgumentError
, 'Language and source/destination files not specified' if ARGV.size !
= 3
13 xml
= Nokogiri
::XML(f
)
16 indicators
= %w(! •
# -)
18 print indicators
[level
]
20 print
"\n%s %s\n" % ['*' * (level+
1), what
]
24 if intro
= File
.open('extra/%s/intro_%s.xml' % [lang
, lang
],
26 log
0, 'Including the %s version introduction' % lang
27 xml
.search('preface').last
.after( intro
)
29 log
0, ' -!- Not including the
%s introduction text
' % lang
33 log 0, 'Final editorial requests
: Attributions on top
, as
in other chapters
, also
for prefaces
'
34 xml.search('preface
').each do |pref|
35 title = pref.search('title
').first
36 attrib = pref.search('blockquote
').last
37 attrib_text = attrib.inner_text.gsub(/\s+/,' ')
39 # Some formatting issues we need to modify
40 attrib_text
.gsub!
(/Paul y Sarah/, 'Paul <?latex \textup{>y<?latex } > Sarah')
41 attrib_text
.gsub!
(/Merkley,? (CEO.*)/, 'Merkley <citetitle>\1</citetitle>')
42 attrib_text
.gsub!
(/Wolf (Ins.*)/, 'Wolf <citetitle>\1</citetitle>')
45 title
.after('<blockquote><attribution>%s</attribution><para/></blockquote>' % attrib_text
)
46 log
1, 'Moved: %s' % attrib_text
50 if legal
= File
.open('extra/%s/legal_info.xml' % lang
, 'r').read
rescue nil
51 log
0, 'Replace legal info by the information assembled by our publisher'
52 xml
.search('colophon').first
.inner_html
= legal
55 # Doing this the dirty, non-DocBooky way: I'm adding a large <?latex
56 # ... ?> section to the last appendix. This should probably go in the
57 # <colophon> section, but it's already used.
59 # A cleaner way would be to replace the <xsl:param
60 # name="latex.enddocument"> section in pdf_es.xsl — But it gets
62 if colophon
= File
.open('extra/%s/colophon.tex' % lang
, 'r').read
rescue nil
63 log
0, 'Add a colophon at the end'
64 xml
.search('appendix').last
.search('para').last
.after('<?latex %s ?>' % colophon
)
68 log
0, 'Writing processed file'
69 # Unable to figure out API way to replace DOCTYPE
71 File
.open(dstfile
, 'w') {|f
| f
.write(data)}