review 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +92 -73
  3. data/{doc/NEWS.ja.md → NEWS.ja.md} +60 -0
  4. data/{doc/NEWS.md → NEWS.md} +60 -0
  5. data/bin/review-compile +1 -1
  6. data/bin/review-epubmaker +2 -2
  7. data/bin/review-pdfmaker +2 -2
  8. data/debian/control +1 -1
  9. data/{ChangeLog → doc/ChangeLog-0.x_to_2.0} +0 -0
  10. data/doc/config.yml.sample +6 -6
  11. data/doc/format.ja.md +19 -1
  12. data/doc/format.md +28 -10
  13. data/doc/quickstart.ja.md +1 -1
  14. data/doc/quickstart.md +1 -1
  15. data/lib/epubmaker.rb +2 -1
  16. data/lib/epubmaker/content.rb +2 -1
  17. data/lib/epubmaker/epubcommon.rb +1 -0
  18. data/lib/epubmaker/epubv2.rb +2 -1
  19. data/lib/epubmaker/epubv3.rb +2 -1
  20. data/lib/epubmaker/producer.rb +2 -1
  21. data/lib/epubmaker/zip_exporter.rb +2 -2
  22. data/lib/review/book/base.rb +2 -2
  23. data/lib/review/book/index.rb +7 -3
  24. data/lib/review/builder.rb +15 -7
  25. data/lib/review/compiler.rb +4 -3
  26. data/lib/review/converter.rb +1 -1
  27. data/lib/review/epubmaker.rb +2 -2
  28. data/lib/review/ewbbuilder.rb +2 -1
  29. data/lib/review/htmlbuilder.rb +59 -9
  30. data/lib/review/idgxmlbuilder.rb +13 -5
  31. data/lib/review/latexbuilder.rb +44 -17
  32. data/lib/review/latexutils.rb +2 -2
  33. data/lib/review/makerhelper.rb +2 -2
  34. data/lib/review/markdownbuilder.rb +12 -8
  35. data/lib/review/pdfmaker.rb +1 -2
  36. data/lib/review/rstbuilder.rb +10 -4
  37. data/lib/review/sec_counter.rb +9 -3
  38. data/lib/review/topbuilder.rb +47 -5
  39. data/lib/review/version.rb +1 -1
  40. data/lib/review/webmaker.rb +1 -2
  41. data/review.gemspec +1 -1
  42. data/templates/latex/layout.tex.erb +5 -0
  43. data/test/assets/test_template.tex +5 -0
  44. data/test/test_book.rb +2 -1
  45. data/test/test_book_chapter.rb +1 -3
  46. data/test/test_epub3maker.rb +0 -2
  47. data/test/test_htmlbuilder.rb +72 -3
  48. data/test/test_idgxmlbuilder.rb +11 -2
  49. data/test/test_index.rb +0 -1
  50. data/test/test_latexbuilder.rb +96 -2
  51. data/test/test_pdfmaker.rb +0 -1
  52. data/test/test_rstbuilder.rb +5 -0
  53. data/test/test_topbuilder.rb +26 -1
  54. metadata +6 -7
File without changes
@@ -137,27 +137,27 @@ secnolevel: 2
137
137
  # 表紙の後に大扉ページを作成するか。省略した場合はnull (作成しない)
138
138
  # titlepage: null
139
139
  #
140
- # 自動生成される大扉ページを上書きするファイル。ファイル名を指定すると大扉として入る
140
+ # 自動生成される大扉ページを上書きするファイル。ファイル名を指定すると大扉として入る (PDFMaker向けにはLaTeXソース断片、EPUBMaker向けにはHTMLファイル)
141
141
  # titlefile: null
142
142
  #
143
- # 原書大扉ページにするHTMLファイル。ファイル名を指定すると原書大扉として入る
143
+ # 原書大扉ページにするHTMLファイル。ファイル名を指定すると原書大扉として入る (PDFMaker向けにはLaTeXソース断片、EPUBMaker向けにはHTMLファイル)
144
144
  # originaltitlefile: null
145
145
  #
146
- # 権利表記ページファイル。ファイル名を指定すると権利表記として入る
146
+ # 権利表記ページファイル。ファイル名を指定すると権利表記として入る (PDFMaker向けにはLaTeXソース断片、EPUBMaker向けにはHTMLファイル)
147
147
  # creditfile: null
148
148
 
149
149
  # 奥付を作成するか。デフォルトでは作成されない。trueを指定するとデフォルトの奥付、ファイル名を指定するとそれがcolophon.htmlとしてコピーされる
150
150
  # colophon: null
151
151
 
152
- # 裏表紙ファイル (画像はcoversまたはimagesに配置する)。ファイル名を指定すると裏表紙として入る
152
+ # 裏表紙データファイル (PDFMaker向けにはLaTeXソース断片、EPUBMaker向けにはHTMLファイル)
153
153
  # backcover: null
154
154
 
155
- # プロフィールページファイル。ファイル名を指定すると著者紹介として入る
155
+ # プロフィールページファイル (PDFMaker向けにはLaTeXソース断片、EPUBMaker向けにはHTMLファイル)。ファイル名を指定すると著者紹介として入る
156
156
  # profile: null
157
157
  # プロフィールページの目次上の見出し
158
158
  # profiletitle: 著者紹介
159
159
 
160
- # 広告ファイル。ファイル名を指定すると広告として入る
160
+ # 広告ファイル。ファイル名を指定すると広告として入る (PDFMaker向けにはLaTeXソース断片、EPUBMaker向けにはHTMLファイル)
161
161
  # advfile: null
162
162
 
163
163
  # 取り込む画像が格納されているディレクトリ。省略した場合は以下
@@ -297,6 +297,8 @@ V1 --> V6 --|
297
297
 
298
298
  また、本文中で「図 X.X を見てください」のように図を指定する場合は、インライン命令 `@<img>` を使います。`//image` で指定した識別子を用いて「`@<img>{unixhistory}`」のように記述します(`//image` と `@<img>` でつづりが違うので注意してください)。
299
299
 
300
+ 他章の図を参照するには、リストと同様に「章ID」を指定します。たとえば `@<img>{advanced|unixhistory}`(`advanced.re` ファイルの章にある図 `unixhistory` を参照する)と記述します。
301
+
300
302
  ### 画像ファイルの探索
301
303
 
302
304
  図として貼り込む画像ファイルは、次の順序で探索され、最初に発見されたものが利用されます。
@@ -356,7 +358,7 @@ plot sin(x)
356
358
 
357
359
  表は `//table[識別子][キャプション]{ 〜 //}` という記法です。ヘッダと内容を分ける罫線は「`------------`」(12個以上の連続する `-` または `=`)を使います。
358
360
 
359
- 表の各列のセル間は「1つ」のタブで区切ります。また、列の先頭セルの「`.`」は削除されるので、先頭文字が「`.`」の場合は「`.`」をもう1つ余計に付けてください。たとえば「`.`」という内容のセルは「`..`」と書きます。
361
+ 表の各列のセル間は「1つ」のタブで区切ります。空白のセルには「`.`」と書きます。セルの先頭の「`.`」は削除されるので、先頭文字が「`.`」の場合は「`.`」をもう1つ余計に付けてください。たとえば「`.`」という内容のセルは「`..`」と書きます。
360
362
 
361
363
  例:
362
364
 
@@ -380,6 +382,22 @@ DISPLAY X Window Systemのデフォルトディスプレイ
380
382
 
381
383
  表のセル内でもインライン命令は有効です。
382
384
 
385
+ 「採番なし、キャプションなし」の表は、`//table` ブロック命令に引数を付けずに記述します。
386
+
387
+ ```
388
+ //table{
389
+
390
+ //}
391
+ ```
392
+
393
+ 「採番なし、キャプションあり」の表を作りたいときには、`//emtable` ブロック命令を利用します。
394
+
395
+ ```
396
+ //emtable[キャプション]{
397
+
398
+ //}
399
+ ```
400
+
383
401
  ### 表の列幅
384
402
 
385
403
  LaTeX および IDGXML のビルダを利用する場合、表の各列の幅を `//tsize` ブロック命令で指定できます。
@@ -340,6 +340,8 @@ The third option is used to define the scale of images. `scale=X` is scaling fo
340
340
  When you want to refer images such as "see figure 1.", you can use
341
341
  inline reference markup like `@<img>{unixhistory}`.
342
342
 
343
+ When you refer a image in the other chapter, you can use the same way as a list reference. To refer a image `unixhistory` in `advanced.re`, use `@<img>{advanced|unixhistory}`.
344
+
343
345
  When you want to use images in paragraph or other inline context, you can use `@<icon>`.
344
346
 
345
347
  ### Finding image pathes
@@ -399,7 +401,7 @@ Before using these tools, you should installed them.
399
401
  The markup of table is `//table[ID][caption]{ ... //}`
400
402
  You can separate header and content with `------------`.
401
403
 
402
- The columns are splitted by TAB character. When the first character in the column is `.`, the character is removed. If you want to write `.` at the first, you should write `..`.
404
+ The columns are splitted by TAB character. Write `.` to blank cells. When the first character in the cell is `.`, the character is removed. If you want to write `.` at the first, you should write `..`.
403
405
 
404
406
  When you want to use an empty column, you write `.`.
405
407
 
@@ -425,6 +427,22 @@ When you want to write "see table X", you can write `@<table>{envvars}`.
425
427
 
426
428
  You can use inline markup in the tables.
427
429
 
430
+ `//table` without arguments creates a table without numbering and captioning.
431
+
432
+ ```
433
+ //table{
434
+ ...
435
+ //}
436
+ ```
437
+
438
+ To create a table without numbering but with captioning, use `//emtable`.
439
+
440
+ ```
441
+ //emtable[caption]{
442
+ ...
443
+ //}
444
+ ```
445
+
428
446
  ### Column width of table
429
447
  When using LaTeX or IDGXML builder, you can specify each column width of the table with `//tsize` block command.
430
448
 
@@ -454,7 +472,7 @@ The rule of finding images is same as image command.
454
472
 
455
473
  ## Quoting Text
456
474
 
457
- You can use `//quote{ //}` as quotations.
475
+ You can use `//quote{ ... //}` as quotations.
458
476
 
459
477
  Usage:
460
478
 
@@ -470,14 +488,14 @@ You can use inline markup in quotations.
470
488
 
471
489
  Some block commands are used for short column.
472
490
 
473
- * `//note[caption]{ //}`
474
- * `//memo[caption]{ //}`
475
- * `//tip[caption]{ //}`
476
- * `//info[caption]{ //}`
477
- * `//warning[caption]{ //}`
478
- * `//important[caption]{ //}`
479
- * `//caution[caption]{ //}`
480
- * `//notice[caption]{ //}`
491
+ * `//note[caption]{ ... //}`
492
+ * `//memo[caption]{ ... //}`
493
+ * `//tip[caption]{ ... //}`
494
+ * `//info[caption]{ ... //}`
495
+ * `//warning[caption]{ ... //}`
496
+ * `//important[caption]{ ... //}`
497
+ * `//caution[caption]{ ... //}`
498
+ * `//notice[caption]{ ... //}`
481
499
 
482
500
  `[caption]` is optional.
483
501
 
@@ -47,7 +47,7 @@ Re:VIEW は GitHub で開発されており、バージョン管理ツールの
47
47
  初めて取得するときには、次のようにします (コピーを作っています)。
48
48
 
49
49
  ```bash
50
- $ git clone git://github.com/kmuto/review.git
50
+ $ git clone https://github.com/kmuto/review.git
51
51
  ```
52
52
 
53
53
  review というディレクトリに展開されるので、review/bin にパスを通すようにしておいてください。
@@ -46,7 +46,7 @@ $ gem install review
46
46
  You can get latest Re:VIEW sources from GitHub.
47
47
 
48
48
  ```bash
49
- $ git clone git://github.com/kmuto/review.git
49
+ $ git clone https://github.com/kmuto/review.git
50
50
  ```
51
51
 
52
52
  You can use Re:VIEW to add `review/bin` directory to `$PATH` variable.
@@ -1,7 +1,8 @@
1
1
  # encoding: utf-8
2
+
2
3
  # = epubmaker.rb -- EPUB production set.
3
4
  #
4
- # Copyright (c) 2010-2013 Kenshi Muto
5
+ # Copyright (c) 2010-2017 Kenshi Muto
5
6
  #
6
7
  # This program is free software.
7
8
  # You can distribute or modify this program under the terms of
@@ -1,7 +1,8 @@
1
1
  # encoding: utf-8
2
+
2
3
  # = content.rb -- Content object for EPUBMaker.
3
4
  #
4
- # Copyright (c) 2010-2014 Kenshi Muto
5
+ # Copyright (c) 2010-2017 Kenshi Muto
5
6
  #
6
7
  # This program is free software.
7
8
  # You can distribute or modify this program under the terms of
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  # = epubcommon.rb -- super class for EPUBv2 and EPUBv3
3
4
  #
4
5
  # Copyright (c) 2010-2017 Kenshi Muto and Masayoshi Takahashi
@@ -1,7 +1,8 @@
1
1
  # encoding: utf-8
2
+
2
3
  # = epubv2.rb -- EPUB version 2 producer.
3
4
  #
4
- # Copyright (c) 2010-2016 Kenshi Muto and Masayoshi Takahashi
5
+ # Copyright (c) 2010-2017 Kenshi Muto and Masayoshi Takahashi
5
6
  #
6
7
  # This program is free software.
7
8
  # You can distribute or modify this program under the terms of
@@ -1,7 +1,8 @@
1
1
  # encoding: utf-8
2
+
2
3
  # = epubv3.rb -- EPUB version 3 producer.
3
4
  #
4
- # Copyright (c) 2010-2016 Kenshi Muto
5
+ # Copyright (c) 2010-2017 Kenshi Muto
5
6
  #
6
7
  # This program is free software.
7
8
  # You can distribute or modify this program under the terms of
@@ -1,7 +1,8 @@
1
1
  # encoding: utf-8
2
+
2
3
  # = producer.rb -- EPUB producer.
3
4
  #
4
- # Copyright (c) 2010-2016 Kenshi Muto
5
+ # Copyright (c) 2010-2017 Kenshi Muto
5
6
  #
6
7
  # This program is free software.
7
8
  # You can distribute or modify this program under the terms of
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
- #
3
- # Copyright (c) 2010-2016 Kenshi Muto and Masayoshi Takahashi
2
+
3
+ # Copyright (c) 2010-2017 Kenshi Muto and Masayoshi Takahashi
4
4
  #
5
5
  # This program is free software.
6
6
  # You can distribute or modify this program under the terms of
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Copyright (c) 2002-2008 Minero Aoki
3
- # 2009-2016 Minero Aoki, Kenshi Muto
3
+ # 2009-2017 Minero Aoki, Kenshi Muto
4
4
  #
5
5
  # This program is free software.
6
6
  # You can distribute or modify this program under the terms of
@@ -390,7 +390,7 @@ module ReVIEW
390
390
  def read_FILE(filename)
391
391
  if !@warn_old_files[filename]
392
392
  @warn_old_files[filename] = true
393
- if !caller().any?{|item| item =~ %r|/review/test/test_|}
393
+ if caller().none? {|item| item =~ %r|/review/test/test_|}
394
394
  warn "!!! #{filename} is obsoleted. please use catalog.yml."
395
395
  end
396
396
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- #
2
+
3
3
  # Copyright (c) 2002-2007 Minero Aoki
4
4
  # 2008-2017 Minero Aoki, Kenshi Muto
5
5
  #
@@ -151,8 +151,12 @@ module ReVIEW
151
151
  # ex. ["//image", "id", "", "caption"]
152
152
  elements = line.split(/\[(.*?)\]/)
153
153
  if elements[1].present?
154
- items.push item_class().new(elements[1], seq, elements[3])
155
- seq += 1
154
+ if line =~ %r{^//imgtable}
155
+ items.push item_class().new(elements[1], 0, elements[3])
156
+ else ## %r<^//(image|graph)>
157
+ items.push item_class().new(elements[1], seq, elements[3])
158
+ seq += 1
159
+ end
156
160
  if elements[1] == ""
157
161
  warn "warning: no ID of #{item_type()} in #{line}"
158
162
  end
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
- #
3
- # Copyright (c) 2002-2016 Minero Aoki, Kenshi Muto
2
+
3
+ # Copyright (c) 2002-2017 Minero Aoki, Kenshi Muto
4
4
  #
5
5
  # This program is free software.
6
6
  # You can distribute or modify this program under the terms of
@@ -142,7 +142,7 @@ module ReVIEW
142
142
  sepidx ||= idx
143
143
  next
144
144
  end
145
- rows.push line.strip.split(/\t+/).map {|s| s.sub(/\A\./, '') }
145
+ rows.push(line.strip.split(/\t+/).map {|s| s.sub(/\A\./, '') })
146
146
  end
147
147
  rows = adjust_n_cols(rows)
148
148
 
@@ -155,15 +155,15 @@ module ReVIEW
155
155
  table_begin rows.first.size
156
156
  if sepidx
157
157
  sepidx.times do
158
- tr rows.shift.map {|s| th(s) }
158
+ tr(rows.shift.map {|s| th(s) })
159
159
  end
160
160
  rows.each do |cols|
161
- tr cols.map {|s| td(s) }
161
+ tr(cols.map {|s| td(s) })
162
162
  end
163
163
  else
164
164
  rows.each do |cols|
165
165
  h, *cs = *cols
166
- tr [th(h)] + cs.map {|s| td(s) }
166
+ tr([th(h)] + cs.map {|s| td(s) })
167
167
  end
168
168
  end
169
169
  table_end
@@ -183,6 +183,10 @@ module ReVIEW
183
183
  end
184
184
  private :adjust_n_cols
185
185
 
186
+ def emtable(lines, caption = nil)
187
+ table(lines, nil, caption)
188
+ end
189
+
186
190
  #def footnote(id, str)
187
191
  # @footnotes.push [id, str]
188
192
  #end
@@ -394,7 +398,11 @@ module ReVIEW
394
398
 
395
399
  def get_chap(chapter = @chapter)
396
400
  if @book.config["secnolevel"] > 0 && !chapter.number.nil? && !chapter.number.to_s.empty?
397
- return chapter.format_number(nil)
401
+ if chapter.is_a? ReVIEW::Book::Part
402
+ return I18n.t('part_short', chapter.number)
403
+ else
404
+ return chapter.format_number(nil)
405
+ end
398
406
  end
399
407
  return nil
400
408
  end
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
- #
2
+
3
3
  # Copyright (c) 2002-2007 Minero Aoki
4
- # Copyright (c) 2009-2016 Minero Aoki, Kenshi Muto
4
+ # Copyright (c) 2009-2017 Minero Aoki, Kenshi Muto
5
5
  #
6
6
  # This program is free software.
7
7
  # You can distribute or modify this program under the terms of
@@ -135,6 +135,7 @@ module ReVIEW
135
135
  defblock :cmd, 0..1
136
136
  defblock :table, 0..2
137
137
  defblock :imgtable, 0..2
138
+ defblock :emtable, 0..1
138
139
  defblock :quote, 0
139
140
  defblock :image, 2..3, true
140
141
  defblock :source, 0..2
@@ -415,7 +416,7 @@ module ReVIEW
415
416
  @strategy.dl_begin
416
417
  while /\A\s*:/ =~ f.peek
417
418
  @strategy.dt text(f.gets.sub(/\A\s*:/, '').strip)
418
- @strategy.dd f.break(/\A(\S|\s*:)/).map {|line| text(line.strip) }
419
+ @strategy.dd(f.break(/\A(\S|\s*:|\s+\d+\.\s|\s+\*\s)/).map {|line| text(line.strip) })
419
420
  f.skip_blank_lines
420
421
  f.skip_comment_lines
421
422
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- #
2
+
3
3
  # This program is free software.
4
4
  # You can distribute or modify this program under the terms of
5
5
  # the GNU LGPL, Lesser General Public License version 2.1.
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
- #
3
- # Copyright (c) 2010-2016 Kenshi Muto and Masayoshi Takahashi
2
+
3
+ # Copyright (c) 2010-2017 Kenshi Muto and Masayoshi Takahashi
4
4
  #
5
5
  # This program is free software.
6
6
  # You can distribute or modify this program under the terms of
@@ -1,4 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
+
2
3
  # $Id: ewbbuilder.rb 2195 2005-11-13 21:52:18Z aamine $
3
4
 
4
5
  require 'review/builder'
@@ -112,7 +113,7 @@ module ReVIEW
112
113
  buf = []
113
114
  while line = f.gets
114
115
  break if %r[\A//\}] === line
115
- buf.push line.strip.split(/\t+/).map {|s| s == '.' ? '' : s }
116
+ buf.push(line.strip.split(/\t+/).map {|s| s == '.' ? '' : s })
116
117
  end
117
118
  table_type = 'tabm'
118
119
  output.puts "//#{table_type}[" + spec + ']{'
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
- #
2
+
3
3
  # Copyright (c) 2002-2007 Minero Aoki
4
- # 2008-2016 Minero Aoki, Kenshi Muto, Masayoshi Takahashi,
4
+ # 2008-2017 Minero Aoki, Kenshi Muto, Masayoshi Takahashi,
5
5
  # KADO Masanori
6
6
  #
7
7
  # This program is free software.
@@ -14,6 +14,8 @@ require 'review/htmlutils'
14
14
  require 'review/template'
15
15
  require 'review/textutils'
16
16
  require 'review/webtocprinter'
17
+ require 'digest'
18
+ require 'tmpdir'
17
19
 
18
20
  module ReVIEW
19
21
 
@@ -572,6 +574,14 @@ module ReVIEW
572
574
  require 'math_ml/symbol/character_reference'
573
575
  p = MathML::LaTeX::Parser.new(:symbol=>MathML::Symbol::CharacterReference)
574
576
  puts p.parse(unescape_html(lines.join("\n")), true)
577
+ elsif @book.config["imgmath"]
578
+ puts %Q[<div class="equation">]
579
+ math_str = "\\begin{equation*}\n" + unescape_html(lines.join("\n")) + "\n\\end{equation*}\n"
580
+ key = Digest::SHA256.hexdigest(math_str)
581
+ img_path = "./images/_gen_#{key}.png"
582
+ make_math_image(math_str, img_path)
583
+ puts %Q[<img src="#{img_path}" />]
584
+ puts '</div>'
575
585
  else
576
586
  print '<pre>'
577
587
  puts "#{lines.join("\n")}"
@@ -642,7 +652,7 @@ module ReVIEW
642
652
  sepidx ||= idx
643
653
  next
644
654
  end
645
- rows.push line.strip.split(/\t+/).map {|s| s.sub(/\A\./, '') }
655
+ rows.push(line.strip.split(/\t+/).map {|s| s.sub(/\A\./, '') })
646
656
  end
647
657
  rows = adjust_n_cols(rows)
648
658
 
@@ -660,15 +670,15 @@ module ReVIEW
660
670
  return if rows.empty?
661
671
  if sepidx
662
672
  sepidx.times do
663
- tr rows.shift.map {|s| th(s) }
673
+ tr (rows.shift.map {|s| th(s) })
664
674
  end
665
675
  rows.each do |cols|
666
- tr cols.map {|s| td(s) }
676
+ tr (cols.map {|s| td(s) })
667
677
  end
668
678
  else
669
679
  rows.each do |cols|
670
680
  h, *cs = *cols
671
- tr [th(h)] + cs.map {|s| td(s) }
681
+ tr ([th(h)] + cs.map {|s| td(s) })
672
682
  end
673
683
  end
674
684
  table_end
@@ -676,10 +686,14 @@ module ReVIEW
676
686
  end
677
687
 
678
688
  def table_header(id, caption)
679
- if get_chap.nil?
680
- puts %Q[<p class="caption">#{I18n.t("table")}#{I18n.t("format_number_header_without_chapter", [@chapter.table(id).number])}#{I18n.t("caption_prefix")}#{compile_inline(caption)}</p>]
689
+ if id.nil?
690
+ puts %Q[<p class="caption">#{compile_inline(caption)}</p>]
681
691
  else
682
- puts %Q[<p class="caption">#{I18n.t("table")}#{I18n.t("format_number_header", [get_chap, @chapter.table(id).number])}#{I18n.t("caption_prefix")}#{compile_inline(caption)}</p>]
692
+ if get_chap.nil?
693
+ puts %Q[<p class="caption">#{I18n.t("table")}#{I18n.t("format_number_header_without_chapter", [@chapter.table(id).number])}#{I18n.t("caption_prefix")}#{compile_inline(caption)}</p>]
694
+ else
695
+ puts %Q[<p class="caption">#{I18n.t("table")}#{I18n.t("format_number_header", [get_chap, @chapter.table(id).number])}#{I18n.t("caption_prefix")}#{compile_inline(caption)}</p>]
696
+ end
683
697
  end
684
698
  end
685
699
 
@@ -727,6 +741,10 @@ module ReVIEW
727
741
  puts %Q[<img src="#{@chapter.image(id).path.sub(/\A\.\//, "")}" alt="#{escape_html(compile_inline(caption))}"#{metrics} />]
728
742
  end
729
743
 
744
+ def emtable(lines, caption = nil)
745
+ table(lines, nil, caption)
746
+ end
747
+
730
748
  def comment(lines, comment = nil)
731
749
  lines ||= []
732
750
  lines.unshift comment unless comment.blank?
@@ -920,6 +938,12 @@ module ReVIEW
920
938
  require 'math_ml/symbol/character_reference'
921
939
  parser = MathML::LaTeX::Parser.new(:symbol => MathML::Symbol::CharacterReference)
922
940
  %Q[<span class="equation">#{parser.parse(str, nil)}</span>]
941
+ elsif @book.config["imgmath"]
942
+ math_str = "$" + str + "$"
943
+ key = Digest::SHA256.hexdigest(str)
944
+ img_path = "./images/_gen_#{key}.png"
945
+ make_math_image(math_str, img_path)
946
+ %Q[<span class="equation"><img src="#{img_path}" /></span>]
923
947
  else
924
948
  %Q[<span class="equation">#{escape_html(str)}</span>]
925
949
  end
@@ -1174,6 +1198,32 @@ module ReVIEW
1174
1198
  def olnum(num)
1175
1199
  @ol_num = num.to_i
1176
1200
  end
1201
+
1202
+ def make_math_image(str, path, fontsize=12)
1203
+ fontsize2 = (fontsize*1.2).round.to_i
1204
+ texsrc = <<-EOB
1205
+ \\documentclass[12pt]{article}
1206
+ \\usepackage[utf8]{inputenc}
1207
+ \\usepackage{amsmath}
1208
+ \\usepackage{amsthm}
1209
+ \\usepackage{amssymb}
1210
+ \\usepackage{amsfonts}
1211
+ \\usepackage{anyfontsize}
1212
+ \\usepackage{bm}
1213
+ \\pagestyle{empty}
1214
+
1215
+ \\begin{document}
1216
+ \\fontsize{#{fontsize}}{#{fontsize2}}\\selectfont #{str}
1217
+ \\end{document}
1218
+ EOB
1219
+ Dir.mktmpdir do |tmpdir|
1220
+ tex_path = File.join(tmpdir, "tmpmath.tex")
1221
+ dvi_path = File.join(tmpdir, "tmpmath.dvi")
1222
+ File.write(tex_path, texsrc)
1223
+ system("latex --interaction=nonstopmode --output-directory=#{tmpdir} #{tex_path} && dvipng -T tight -z9 -o #{path} #{dvi_path}")
1224
+ end
1225
+ end
1226
+
1177
1227
  end
1178
1228
 
1179
1229
  end # module ReVIEW