bin/review-compile in review-0.9.0 vs bin/review-compile in review-1.0.0
- old
+ new
@@ -13,10 +13,11 @@
require 'pathname'
bindir = Pathname.new(__FILE__).realpath.dirname
$LOAD_PATH.unshift((bindir + '../lib').realpath)
+require 'review'
require 'review/compiler'
require 'review/book'
require 'fileutils'
require 'optparse'
@@ -46,74 +47,66 @@
"nolf" => nil, # for IDGXML
"chapref" => nil, # for IDGXML
"inencoding" => "UTF-8",
"outencoding" => "UTF-8",
"subdirmode" => nil,
- "stylesheet" => nil, # for HTML
+ "singledirmode" => nil,
+ "stylesheet" => [], # for HTML
"mathml" => nil, # for HTML
+ "language" => "ja", # for HTML
"deprecated-blocklines" => nil,
+ "footnotetext" => false,
+ "htmlext" => "html",
+ "htmlversion" => 4,
}
parser = OptionParser.new
parser.banner = "Usage: #{File.basename($0)} [--target=FMT]"
- parser.on('--inencoding=ENCODING', 'Set input encoding. (UTF-8, EUC, JIS, and SJIS)') {|enc|
- param["inencoding"] = enc
- }
- parser.on('--outencoding=ENCODING', 'Set output encoding. (UTF-8[default], EUC, JIS, and SJIS)') {|enc|
- param["outencoding"] = enc
- }
- parser.on('-c', '--check', 'Check manuscript') {
- check_only = true
- }
- parser.on('--level=LVL', 'Section level to append number.') {|lvl|
- param["secnolevel"] = lvl.to_i
- }
- parser.on('--nolfinxml', 'Do not insert LF in XML. (idgxml)') {
- param["nolf"] = true
- }
- parser.on('--table=WIDTH', 'Default table width. (idgxml)') {|tbl|
- param["tableopt"] = tbl
- }
- parser.on('--listinfo', 'Append listinfo tag to lists to indicate begin/end. (idgxml)') {
- param["listinfo"] = true
- }
- parser.on('--chapref="before,middle,after"', 'Chapref decoration.') {|cdec|
- param["chapref"] = cdec
- }
- parser.on('--subdirmode', 'Use chapter/id.ext path style to find images.') {
- param["subdirmode"] = true
- }
- parser.on('--stylesheet=file', 'Stylesheet file for HTML') {|file|
- param["stylesheet"] = file
- }
- parser.on('--mathml', 'Use MathML for TeX equation in HTML') {
+ parser.on('--yaml=YAML', 'Read configurations from YAML file.') do |yaml|
+ require 'yaml'
+ param = param.merge(YAML.load_file(yaml))
+ end
+ parser.on('--inencoding=ENCODING', 'Set input encoding. (UTF-8, EUC, JIS, and SJIS)') {|enc| param["inencoding"] = enc }
+ parser.on('--outencoding=ENCODING', 'Set output encoding. (UTF-8[default], EUC, JIS, and SJIS)') {|enc| param["outencoding"] = enc }
+ parser.on('-c', '--check', 'Check manuscript') { check_only = true }
+ parser.on('--level=LVL', 'Section level to append number.') {|lvl| param["secnolevel"] = lvl.to_i }
+ parser.on('--nolfinxml', 'Do not insert LF in XML. (idgxml)') { param["nolf"] = true }
+ parser.on('--table=WIDTH', 'Default table width. (idgxml)') {|tbl| param["tableopt"] = tbl }
+ parser.on('--listinfo', 'Append listinfo tag to lists to indicate begin/end. (idgxml)') { param["listinfo"] = true }
+ parser.on('--chapref="before,middle,after"', 'Chapref decoration.') {|cdec| param["chapref"] = cdec }
+ parser.on('--subdirmode', 'Use chapter/id.ext path style to find images.') { param["subdirmode"] = true }
+ parser.on('--singledirmode', 'Use id.ext path style to find images.') { param["singledirmode"] = true }
+ parser.on('--chapterlink', 'make chapref hyperlink') { param["chapterlink"] = true }
+ parser.on('--stylesheet=file', 'Stylesheet file for HTML (comma separated)') {|files| param["stylesheet"] = files.split(/\s*,\s*/) }
+ parser.on('--mathml', 'Use MathML for TeX equation in HTML') do
param["mathml"] = true
require 'math_ml'
- }
- parser.on('--hdnumberingmode', 'Output numbering headlines. (deprecated)') {
- param["hdnumberingmode"] = true
- }
- parser.on('--deprecated-blocklines', 'Disable paragrahs in block tags. Treat physical line as a paragraph. (deprecated)') {
- param["deprecated-blocklines"] = true
- }
- unless target
- parser.on('--target=FMT', 'Target format.') {|fmt|
- target = fmt
- }
end
- parser.on('-a', '--all', 'Compile all chapters.') {
+ parser.on('--htmlversion=VERSION', 'HTML version.') do |v|
+ v = v.to_i
+ param["htmlversion"] = v if v == 4 || v == 5
+ end
+ parser.on('--hdnumberingmode', 'Output numbering headlines. (deprecated)') { param["hdnumberingmode"] = true }
+ parser.on('--deprecated-blocklines', 'Disable paragrahs in block tags. Treat physical line as a paragraph. (deprecated)') { param["deprecated-blocklines"] = true }
+ parser.on('--target=FMT', 'Target format.') {|fmt| target = fmt } unless target
+ parser.on('--footnotetext',
+ 'Use footnotetext and footnotemark instead of footnote (latex)') {
+ param["footnotetext"] = true
+ }
+ parser.on('--draft', 'use draft mode(inline comment)') { param["draft"] = true }
+ parser.on('-a', '--all', 'Compile all chapters.') do
mode = :dir
basedir = nil
- }
- parser.on('--directory=DIR', 'Compile all chapters in DIR.') {|path|
+ end
+ parser.on('--directory=DIR', 'Compile all chapters in DIR.') do |path|
mode = :dir
basedir = path
- }
- parser.on('--help', 'Prints this message and quit.') {
+ end
+ parser.on('--help', 'Prints this message and quit.') do
puts parser.help
exit 0
- }
+ end
begin
parser.parse!
unless target
if check_only
target = 'html'
@@ -125,10 +118,17 @@
error err.message
$stderr.puts parser.help
exit 1
end
+ # array parameter
+ ["stylesheet"].each do |k|
+ if param["k"].instance_of?(String)
+ param["k"] = [param["k"]]
+ end
+ end
+
begin
compiler = ReVIEW::Compiler.new(load_strategy_class(target, check_only))
ReVIEW.book.param = param
case mode
when :files
@@ -136,10 +136,10 @@
error 'no input'
exit 1
end
ReVIEW::Chapter.intern_pathes(ARGV).each do |chap|
result = compiler.compile(chap)
- print result unless check_only
+ puts result unless check_only
end
when :dir
book = basedir ? ReVIEW::Book.load(basedir) : ReVIEW.book
book.chapters.each do |chap|
str = compiler.compile(chap)