bin/review-compile in review-1.7.2 vs bin/review-compile in review-2.0.0.beta1
- old
+ new
@@ -32,10 +32,12 @@
rescue Errno::EPIPE
exit 0
end
def _main
+ $KCODE = 'UTF-8' unless defined?(Encoding)
+
mode = :files
basedir = nil
if /\Areview2/ =~ File.basename($0)
target = File.basename($0, '.rb').sub(/review2/, '')
else
@@ -44,18 +46,20 @@
check_only = false
output_filename = nil
config = ReVIEW::Configure.values
config.merge!({
- "secnolevel" => 2, # for IDGXML and HTML
- "tableopt" => nil, # for IDGXML
- "nolf" => nil, # for IDGXML
- "chapref" => nil, # for IDGXML
+ "secnolevel" => 2, # for IDGXML and HTML
+ "tableopt" => nil, # for IDGXML
+ "nolf" => nil, # for IDGXML
+ "chapref" => nil, # for IDGXML
"structuredxml" => nil, # for IDGXML
- "stylesheet" => [], # for HTML
- "mathml" => nil, # for HTML
- "language" => "ja", # for HTML
+ "inencoding" => "UTF-8",
+ "outencoding" => "UTF-8",
+ "stylesheet" => [], # for HTML
+ "mathml" => nil, # for HTML
+ "language" => "ja", # for HTML
"deprecated-blocklines" => nil,
"footnotetext" => false,
"htmlext" => "html",
"htmlversion" => 4,
})
@@ -65,10 +69,12 @@
opts.banner = "Usage: #{File.basename($0)} [--target=FMT]"
opts.on('--yaml=YAML', 'Read configurations from YAML file.') do |yaml|
require 'yaml'
config = config.merge(YAML.load_file(yaml))
end
+ opts.on('--inencoding=ENCODING', 'Set input encoding. (UTF-8, EUC, JIS, and SJIS)') {|enc| config["inencoding"] = enc }
+ opts.on('--outencoding=ENCODING', 'Set output encoding. (UTF-8[default], EUC, JIS, and SJIS)') {|enc| config["outencoding"] = enc }
opts.on('-c', '--check', 'Check manuscript') { check_only = true }
opts.on('--level=LVL', 'Section level to append number.') {|lvl| config["secnolevel"] = lvl.to_i }
opts.on('--toclevel=LVL', 'Section level to append number.') {|lvl| config["toclevel"] = lvl.to_i }
opts.on('--nolfinxml', 'Do not insert LF in XML. (idgxml)') { config["nolf"] = true }
opts.on('--structuredxml', 'Produce XML with structured sections. (idgxml)') { config["structuredxml"] = true }
@@ -165,15 +171,15 @@
book = basedir ? ReVIEW::Book.load(basedir) : ReVIEW::Book::Base.load
book.config = config
compiler = ReVIEW::Compiler.new(load_strategy_class(target, check_only))
book.chapters.each do |chap|
str = compiler.compile(chap)
- write "#{chap.name}#{compiler.strategy.extname}", str unless check_only
+ write "#{chap.name}#{compiler.strategy.extname}", str unless check_only
end
# PART
book.parts_in_file.each do |part|
str = compiler.compile(part)
- write "#{part.name}#{compiler.strategy.extname}", str unless check_only
+ write "#{part.name}#{compiler.strategy.extname}", str unless check_only
end
else
raise "must not happen: #{mode}"
end
rescue ReVIEW::ApplicationError => err