review 2.0.0.beta1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +66 -1
  3. data/.rubocop_todo.yml +617 -0
  4. data/.travis.yml +16 -1
  5. data/ChangeLog +48 -0
  6. data/Dockerfile +22 -0
  7. data/Gemfile +0 -1
  8. data/README.md +97 -0
  9. data/Rakefile +10 -11
  10. data/appveyor.yml +9 -0
  11. data/bin/review +46 -0
  12. data/bin/review-check +8 -21
  13. data/bin/review-compile +26 -43
  14. data/bin/review-index +9 -22
  15. data/bin/review-init +21 -25
  16. data/bin/review-preproc +9 -13
  17. data/bin/review-validate +1 -1
  18. data/bin/review-vol +3 -17
  19. data/bin/review-webmaker +15 -0
  20. data/doc/NEWS.ja.md +534 -0
  21. data/doc/NEWS.md +538 -0
  22. data/doc/catalog.ja.md +10 -18
  23. data/doc/catalog.md +5 -9
  24. data/doc/config.yml.sample +319 -0
  25. data/doc/customize_epub.ja.md +42 -0
  26. data/doc/format.ja.md +320 -288
  27. data/doc/format.md +277 -170
  28. data/doc/format_idg.ja.md +82 -175
  29. data/doc/pdfmaker.ja.md +61 -0
  30. data/doc/pdfmaker.md +65 -0
  31. data/doc/quickstart.ja.md +88 -98
  32. data/doc/quickstart.md +72 -110
  33. data/doc/sample.css +41 -0
  34. data/doc/writing_vertical.ja.md +55 -0
  35. data/doc/writing_vertical.md +5 -0
  36. data/lib/epubmaker/content.rb +3 -3
  37. data/lib/epubmaker/epubcommon.rb +173 -145
  38. data/lib/epubmaker/epubv2.rb +24 -77
  39. data/lib/epubmaker/epubv3.rb +72 -73
  40. data/lib/epubmaker/producer.rb +54 -30
  41. data/lib/lineinput.rb +48 -0
  42. data/lib/review/book.rb +0 -1
  43. data/lib/review/book/base.rb +47 -27
  44. data/lib/review/book/chapter.rb +48 -19
  45. data/lib/review/book/compilable.rb +10 -14
  46. data/lib/review/book/index.rb +10 -19
  47. data/lib/review/book/page_metric.rb +0 -10
  48. data/lib/review/book/part.rb +17 -3
  49. data/lib/review/builder.rb +84 -68
  50. data/lib/review/catalog.rb +5 -1
  51. data/lib/review/compiler.rb +327 -4657
  52. data/lib/review/configure.rb +84 -10
  53. data/lib/review/converter.rb +28 -0
  54. data/lib/review/epubbuilder.rb +1 -1
  55. data/lib/review/epubmaker.rb +142 -158
  56. data/lib/review/ewbbuilder.rb +5 -5
  57. data/lib/review/exception.rb +1 -1
  58. data/lib/review/extentions.rb +1 -1
  59. data/lib/review/extentions/hash.rb +15 -0
  60. data/lib/review/extentions/string.rb +2 -1
  61. data/lib/review/htmlbuilder.rb +364 -348
  62. data/lib/review/htmltoc.rb +44 -0
  63. data/lib/review/htmlutils.rb +12 -6
  64. data/lib/review/i18n.rb +78 -6
  65. data/lib/review/i18n.yml +7 -4
  66. data/lib/review/idgxmlbuilder.rb +226 -267
  67. data/lib/review/latexbuilder.rb +281 -274
  68. data/lib/review/latexutils.rb +56 -49
  69. data/lib/review/makerhelper.rb +8 -4
  70. data/lib/review/markdownbuilder.rb +80 -124
  71. data/lib/review/pdfmaker.rb +197 -138
  72. data/lib/review/preprocessor.rb +16 -67
  73. data/lib/review/template.rb +24 -0
  74. data/lib/review/textbuilder.rb +1 -1
  75. data/lib/review/textutils.rb +18 -24
  76. data/lib/review/tocparser.rb +51 -106
  77. data/lib/review/tocprinter.rb +61 -117
  78. data/lib/review/topbuilder.rb +119 -126
  79. data/lib/review/unfold.rb +2 -2
  80. data/lib/review/version.rb +1 -1
  81. data/lib/review/webmaker.rb +302 -0
  82. data/lib/review/webtocprinter.rb +48 -0
  83. data/lib/review/yamlloader.rb +47 -0
  84. data/review.gemspec +3 -3
  85. data/templates/html/layout-html5.html.erb +17 -0
  86. data/templates/html/layout-xhtml1.html.erb +20 -0
  87. data/{lib/review → templates/latex}/layout.tex.erb +107 -115
  88. data/templates/ncx/epubv2.ncx.erb +11 -0
  89. data/templates/opf/epubv2.opf.erb +21 -0
  90. data/templates/opf/epubv3.opf.erb +18 -0
  91. data/templates/web/html/layout-html5.html.erb +56 -0
  92. data/templates/web/html/layout-xhtml1.html.erb +20 -0
  93. data/templates/xml/container.xml.erb +6 -0
  94. data/test/assets/test.xml.erb +3 -0
  95. data/test/assets/test_template.tex +28 -71
  96. data/test/assets/test_template_backmatter.tex +1 -9
  97. data/test/sample-book/src/Rakefile +12 -3
  98. data/{doc/sample.yml → test/sample-book/src/config-epub2.yml} +92 -147
  99. data/test/sample-book/src/config.yml +40 -154
  100. data/test/sample-book/src/style-web.css +45 -0
  101. data/test/sample-book/src/style.css +23 -1
  102. data/test/test.re +1 -1
  103. data/test/test_book.rb +15 -17
  104. data/test/test_book_chapter.rb +2 -80
  105. data/test/test_book_part.rb +1 -1
  106. data/test/test_builder.rb +28 -6
  107. data/test/test_catalog.rb +17 -0
  108. data/test/test_compiler.rb +14 -59
  109. data/test/test_configure.rb +94 -0
  110. data/test/test_converter.rb +21 -0
  111. data/test/test_epub3maker.rb +155 -3
  112. data/test/test_epubmaker.rb +245 -30
  113. data/test/test_epubmaker_cmd.rb +2 -2
  114. data/test/test_extentions_hash.rb +60 -0
  115. data/test/test_helper.rb +4 -47
  116. data/test/test_htmlbuilder.rb +282 -175
  117. data/test/test_htmltoc.rb +33 -0
  118. data/test/test_i18n.rb +134 -70
  119. data/test/test_idgxmlbuilder.rb +58 -39
  120. data/test/test_latexbuilder.rb +132 -14
  121. data/test/test_lineinput.rb +5 -26
  122. data/test/test_makerhelper.rb +6 -4
  123. data/test/test_markdownbuilder.rb +23 -5
  124. data/test/test_pdfmaker.rb +86 -20
  125. data/test/test_pdfmaker_cmd.rb +1 -3
  126. data/test/test_review_ext.rb +1 -1
  127. data/test/test_template.rb +27 -0
  128. data/test/test_textutils.rb +36 -0
  129. data/test/test_tocparser.rb +25 -0
  130. data/test/test_topbuilder.rb +34 -2
  131. data/test/test_yamlloader.rb +188 -0
  132. metadata +71 -29
  133. data/README.rdoc +0 -81
  134. data/bin/review-epubmaker-legacy +0 -1024
  135. data/doc/ruby-uuid/README +0 -11
  136. data/doc/ruby-uuid/README.ja +0 -34
  137. data/lib/review/compiler/literals_1_8.kpeg +0 -19
  138. data/lib/review/compiler/literals_1_8.rb +0 -432
  139. data/lib/review/compiler/literals_1_9.kpeg +0 -22
  140. data/lib/review/compiler/literals_1_9.rb +0 -435
  141. data/lib/review/extentions/array.rb +0 -25
  142. data/lib/review/htmllayout.rb +0 -41
  143. data/lib/review/inaobuilder.rb +0 -357
  144. data/lib/review/location.rb +0 -24
  145. data/lib/review/node.rb +0 -267
  146. data/lib/review/review.kpeg +0 -724
  147. data/lib/uuid.rb +0 -312
  148. data/rubocop-todo.yml +0 -456
  149. data/test/test_inaobuilder.rb +0 -247
  150. data/test/test_uuid.rb +0 -157
@@ -1,9 +1,24 @@
1
+ language: ruby
2
+ sudo: false
3
+
4
+ before_install:
5
+ - gem update bundler
6
+
1
7
  rvm:
2
- - 1.9.3
3
8
  - 2.0.0
4
9
  - 2.1.*
5
10
  - 2.2.*
11
+ - 2.3.0
12
+
13
+ addons:
14
+ apt_packages:
15
+ - libgmp3-dev
6
16
 
7
17
  branches:
8
18
  only:
9
19
  - master
20
+
21
+ script:
22
+ - bundle exec rake test
23
+ - bundle exec rubocop
24
+
data/ChangeLog CHANGED
@@ -1,3 +1,51 @@
1
+ Fri Apr 29 23:11:06 2016 Masayoshi Takahashi <takahashimm@gmail.com>
2
+
3
+ * Release 2.0.0
4
+
5
+ Mon Apr 4 14:42:51 2016 Kenshi Muto <kmuto@debian.org>
6
+
7
+ * config.yml:
8
+ support "inherit: YAMLfilename" parameter in config.yml to
9
+ read other YAML file (such as common.yml.)
10
+
11
+ Sun Apr 3 17:21:25 2016 Masayoshi Takahashi <takahashimm@gmail.com>
12
+
13
+ * epubmaker:
14
+ add direction in default setting.
15
+
16
+ Sun Apr 3 11:04:53 2016 Kenshi Muto <kmuto@debian.org>
17
+
18
+ * epubmaker:
19
+ accept hash value for 'booktitle' and some other parameters,
20
+ as same as 'aut:' (author value).
21
+ This change aims to set "file-as" variable to book title.
22
+
23
+ Sun Apr 3 11:03:47 2016 Masayoshi Takahashi <takahashimm@gmail.com>
24
+
25
+ use SecureRandom.uuid instead of ruby-uuid
26
+
27
+ Fri Mar 25 22:16:33 2016 Kenshi Muto <kmuto@debian.org>
28
+
29
+ * bin/review-preproc:
30
+ load review-preproc-ext.rb if it exists, to overwrite
31
+ review-preproc.
32
+
33
+ Sun Dec 27 16:25:45 2015 Masayoshi Takahashi <takahashimm@gmail.com>
34
+
35
+ * Release 1.7.2
36
+
37
+ Sun Nov 29 23:12:29 2015 Masayoshi Takahashi <takahashimm@gmail.com>
38
+
39
+ * Release 1.7.1
40
+
41
+ Thu Oct 29 13:58:22 2015 KADO Masanori <kdmsnr@gmail.com>
42
+
43
+ * Release 1.7.0
44
+
45
+ Mon Jun 29 18:16:06 2015 KADO Masanori <kdmsnr@gmail.com>
46
+
47
+ * Release 1.6.0
48
+
1
49
  Sat Feb 28 19:51:29 2015 KADO Masanori <kdmsnr@gmail.com>
2
50
 
3
51
  * Release 1.5.0.
@@ -0,0 +1,22 @@
1
+ # This file is a sample Dockerfile to build Re:VIEW documents.
2
+ #
3
+ # Build:
4
+ # $ docker build -t review .
5
+ #
6
+ # Usage:
7
+ # $ cd path/to/review/project
8
+ # $ docker run -it --rm -v `pwd`:/work review rake pdf
9
+ #
10
+ # cf. https://github.com/vvakame/docker-review/blob/master/Dockerfile
11
+
12
+ FROM debian:sid
13
+ MAINTAINER takahashim
14
+
15
+ RUN apt-get update \
16
+ && apt-get install -y --no-install-recommends git-core ruby locales zip \
17
+ && apt-get install -y --no-install-recommends texlive-lang-cjk texlive-lang-japanese texlive-fonts-recommended texlive-latex-extra ghostscript \
18
+ && rm -rf /var/lib/apt/lists/*
19
+ RUN gem install review rake bundler --no-rdoc --no-ri
20
+
21
+ VOLUME ["/work"]
22
+ WORKDIR /work
data/Gemfile CHANGED
@@ -3,4 +3,3 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in review.gemspec
4
4
  gemspec
5
5
 
6
- gem "json"
@@ -0,0 +1,97 @@
1
+ # Re:VIEW
2
+
3
+ [![Build Status](https://secure.travis-ci.org/kmuto/review.png)](http://travis-ci.org/kmuto/review)
4
+ [![Gem Version](https://badge.fury.io/rb/review.png)](http://badge.fury.io/rb/review)
5
+
6
+ Re:VIEW is an easy-to-use digital publishing system for paper books and ebooks.
7
+
8
+ ## Supported Format
9
+
10
+ Output formats Re:VIEW supports are:
11
+
12
+ * EPUB
13
+ * LaTeX
14
+ * InDesign (IDGXML)
15
+ * Markdown
16
+ * plain text (TOPBuilder Text Markup Language)
17
+
18
+ Re:VIEW uses its original format('Re:VIEW format') as source files. See doc/format.md.
19
+
20
+ ## Commands
21
+
22
+ There are two commands generate files directly.
23
+
24
+ * review-epubmaker: generate EPUB file.
25
+ * review-pdfmaker: generate PDF file using LaTeX(ptexlive).
26
+
27
+ And some useful commands.
28
+
29
+ * review-compile: compile Re:VIEW fomat files.
30
+ * review-vol: figure out size of Re:VIEW files.
31
+ * review-index: generate index with various format.
32
+ * review-preproc: preprocessor.
33
+
34
+ ## Installation
35
+
36
+ Install gem yourself as:
37
+
38
+ $ gem install review
39
+
40
+ Or build from source:
41
+
42
+ $ git clone https://github.com/kmuto/review.git
43
+ $ cd review
44
+ $ rake install
45
+
46
+ Or add the `./bin` directory to your $PATH:
47
+
48
+ $ echo "export PATH=PATH_OF_REVIEW/bin:$PATH" >> ~/.profile
49
+
50
+ ## Quick Start
51
+
52
+ ```
53
+ $ review-init hello
54
+ $ cd hello
55
+ $ (... add and edit *.re file, config.yml and catalog.yml ...)
56
+ $ rake epub ## generating EPUB
57
+ $ rake pdf ## generating PDF
58
+ ```
59
+
60
+ For further information, see [doc/quickstart.md](https://github.com/kmuto/review/blob/readme-md/doc/quickstart.md)
61
+
62
+ ## Resources
63
+
64
+ | | URL |
65
+ |---------|----------------------------------------|
66
+ | Home | http://reviewml.org |
67
+ | Project | https://github.com/kmuto/review/ |
68
+ | Gems | https://rubygems.org/gems/review |
69
+ | Wiki | https://github.com/kmuto/review/wiki |
70
+ | Bugs | https://github.com/kmuto/review/issues |
71
+
72
+ ### Documents
73
+
74
+ * Wiki pages: https://github.com/kmuto/review/wiki
75
+ * doc/* files (in English and Japanese)
76
+
77
+ ### Issues tracker
78
+
79
+ * GitHub: https://github.com/kmuto/review
80
+
81
+ ### Note on Patches/Pull Requests
82
+
83
+ * Fork the project.
84
+ * Make your feature addition or bug fix.
85
+ * Add tests for it. This is important so I don't break it in a
86
+ future version unintentionally.
87
+ * Commit, do not mess with rakefile, version, or history.
88
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
89
+ * Send me a pull request. Bonus points for topic branches.
90
+
91
+ ## License
92
+
93
+ LGPL. See [COPYING](https://github.com/kmuto/review/blob/master/COPYING) file.
94
+
95
+ ## Copyright
96
+
97
+ Copyright (c) 2006-2016 Minero Aoki, Kenshi Muto, Masayoshi Takahashi, Masanori Kado.
data/Rakefile CHANGED
@@ -1,5 +1,3 @@
1
- require 'fileutils'
2
-
3
1
  begin
4
2
  require 'bundler'
5
3
  Bundler::GemHelper.install_tasks
@@ -11,21 +9,22 @@ require 'rubygems'
11
9
  require 'rake/testtask'
12
10
  require 'rake/clean'
13
11
 
14
- task :default => [:test]
12
+ task :default => [:test, :rubocop]
15
13
 
16
- task :kpeg do
17
- FileUtils.rm_f "lib/review/compiler.rb"
18
- FileUtils.rm_f "lib/review/compiler/literals_1_8.rb"
19
- FileUtils.rm_f "lib/review/compiler/literals_1_9.rb"
20
- sh "kpeg -s lib/review/compiler/literals_1_8.kpeg -o lib/review/compiler/literals_1_8.rb"
21
- sh "kpeg -s lib/review/compiler/literals_1_9.kpeg -o lib/review/compiler/literals_1_9.rb"
22
- sh "kpeg -s lib/review/review.kpeg -o lib/review/compiler.rb"
14
+ task :rubocop do
15
+ begin
16
+ require 'rubocop/rake_task'
17
+ RuboCop::RakeTask.new
18
+ rescue LoadError
19
+ warn "rubocop not found"
20
+ end
23
21
  end
24
22
 
25
23
  Rake::TestTask.new("test") do |t|
26
- t.libs << "test"
24
+ t.libs << "test"
27
25
  t.test_files = Dir.glob("test/**/test_*.rb")
28
26
  t.verbose = true
27
+ t.warning = false
29
28
  end
30
29
 
31
30
  begin
@@ -0,0 +1,9 @@
1
+ ---
2
+ install:
3
+ - SET PATH=C:\Ruby22-x64\bin;%PATH%
4
+ - ruby --version
5
+ - gem --version
6
+ build_script:
7
+ - bundle install
8
+ - bundle exec rake test --trace --verbose
9
+ - bundle exec rubocop
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #
4
+ # review: Wrapper command to call subcommand
5
+ #
6
+ # ex.
7
+ # review epubmaker config.yml
8
+ # -> call `review-epubmaker config.yml`
9
+ #
10
+
11
+ require 'pathname'
12
+
13
+ def usage
14
+ message = <<-EOB
15
+ usage: review <command> [<args>]
16
+
17
+ ReVIEW commands are:
18
+ init
19
+ preproc
20
+ compile
21
+ epubmaker
22
+ pdfmaker
23
+ vol
24
+ check
25
+ index
26
+ validate
27
+ EOB
28
+ print message
29
+ exit 1
30
+ end
31
+
32
+ usage if ARGV.length == 0
33
+
34
+ command = "review-#{ARGV.shift}"
35
+ bindir = Pathname.new(__FILE__).realpath.dirname
36
+ command_path = File.join(bindir, command)
37
+
38
+ if !File.exist?(command_path)
39
+ print "cannot find command: #{command}\n\n"
40
+ usage
41
+ end
42
+
43
+ exec(command_path, *ARGV)
44
+
45
+
46
+
@@ -31,12 +31,7 @@ rescue Errno::EPIPE
31
31
  end
32
32
 
33
33
  def main
34
- $KCODE = 'UTF-8' unless defined?(Encoding)
35
34
  @config = ReVIEW::Configure.values
36
- @config.merge!({
37
- "inencoding" => "UTF-8",
38
- "outencoding" => "UTF-8"
39
- })
40
35
  @book = ReVIEW::Book::Base.load
41
36
  @book.config = @config
42
37
 
@@ -44,12 +39,6 @@ def main
44
39
  files = ARGV unless ARGV.empty?
45
40
  opts = OptionParser.new
46
41
  opts.version = ReVIEW::VERSION
47
- opts.on('--inencoding=ENCODING', 'Set input encoding. (UTF-8, EUC, JIS, and SJIS)') {|enc|
48
- @config["inencoding"] = enc
49
- }
50
- opts.on('--outencoding=ENCODING', 'Set output encoding. (UTF-8[default], EUC, JIS, and SJIS)') {|enc|
51
- @config["outencoding"] = enc
52
- }
53
42
  opts.on('-a', '--all-chapters', 'Check all chapters.') {
54
43
  files = @book.chapters.map {|ent| ent.path }
55
44
  }
@@ -95,11 +84,11 @@ def check_text(files)
95
84
  each_paragraph(f) do |para, lineno|
96
85
  s = para.join('')
97
86
  if m = re.match(s)
98
- next if m[0] == $ReVIEW_utils_word_ok
87
+ next if m[0] == @review_utils_word_ok
99
88
  next if neg and neg =~ s
100
89
  str, offset = find_line(para, re)
101
90
  out = sprintf("%s:%d: %s\n", path, lineno + offset, str)
102
- print convert_outencoding(out, @config["outencoding"])
91
+ print out
103
92
  end
104
93
  end
105
94
  }
@@ -109,14 +98,14 @@ end
109
98
  def find_line(lines, re)
110
99
  # single line?
111
100
  lines.each_with_index do |line, idx|
112
- return line.gsub(re, '<<<\&>>>'), idx if re =~ line
101
+ return line.gsub(re, '<<<\&>>>'), idx if re =~ line
113
102
  end
114
103
 
115
104
  # multiple lines?
116
105
  i = 0
117
106
  while i < lines.size - 1
118
107
  str = lines[i] + lines[i+1]
119
- return str.gsub(re, '<<<\&>>>'), i if re =~ str
108
+ return str.gsub(re, '<<<\&>>>'), i if re =~ str
120
109
  i += 1
121
110
  end
122
111
 
@@ -127,7 +116,7 @@ def words_re(rc)
127
116
  words = []
128
117
  nega = []
129
118
  File.foreach(rc) do |line|
130
- next if line[0,1] == '#'
119
+ next if line[0,1] == '#'
131
120
  if / !/ =~ line
132
121
  line, n = *line.split(/!/, 2)
133
122
  nega.push n.strip
@@ -139,13 +128,11 @@ def words_re(rc)
139
128
  end
140
129
 
141
130
  def each_paragraph(f)
142
- $ReVIEW_utils_word_ok = nil
131
+ @review_utils_word_ok = nil
143
132
  while line = f.gets
144
- line = convert_inencoding(line, @config["inencoding"])
145
-
146
133
  case line
147
134
  when /\A\#@ok\((.*)\)/
148
- $ReVIEW_utils_word_ok = $1
135
+ @review_utils_word_ok = $1
149
136
  when /\A\#@/
150
137
  ;
151
138
  when %r[\A//caption\{(.*?)//\}]
@@ -168,7 +155,7 @@ def each_paragraph(f)
168
155
  buf.push line.strip
169
156
  end
170
157
  yield buf, lineno
171
- $ReVIEW_utils_word_ok = nil
158
+ @review_utils_word_ok = nil
172
159
  end
173
160
  end
174
161
  end
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # $Id: review-compile 4326 2010-01-12 14:10:17Z kmuto $
4
4
  #
5
- # Copyright (c) 2008-2014 Kenshi Muto, Masayoshi Takahashi, KADO Masanori, Minero Aoki
5
+ # Copyright (c) 2008-2016 Kenshi Muto, Masayoshi Takahashi, KADO Masanori, Minero Aoki
6
6
  # Copyright (c) 1999-2007 Minero Aoki
7
7
  #
8
8
  # This program is free software.
@@ -17,11 +17,11 @@ bindir = Pathname.new(__FILE__).realpath.dirname
17
17
  $LOAD_PATH.unshift((bindir + '../lib').realpath)
18
18
 
19
19
  require 'review'
20
- require 'review/compiler'
21
- require 'review/book'
22
- require 'review/i18n'
23
20
  require 'fileutils'
24
21
  require 'optparse'
22
+ require 'yaml'
23
+
24
+ DEFAULT_CONFIG_FILENAME = "config.yml"
25
25
 
26
26
  def main
27
27
  Signal.trap(:INT) { exit 1 }
@@ -34,8 +34,6 @@ rescue Errno::EPIPE
34
34
  end
35
35
 
36
36
  def _main
37
- $KCODE = 'UTF-8' unless defined?(Encoding)
38
-
39
37
  mode = :files
40
38
  basedir = nil
41
39
  if /\Areview2/ =~ File.basename($0)
@@ -47,32 +45,11 @@ def _main
47
45
  output_filename = nil
48
46
 
49
47
  config = ReVIEW::Configure.values
50
- config.merge!({
51
- "secnolevel" => 2, # for IDGXML and HTML
52
- "tableopt" => nil, # for IDGXML
53
- "nolf" => nil, # for IDGXML
54
- "chapref" => nil, # for IDGXML
55
- "structuredxml" => nil, # for IDGXML
56
- "inencoding" => "UTF-8",
57
- "outencoding" => "UTF-8",
58
- "stylesheet" => [], # for HTML
59
- "mathml" => nil, # for HTML
60
- "language" => "ja", # for HTML
61
- "deprecated-blocklines" => nil,
62
- "footnotetext" => false,
63
- "htmlext" => "html",
64
- "htmlversion" => 4,
65
- })
66
48
 
67
49
  opts = OptionParser.new
68
50
  opts.version = ReVIEW::VERSION
69
51
  opts.banner = "Usage: #{File.basename($0)} [--target=FMT]"
70
- opts.on('--yaml=YAML', 'Read configurations from YAML file.') do |yaml|
71
- require 'yaml'
72
- config = config.merge(YAML.load_file(yaml))
73
- end
74
- opts.on('--inencoding=ENCODING', 'Set input encoding. (UTF-8, EUC, JIS, and SJIS)') {|enc| config["inencoding"] = enc }
75
- opts.on('--outencoding=ENCODING', 'Set output encoding. (UTF-8[default], EUC, JIS, and SJIS)') {|enc| config["outencoding"] = enc }
52
+ opts.on('--yaml=YAML', 'Read configurations from YAML file.') {|yaml| config["yaml"] = yaml}
76
53
  opts.on('-c', '--check', 'Check manuscript') { check_only = true }
77
54
  opts.on('--level=LVL', 'Section level to append number.') {|lvl| config["secnolevel"] = lvl.to_i }
78
55
  opts.on('--toclevel=LVL', 'Section level to append number.') {|lvl| config["toclevel"] = lvl.to_i }
@@ -80,13 +57,7 @@ def _main
80
57
  opts.on('--structuredxml', 'Produce XML with structured sections. (idgxml)') { config["structuredxml"] = true }
81
58
  opts.on('--table=WIDTH', 'Default table width. (idgxml)') {|tbl| config["tableopt"] = tbl }
82
59
  opts.on('--listinfo', 'Append listinfo tag to lists to indicate begin/end. (idgxml)') { config["listinfo"] = true }
83
- opts.on('--chapref="before,middle,after"', 'Chapref decoration.') {|cdec| config["chapref"] = cdec }
84
- opts.on('--subdirmode', 'Use chapter/id.ext path style to find images. (deprecated)') do
85
- STDERR.puts "Warning: --subdirmode is deprecated. Images are automatically detected."
86
- end
87
- opts.on('--singledirmode', 'Use id.ext path style to find images. (deprecated)') do
88
- STDERR.puts "Warning: --singledirmode is deprecated. Images are automatically detected."
89
- end
60
+ opts.on('--chapref="before,middle,after"', 'Chapref decoration. (idgxml)') {|cdec| config["chapref"] = cdec }
90
61
  opts.on('--chapterlink', 'make chapref hyperlink') { config["chapterlink"] = true }
91
62
  opts.on('--stylesheet=file', 'Stylesheet file for HTML (comma separated)') {|files| config["stylesheet"] = files.split(/\s*,\s*/) }
92
63
  opts.on('--mathml', 'Use MathML for TeX equation in HTML') do
@@ -100,18 +71,12 @@ def _main
100
71
  v = v.to_i
101
72
  config["epubversion"] = v if v == 2 || v == 3
102
73
  end
103
- opts.on('--hdnumberingmode', 'Output numbering headlines. (deprecated)') { config["hdnumberingmode"] = true }
104
- opts.on('--deprecated-blocklines', 'Disable paragrahs in block tags. Treat physical line as a paragraph. (deprecated)') { config["deprecated-blocklines"] = true }
105
74
  opts.on('--target=FMT', 'Target format.') {|fmt| target = fmt } unless target
106
75
  opts.on('--footnotetext',
107
76
  'Use footnotetext and footnotemark instead of footnote (latex)') {
108
77
  config["footnotetext"] = true
109
78
  }
110
79
  opts.on('--draft', 'use draft mode(inline comment)') { config["draft"] = true }
111
- opts.on('-a', '--all', 'Compile all chapters.') do
112
- mode = :dir
113
- basedir = nil
114
- end
115
80
  opts.on('--directory=DIR', 'Compile all chapters in DIR.') do |path|
116
81
  mode = :dir
117
82
  basedir = path
@@ -143,8 +108,26 @@ def _main
143
108
  end
144
109
 
145
110
  begin
111
+ loader = ReVIEW::YAMLLoader.new
112
+ if config["yaml"]
113
+ config.deep_merge!(loader.load_file(config["yaml"]))
114
+ else
115
+ if File.exist?(DEFAULT_CONFIG_FILENAME)
116
+ config.deep_merge!(loader.load_file(DEFAULT_CONFIG_FILENAME))
117
+ end
118
+ end
119
+
146
120
  config["builder"] = target
147
121
  ReVIEW::I18n.setup(config["language"])
122
+ begin
123
+ config.check_version(ReVIEW::VERSION)
124
+ rescue ReVIEW::ConfigError => e
125
+ warn e.message
126
+ end
127
+
128
+ if ARGV.blank?
129
+ mode = :dir
130
+ end
148
131
 
149
132
  case mode
150
133
  when :files
@@ -173,12 +156,12 @@ def _main
173
156
  compiler = ReVIEW::Compiler.new(load_strategy_class(target, check_only))
174
157
  book.chapters.each do |chap|
175
158
  str = compiler.compile(chap)
176
- write "#{chap.name}#{compiler.strategy.extname}", str unless check_only
159
+ write "#{chap.name}#{compiler.strategy.extname}", str unless check_only
177
160
  end
178
161
  # PART
179
162
  book.parts_in_file.each do |part|
180
163
  str = compiler.compile(part)
181
- write "#{part.name}#{compiler.strategy.extname}", str unless check_only
164
+ write "#{part.name}#{compiler.strategy.extname}", str unless check_only
182
165
  end
183
166
  else
184
167
  raise "must not happen: #{mode}"