]>
pere.pagekite.me Git - text-madewithcc.git/blob - fixup-docbook-translated.rb
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 log
0, 'Including the Spanish version introduction'
25 if intro
= File
.open('extra/es/intro_es.xml', 'r').read
rescue nil
26 xml
.search('preface').last
.after( intro
)
28 log
0, ' -!- Introduction text
not found
or empty
'
31 log 0, 'Final editorial requests
: Attributions on top
, as
in other chapters
, also
for prefaces
'
32 xml.search('preface
').each do |pref|
33 title = pref.search('title
').first
34 attrib = pref.search('blockquote
').last
35 attrib_text = attrib.inner_text.gsub(/\s+/,' ')
37 # Some formatting issues we need to modify
38 attrib_text
.gsub!
(/Paul y Sarah/, 'Paul <?latex \textup{>y<?latex } > Sarah')
39 attrib_text
.gsub!
(/Merkley (CEO.*)/, 'Merkley <citetitle>\1</citetitle>')
40 attrib_text
.gsub!
(/Wolf (Ins.*)/, 'Wolf <citetitle>\1</citetitle>')
43 title
.after('<blockquote><attribution>%s</attribution></blockquote>' % attrib_text
)
44 log
1, 'Moved: %s' % attrib_text
47 log
0, 'Replace legal info by the information assembled by our publisher'
48 if legal
= File
.open('extra/es/legal_info.xml', 'r').read
rescue nil
49 xml
.search('colophon').first
.inner_html
= legal
52 log
0, 'Add a colophon at the end'
53 # Doing this the dirty, non-DocBooky way: I'm adding a large <?latex
54 # ... ?> section to the last appendix. This should probably go in the
55 # <colophon> section, but it's already used.
57 # A cleaner way would be to replace the <xsl:param
58 # name="latex.enddocument"> section in pdf_es.xsl — But it gets
60 if colophon
= File
.open('extra/es/colophon.tex', 'r').read
rescue nil
61 xml
.search('appendix').last
.search('para').last
.after('<?latex %s ?>' % colophon
)
65 log
0, 'Writing processed file'
66 # Unable to figure out API way to replace DOCTYPE
68 File
.open(dstfile
, 'w') {|f
| f
.write(data)}