source: stylesheets/lfs-xsl/docbook-xsl-1.78.1/epub/bin/dbtoepub@ 15c7d39

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 11.1 11.1-rc1 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 12.2 12.2-rc1 7.5 7.6 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 9.0 9.1 arm bdubbs/gcc13 ml-11.0 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/loongarch-12.2 xry111/mips64el xry111/multilib xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since 15c7d39 was 15c7d39, checked in by Matthew Burgess <matthew@…>, 11 years ago

Update stylesheets to docbook-xsl-1.78.1.

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@10355 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100755
File size: 2.6 KB
Line 
1#!/usr/bin/env ruby
2# This program converts DocBook documents into .epub files.
3#
4# Usage: dbtoepub [OPTIONS] [DocBook Files]
5#
6# .epub is defined by the IDPF at www.idpf.org and is made up of 3 standards:
7# - Open Publication Structure (OPS)
8# - Open Packaging Format (OPF)
9# - Open Container Format (OCF)
10#
11# Specific options:
12# -c, --css [FILE] Use FILE for CSS on generated XHTML.
13# -d, --debug Show debugging output.
14# -f, --font [OTF FILE] Embed OTF FILE in .epub.
15# -h, --help Display usage info.
16# -s, --stylesheet [XSL FILE] Use XSL FILE as a customization
17# layer (imports epub/docbook.xsl).
18# -v, --verbose Make output verbose.
19
20lib = File.expand_path(File.join(File.dirname(__FILE__), 'lib'))
21$LOAD_PATH.unshift(lib) if File.exist?(lib)
22
23require 'fileutils'
24require 'optparse'
25require 'tmpdir'
26
27require 'docbook'
28
29verbose = false
30debug = false
31css_file = nil
32otf_files = []
33customization_layer = nil
34output_file = nil
35
36#$DEBUG=true
37
38# Set up the OptionParser
39opts = OptionParser.new
40opts.banner = "Usage: #{File.basename($0)} [OPTIONS] [DocBook Files]
41
42#{File.basename($0)} converts DocBook <book> and <article>s into to .epub files.
43
44.epub is defined by the IDPF at www.idpf.org and is made up of 3 standards:
45- Open Publication Structure (OPS)
46- Open Packaging Format (OPF)
47- Open Container Format (OCF)
48
49Specific options:"
50opts.on("-c", "--css [FILE]", "Use FILE for CSS on generated XHTML.") {|f| css_file = f}
51opts.on("-d", "--debug", "Show debugging output.") {debug = true; verbose = true}
52opts.on("-f", "--font [OTF FILE]", "Embed OTF FILE in .epub.") {|f| otf_files << f}
53opts.on("-h", "--help", "Display usage info.") {puts opts.to_s; exit 0}
54opts.on("-o", "--output [OUTPUT FILE]", "Output ePub file as OUTPUT FILE.") {|f| output_file = f}
55opts.on("-s", "--stylesheet [XSL FILE]", "Use XSL FILE as a customization layer (imports epub/docbook.xsl).") {|f| customization_layer = f}
56opts.on("-v", "--verbose", "Make output verbose.") {verbose = true}
57
58db_files = opts.parse(ARGV)
59if db_files.size == 0
60 puts opts.to_s
61 exit 0
62end
63
64db_files.each {|docbook_file|
65 dir = File.expand_path(File.join(Dir.tmpdir, ".epubtmp#{Time.now.to_f.to_s}"))
66 FileUtils.mkdir_p(dir)
67 e = DocBook::Epub.new(docbook_file, dir, css_file, customization_layer, otf_files)
68
69 if output_file
70 epub_file = output_file
71 else
72 epub_file = File.basename(docbook_file, ".xml") + ".epub"
73 end
74 puts "Rendering DocBook file #{docbook_file} to #{epub_file}" if verbose
75 e.render_to_file(epub_file)
76}
Note: See TracBrowser for help on using the repository browser.