review 2.5.0 → 3.0.0.preview1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +28 -10
  3. data/.travis.yml +11 -2
  4. data/NEWS.ja.md +89 -17
  5. data/NEWS.md +92 -0
  6. data/README.md +1 -1
  7. data/Rakefile +0 -13
  8. data/bin/review-catalog-converter +83 -37
  9. data/bin/review-check +17 -5
  10. data/bin/review-compile +1 -1
  11. data/bin/review-index +6 -0
  12. data/bin/review-init +3 -155
  13. data/bin/review-preproc +0 -5
  14. data/bin/review-validate +21 -7
  15. data/bin/review-vol +13 -5
  16. data/doc/config.yml.sample +12 -7
  17. data/doc/config.yml.sample-simple +1 -1
  18. data/doc/format.ja.md +39 -3
  19. data/doc/format.md +39 -3
  20. data/doc/format_idg.ja.md +0 -4
  21. data/doc/pdfmaker.ja.md +1 -1
  22. data/doc/pdfmaker.md +1 -1
  23. data/doc/sample.css +7 -0
  24. data/lib/epubmaker/content.rb +31 -12
  25. data/lib/epubmaker/epubcommon.rb +10 -3
  26. data/lib/epubmaker/epubv2.rb +11 -3
  27. data/lib/epubmaker/epubv3.rb +11 -3
  28. data/lib/epubmaker/producer.rb +55 -20
  29. data/lib/review/book/base.rb +63 -48
  30. data/lib/review/book/chapter.rb +19 -7
  31. data/lib/review/book/compilable.rb +5 -20
  32. data/lib/review/book/image_finder.rb +10 -3
  33. data/lib/review/book/index.rb +30 -9
  34. data/lib/review/book/part.rb +9 -6
  35. data/lib/review/book.rb +0 -14
  36. data/lib/review/builder.rb +110 -18
  37. data/lib/review/catalog.rb +24 -4
  38. data/lib/review/compiler.rb +3 -1
  39. data/lib/review/configure.rb +43 -9
  40. data/lib/review/epubmaker/reviewheaderlistener.rb +57 -0
  41. data/lib/review/epubmaker.rb +129 -85
  42. data/lib/review/htmlbuilder.rb +76 -58
  43. data/lib/review/htmlutils.rb +20 -13
  44. data/lib/review/i18n.rb +6 -2
  45. data/lib/review/idgxmlbuilder.rb +52 -41
  46. data/lib/review/init.rb +194 -0
  47. data/lib/review/latexbuilder.rb +118 -34
  48. data/lib/review/latexutils.rb +5 -5
  49. data/lib/review/logger.rb +2 -1
  50. data/lib/review/makerhelper.rb +1 -1
  51. data/lib/review/markdownbuilder.rb +66 -6
  52. data/lib/review/md2inaobuilder.rb +2 -2
  53. data/lib/review/pdfmaker.rb +74 -22
  54. data/lib/review/plaintextbuilder.rb +8 -4
  55. data/lib/review/preprocessor.rb +14 -17
  56. data/lib/review/sec_counter.rb +8 -2
  57. data/lib/review/textmaker.rb +2 -2
  58. data/lib/review/textutils.rb +9 -2
  59. data/lib/review/tocparser.rb +7 -4
  60. data/lib/review/tocprinter.rb +3 -1
  61. data/lib/review/version.rb +1 -1
  62. data/lib/review/webmaker.rb +19 -7
  63. data/lib/review/webtocprinter.rb +8 -4
  64. data/review.gemspec +4 -3
  65. data/templates/latex/config.erb +84 -0
  66. data/templates/latex/layout.tex.erb +76 -361
  67. data/templates/latex/review-jlreq/README.md +22 -0
  68. data/templates/latex/review-jlreq/review-base.sty +178 -0
  69. data/templates/latex/review-jlreq/review-custom.sty +1 -0
  70. data/templates/latex/review-jlreq/review-jlreq.cls +141 -0
  71. data/templates/latex/review-jlreq/review-style.sty +149 -0
  72. data/templates/latex/review-jlreq/reviewmacro.sty +8 -0
  73. data/templates/latex/review-jsbook/jumoline.sty +310 -0
  74. data/templates/latex/review-jsbook/plistings.sty +326 -0
  75. data/templates/latex/review-jsbook/review-base.sty +405 -0
  76. data/templates/latex/review-jsbook/review-custom.sty +1 -0
  77. data/templates/latex/review-jsbook/review-style.sty +38 -0
  78. data/templates/latex/review-jsbook/reviewmacro.sty +8 -0
  79. data/templates/latex-compat2/layout.tex.erb +387 -0
  80. data/test/assets/test_template.tex +105 -235
  81. data/test/assets/test_template_backmatter.tex +133 -14
  82. data/test/book_test_helper.rb +1 -1
  83. data/test/run_test.rb +2 -0
  84. data/test/sample-book/src/Rakefile +11 -6
  85. data/test/sample-book/src/config.yml +2 -2
  86. data/test/sample-book/src/sty/reviewmacro.sty +1 -39
  87. data/test/sample-book/src/style.css +6 -0
  88. data/test/syntax-book/config.yml +1 -1
  89. data/test/test_book.rb +13 -16
  90. data/test/test_book_chapter.rb +4 -10
  91. data/test/test_book_part.rb +4 -3
  92. data/test/test_catalog.rb +15 -4
  93. data/test/test_helper.rb +2 -2
  94. data/test/test_htmlbuilder.rb +78 -10
  95. data/test/test_htmlutils.rb +12 -5
  96. data/test/test_idgxmlbuilder.rb +1 -1
  97. data/test/test_latexbuilder.rb +94 -49
  98. data/test/test_latexbuilder_v2.rb +1077 -0
  99. data/test/test_logger.rb +20 -0
  100. data/test/test_markdownbuilder.rb +10 -0
  101. data/test/test_pdfmaker.rb +6 -7
  102. data/test/test_plaintextbuilder.rb +1 -1
  103. data/test/test_review_ext.rb +0 -1
  104. data/test/test_rstbuilder.rb +1 -1
  105. data/test/test_topbuilder.rb +19 -7
  106. data/test/test_webtocprinter.rb +14 -14
  107. data/{test/sample-book/src/vendor → vendor}/jumoline/README +0 -0
  108. data/{test/sample-book/src/vendor → vendor}/jumoline/jumoline.dtx +0 -0
  109. data/{test/sample-book/src/vendor → vendor}/jumoline/jumoline.ins +0 -0
  110. data/{test/sample-book/src/vendor → vendor}/jumoline/lppl.txt +0 -0
  111. data/vendor/plistings/.gitignore +9 -0
  112. data/vendor/plistings/LICENSE +21 -0
  113. data/vendor/plistings/README.md +18 -0
  114. data/vendor/plistings/plistings.sty +326 -0
  115. data/vendor/plistings/test1.tex +174 -0
  116. data/vendor/plistings/test2.tex +54 -0
  117. metadata +48 -19
  118. data/lib/review/unfold.rb +0 -129
  119. data/test/CHAPS +0 -2
  120. data/test/bib.re +0 -13
  121. data/test/test.re +0 -43
@@ -52,7 +52,11 @@ module ReVIEW
52
52
  end
53
53
  return true unless @book.config['pdfmaker']['makeindex_mecab']
54
54
  begin
55
- require 'MeCab'
55
+ begin
56
+ require 'MeCab'
57
+ rescue LoadError
58
+ require 'mecab'
59
+ end
56
60
  require 'nkf'
57
61
  @index_mecab = MeCab::Tagger.new(@book.config['pdfmaker']['makeindex_mecab_opts'])
58
62
  rescue LoadError
@@ -150,8 +154,11 @@ module ReVIEW
150
154
  end
151
155
 
152
156
  def nodisp_begin(level, _label, caption)
153
- blank unless @output.pos == 0
154
- puts macro('clearpage') if @output.pos == 0
157
+ if @output.pos != 0
158
+ blank
159
+ else
160
+ puts macro('clearpage')
161
+ end
155
162
  puts macro('addcontentsline', 'toc', HEADLINE[level], compile_inline(caption))
156
163
  # FIXME: headings
157
164
  end
@@ -162,36 +169,62 @@ module ReVIEW
162
169
  def column_begin(level, label, caption)
163
170
  blank
164
171
  @doc_status[:column] = true
165
- puts "\\begin{reviewcolumn}\n"
172
+
173
+ target = nil
166
174
  if label
167
- puts "\\hypertarget{#{column_label(label)}}{}"
175
+ target = "\\hypertarget{#{column_label(label)}}{}"
168
176
  else
169
- puts "\\hypertarget{#{column_label(caption)}}{}"
177
+ target = "\\hypertarget{#{column_label(caption)}}{}"
170
178
  end
179
+
171
180
  @doc_status[:caption] = true
172
- puts macro('reviewcolumnhead', nil, compile_inline(caption))
181
+ if @book.config.check_version('2', exception: false)
182
+ puts '\\begin{reviewcolumn}'
183
+ puts target
184
+ puts macro('reviewcolumnhead', nil, compile_inline(caption))
185
+ else
186
+ # ver.3
187
+ print '\\begin{reviewcolumn}'
188
+ puts "[#{compile_inline(caption)}#{target}]"
189
+ end
173
190
  @doc_status[:caption] = nil
191
+
174
192
  if level <= @book.config['toclevel'].to_i
175
193
  puts "\\addcontentsline{toc}{#{HEADLINE[level]}}{#{compile_inline(caption)}}"
176
194
  end
177
195
  end
178
196
 
179
197
  def column_end(_level)
180
- puts "\\end{reviewcolumn}\n"
198
+ puts '\\end{reviewcolumn}'
181
199
  blank
182
200
  @doc_status[:column] = nil
183
201
  end
184
202
 
185
- def captionblock(_type, lines, caption)
186
- puts "\\begin{reviewminicolumn}\n"
203
+ def captionblock(type, lines, caption)
204
+ if @book.config.check_version('2', exception: false)
205
+ type = 'minicolumn'
206
+ end
207
+
208
+ print "\\begin{review#{type}}"
209
+
187
210
  @doc_status[:caption] = true
188
- puts "\\reviewminicolumntitle{#{compile_inline(caption)}}\n" if caption.present?
211
+ if @book.config.check_version('2', exception: false)
212
+ puts
213
+ if caption.present?
214
+ puts "\\reviewminicolumntitle{#{compile_inline(caption)}}"
215
+ end
216
+ else
217
+ if caption.present?
218
+ print "[#{compile_inline(caption)}]"
219
+ end
220
+ puts
221
+ end
189
222
 
190
223
  @doc_status[:caption] = nil
191
224
  blocked_lines = split_paragraph(lines)
192
225
  puts blocked_lines.join("\n\n")
193
226
 
194
- puts "\\end{reviewminicolumn}\n"
227
+ puts "\\end{review#{type}}"
195
228
  end
196
229
 
197
230
  def box(lines, caption = nil)
@@ -332,6 +365,9 @@ module ReVIEW
332
365
 
333
366
  def common_code_block(id, lines, command, caption, _lang)
334
367
  @doc_status[:caption] = true
368
+ unless @book.config.check_version('2', exception: false)
369
+ puts '\\begin{reviewlistblock}'
370
+ end
335
371
  if caption.present?
336
372
  if command =~ /emlist/ || command =~ /cmd/ || command =~ /source/
337
373
  puts macro(command + 'caption', compile_inline(caption))
@@ -355,14 +391,17 @@ module ReVIEW
355
391
  puts macro('begin', command)
356
392
  print body
357
393
  puts macro('end', command)
394
+ unless @book.config.check_version('2', exception: false)
395
+ puts '\\end{reviewlistblock}'
396
+ end
358
397
  blank
359
398
  end
360
399
 
361
400
  def common_code_block_lst(_id, lines, command, title, caption, lang, first_line_num: 1)
362
- if title == 'title' && caption.blank?
401
+ if title == 'title' && caption.blank? && @book.config.check_version('2', exception: false)
363
402
  print '\vspace{-1.5em}'
364
403
  end
365
- body = lines.inject('') { |i, j| i + detab(unescape_latex(j)) + "\n" }
404
+ body = lines.inject('') { |i, j| i + detab(unescape(j)) + "\n" }
366
405
  args = make_code_block_args(title, caption, lang, first_line_num: first_line_num)
367
406
  puts %Q(\\begin{#{command}}[#{args}])
368
407
  print body
@@ -372,7 +411,7 @@ module ReVIEW
372
411
 
373
412
  def make_code_block_args(title, caption, lang, first_line_num: 1)
374
413
  caption_str = compile_inline((caption || ''))
375
- if title == 'title' && caption_str == ''
414
+ if title == 'title' && caption_str == '' && @book.config.check_version('2', exception: false)
376
415
  caption_str = '\relax' ## dummy charactor to remove lstname
377
416
  end
378
417
  lexer = if @book.config['highlight'] && @book.config['highlight']['lang']
@@ -381,9 +420,14 @@ module ReVIEW
381
420
  ''
382
421
  end
383
422
  lexer = lang if lang.present?
384
- args = %Q(#{title}={#{caption_str}},language={#{lexer}})
423
+ args = "language={#{lexer}}"
424
+ if title == 'title' && caption_str == ''
425
+ # ignore
426
+ else
427
+ args = "#{title}={#{caption_str}}," + args
428
+ end
385
429
  if first_line_num != 1
386
- args += ",firstnumber=#{first_line_num}"
430
+ args << ",firstnumber=#{first_line_num}"
387
431
  end
388
432
  args
389
433
  end
@@ -500,7 +544,10 @@ module ReVIEW
500
544
  end
501
545
 
502
546
  @doc_status[:caption] = true
503
- puts macro('reviewindepimagecaption', %Q(#{I18n.t('numberless_image')}#{I18n.t('caption_prefix')}#{compile_inline(caption)})) if caption.present?
547
+ if caption.present?
548
+ puts macro('reviewindepimagecaption',
549
+ %Q(#{I18n.t('numberless_image')}#{I18n.t('caption_prefix')}#{compile_inline(caption)}))
550
+ end
504
551
  @doc_status[:caption] = nil
505
552
 
506
553
  if @chapter.image(id).path
@@ -527,12 +574,12 @@ module ReVIEW
527
574
  rows = adjust_n_cols(rows)
528
575
 
529
576
  begin
530
- table_header id, caption if caption.present?
577
+ table_header(id, caption) if caption.present?
531
578
  rescue KeyError
532
579
  error "no such table: #{id}"
533
580
  end
534
581
  return if rows.empty?
535
- table_begin rows.first.size
582
+ table_begin(rows.first.size)
536
583
  if sepidx
537
584
  sepidx.times do
538
585
  tr(rows.shift.map { |s| th(s) })
@@ -682,7 +729,7 @@ module ReVIEW
682
729
  blank
683
730
  puts macro('begin', 'equation*')
684
731
  lines.each do |line|
685
- puts unescape_latex(line)
732
+ puts unescape(line)
686
733
  end
687
734
  puts macro('end', 'equation*')
688
735
  blank
@@ -834,12 +881,16 @@ module ReVIEW
834
881
  end
835
882
 
836
883
  def compile_ruby(base, ruby)
837
- macro('ruby', escape(base), escape(ruby))
884
+ macro('ruby', escape(base), escape(ruby).gsub('\\textbar{}', '|'))
838
885
  end
839
886
 
840
887
  # math
841
888
  def inline_m(str)
842
- " $#{str}$ "
889
+ if @book.config.check_version('2', exception: false)
890
+ " $#{str}$ "
891
+ else
892
+ "$#{str}$"
893
+ end
843
894
  end
844
895
 
845
896
  # hidden index
@@ -849,7 +900,11 @@ module ReVIEW
849
900
 
850
901
  # index -> italic
851
902
  def inline_i(str)
852
- macro('textit', escape(str))
903
+ if @book.config.check_version('2', exception: false)
904
+ macro('textit', escape(str))
905
+ else
906
+ macro('reviewit', escape(str))
907
+ end
853
908
  end
854
909
 
855
910
  # index
@@ -864,7 +919,11 @@ module ReVIEW
864
919
 
865
920
  # bold
866
921
  def inline_b(str)
867
- macro('textbf', escape(str))
922
+ if @book.config.check_version('2', exception: false)
923
+ macro('textbf', escape(str))
924
+ else
925
+ macro('reviewbold', escape(str))
926
+ end
868
927
  end
869
928
 
870
929
  # line break
@@ -879,7 +938,11 @@ module ReVIEW
879
938
 
880
939
  ## @<code> is same as @<tt>
881
940
  def inline_code(str)
882
- macro('texttt', escape(str))
941
+ if @book.config.check_version('2', exception: false)
942
+ macro('texttt', escape(str))
943
+ else
944
+ macro('reviewcode', escape(str))
945
+ end
883
946
  end
884
947
 
885
948
  def nofunc_text(str)
@@ -887,7 +950,11 @@ module ReVIEW
887
950
  end
888
951
 
889
952
  def inline_tt(str)
890
- macro('texttt', escape(str))
953
+ if @book.config.check_version('2', exception: false)
954
+ macro('texttt', escape(str))
955
+ else
956
+ macro('reviewtt', escape(str))
957
+ end
891
958
  end
892
959
 
893
960
  def inline_del(str)
@@ -895,11 +962,19 @@ module ReVIEW
895
962
  end
896
963
 
897
964
  def inline_tti(str)
898
- macro('texttt', macro('textit', escape(str)))
965
+ if @book.config.check_version('2', exception: false)
966
+ macro('texttt', macro('textit', escape(str)))
967
+ else
968
+ macro('reviewtti', escape(str))
969
+ end
899
970
  end
900
971
 
901
972
  def inline_ttb(str)
902
- macro('texttt', macro('textbf', escape(str)))
973
+ if @book.config.check_version('2', exception: false)
974
+ macro('texttt', macro('textbf', escape(str)))
975
+ else
976
+ macro('reviewttb', escape(str))
977
+ end
903
978
  end
904
979
 
905
980
  def inline_bib(id)
@@ -967,8 +1042,13 @@ module ReVIEW
967
1042
  end
968
1043
 
969
1044
  def inline_uchar(str)
970
- # with otf package
971
- macro('UTF', escape(str))
1045
+ if @texcompiler && @texcompiler.start_with?('platex')
1046
+ # with otf package
1047
+ macro('UTF', escape(str))
1048
+ else
1049
+ # passthrough
1050
+ [str.to_i(16)].pack('U')
1051
+ end
972
1052
  end
973
1053
 
974
1054
  def inline_comment(str)
@@ -983,6 +1063,10 @@ module ReVIEW
983
1063
  macro('rensuji', escape(str))
984
1064
  end
985
1065
 
1066
+ def inline_balloon(str)
1067
+ macro('reviewballoon', escape(str))
1068
+ end
1069
+
986
1070
  def bibpaper_header(id, caption)
987
1071
  puts "[#{@chapter.bibpaper(id).number}] #{compile_inline(caption)}"
988
1072
  puts macro('label', bib_label(id))
@@ -998,10 +1082,10 @@ module ReVIEW
998
1082
 
999
1083
  sa.map! do |item|
1000
1084
  if @index_db[item]
1001
- escape_index(escape_latex(@index_db[item])) + '@' + escape_index(escape_latex(item))
1085
+ escape_index(escape(@index_db[item])) + '@' + escape_index(escape(item))
1002
1086
  else
1003
1087
  if item =~ /\A[[:ascii:]]+\Z/ || @index_mecab.nil?
1004
- esc_item = escape_index(escape_latex(item))
1088
+ esc_item = escape_index(escape(item))
1005
1089
  if esc_item != item
1006
1090
  "#{escape_index(item)}@#{esc_item}"
1007
1091
  else
@@ -1009,7 +1093,7 @@ module ReVIEW
1009
1093
  end
1010
1094
  else
1011
1095
  yomi = NKF.nkf('-w --hiragana', @index_mecab.parse(item).force_encoding('UTF-8').chomp)
1012
- escape_index(escape_latex(yomi)) + '@' + escape_index(escape_latex(item))
1096
+ escape_index(escape(yomi)) + '@' + escape_index(escape(item))
1013
1097
  end
1014
1098
  end
1015
1099
  end
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2002-2006 Minero Aoki
2
- # Copyright (c) 2006-2017 Minero Aoki, Kenshi Muto and Masayoshi Takahashi
2
+ # Copyright (c) 2006-2018 Minero Aoki, Kenshi Muto and Masayoshi Takahashi
3
3
  #
4
4
  # This program is free software.
5
5
  # You can distribute or modify this program under the terms of
@@ -64,18 +64,18 @@ module ReVIEW
64
64
  @metachars_invert = @metachars.invert
65
65
  end
66
66
 
67
- def escape_latex(str)
67
+ def escape(str)
68
68
  str.gsub(@metachars_re) { |s| @metachars[s] or raise "unknown trans char: #{s}" }
69
69
  end
70
70
 
71
- alias_method :escape, :escape_latex
71
+ alias_method :escape_latex, :escape # backward compatibility
72
72
 
73
- def unescape_latex(str)
73
+ def unescape(str)
74
74
  metachars_invert_re = Regexp.new(@metachars_invert.keys.collect { |key| Regexp.escape(key) }.join('|'))
75
75
  str.gsub(metachars_invert_re) { |s| @metachars_invert[s] or raise "unknown trans char: #{s}" }
76
76
  end
77
77
 
78
- alias_method :unescape, :unescape_latex
78
+ alias_method :unescape_latex, :unescape # backward compatibility
79
79
 
80
80
  def escape_index(str)
81
81
  str.gsub(/[@!|"]/) { |s| '"' + s }
data/lib/review/logger.rb CHANGED
@@ -4,7 +4,8 @@ module ReVIEW
4
4
  class Logger < ::Logger
5
5
  def initialize(*logdev)
6
6
  if logdev.empty?
7
- super(STDERR, formatter: ->(severity, _datetime, _progname, msg) { "#{severity}: #{msg}\n" })
7
+ super(STDERR)
8
+ self.formatter = ->(severity, _datetime, _progname, msg) { "#{severity}: #{msg}\n" }
8
9
  else
9
10
  super
10
11
  end
@@ -51,7 +51,7 @@ module ReVIEW
51
51
  image_files << "#{from_dir}/#{fname}.#{conv_type}"
52
52
  end
53
53
 
54
- exts = options[:exts] || %w[png gif jpg jpeg svg pdf eps ai tif]
54
+ exts = options[:exts] || %w[png gif jpg jpeg svg pdf eps ai tif psd]
55
55
  exts_str = exts.join('|')
56
56
  if !is_converted && fname =~ /\.(#{exts_str})$/i
57
57
  FileUtils.cp "#{from_dir}/#{fname}", to_dir
@@ -16,6 +16,7 @@ module ReVIEW
16
16
  end
17
17
 
18
18
  def builder_init_file
19
+ @noindent = nil
19
20
  @blank_seen = nil
20
21
  @ul_indent = 0
21
22
  @chapter.book.image_types = %w[.png .jpg .jpeg .gif .svg]
@@ -48,8 +49,18 @@ module ReVIEW
48
49
  end
49
50
 
50
51
  def paragraph(lines)
51
- puts lines.join
52
- puts "\n"
52
+ if @noindent
53
+ puts %Q(<p class="noindent">#{lines.join}</p>)
54
+ puts "\n"
55
+ @noindent = nil
56
+ else
57
+ puts lines.join
58
+ puts "\n"
59
+ end
60
+ end
61
+
62
+ def noindent
63
+ @noindent = true
53
64
  end
54
65
 
55
66
  def list_header(id, caption, lang)
@@ -129,6 +140,14 @@ module ReVIEW
129
140
  blank
130
141
  end
131
142
 
143
+ def captionblock(type, lines, caption, _specialstyle = nil)
144
+ puts %Q(<div class="#{type}">)
145
+ puts %Q(<p class="caption">#{compile_inline(caption)}</p>) if caption.present?
146
+ blocked_lines = split_paragraph(lines)
147
+ puts blocked_lines.join("\n")
148
+ puts '</div>'
149
+ end
150
+
132
151
  def hr
133
152
  puts '----'
134
153
  end
@@ -160,10 +179,22 @@ module ReVIEW
160
179
  "`#{str}`"
161
180
  end
162
181
 
182
+ def inline_sub(str)
183
+ "<sub>#{str}</sub>"
184
+ end
185
+
186
+ def inline_sup(str)
187
+ "<sup>#{str}</sup>"
188
+ end
189
+
163
190
  def inline_tt(str)
164
191
  "`#{str}`"
165
192
  end
166
193
 
194
+ def inline_u(str)
195
+ "<u>#{str}</u>"
196
+ end
197
+
167
198
  def image_image(id, caption, _metric)
168
199
  blank
169
200
  puts "![#{compile_inline(caption)}](#{@chapter.image(id).path.sub(%r{\A\./}, '')})"
@@ -180,6 +211,10 @@ module ReVIEW
180
211
  error "unknown image: #{id}"
181
212
  end
182
213
 
214
+ def inline_dtp(str)
215
+ "<!-- DTP:#{str} -->"
216
+ end
217
+
183
218
  def indepimage(_lines, id, caption = '', _metric = nil)
184
219
  blank
185
220
  puts "![#{compile_inline(caption)}](#{@chapter.image(id).path.sub(%r{\A\./}, '')})"
@@ -293,12 +328,22 @@ module ReVIEW
293
328
 
294
329
  def compile_ruby(base, ruby)
295
330
  if @book.htmlversion == 5
296
- %Q(<ruby>#{escape_html(base)}<rp>#{I18n.t('ruby_prefix')}</rp><rt>#{escape_html(ruby)}</rt><rp>#{I18n.t('ruby_postfix')}</rp></ruby>)
331
+ %Q(<ruby>#{escape(base)}<rp>#{I18n.t('ruby_prefix')}</rp><rt>#{escape(ruby)}</rt><rp>#{I18n.t('ruby_postfix')}</rp></ruby>)
297
332
  else
298
- %Q(<ruby><rb>#{escape_html(base)}</rb><rp>#{I18n.t('ruby_prefix')}</rp><rt>#{ruby}</rt><rp>#{I18n.t('ruby_postfix')}</rp></ruby>)
333
+ %Q(<ruby><rb>#{escape(base)}</rb><rp>#{I18n.t('ruby_prefix')}</rp><rt>#{ruby}</rt><rp>#{I18n.t('ruby_postfix')}</rp></ruby>)
299
334
  end
300
335
  end
301
336
 
337
+ def compile_kw(word, alt)
338
+ %Q(<b class="kw">) +
339
+ if alt
340
+ escape_html(word + " (#{alt.strip})")
341
+ else
342
+ escape_html(word)
343
+ end +
344
+ "</b><!-- IDX:#{escape_comment(escape_html(word))} -->"
345
+ end
346
+
302
347
  def comment(lines, comment = nil)
303
348
  return unless @book.config['draft']
304
349
  lines ||= []
@@ -306,15 +351,30 @@ module ReVIEW
306
351
  lines.unshift comment
307
352
  end
308
353
  str = lines.join('<br />')
309
- puts %Q(<div class="red">#{escape_html(str)}</div>)
354
+ puts %Q(<div class="red">#{escape(str)}</div>)
355
+ end
356
+
357
+ def inline_icon(id)
358
+ begin
359
+ "![](#{@chapter.image(id).path.sub(%r{\A\./}, '')})"
360
+ rescue
361
+ warn "image not bound: #{id}"
362
+ %Q(<pre>missing image: #{id}</pre>)
363
+ end
310
364
  end
311
365
 
312
366
  def inline_comment(str)
313
367
  if @book.config['draft']
314
- %Q(<span class="red">#{escape_html(str)}</span>)
368
+ %Q(<span class="red">#{escape(str)}</span>)
315
369
  else
316
370
  ''
317
371
  end
318
372
  end
373
+
374
+ def flushright(lines)
375
+ puts %Q(<div class="flushright">)
376
+ puts lines.join
377
+ puts %Q(</div>)
378
+ end
319
379
  end
320
380
  end # module ReVIEW
@@ -44,9 +44,9 @@ module ReVIEW
44
44
 
45
45
  def compile_ruby(base, ruby)
46
46
  if base.length == 1
47
- %Q[<span class='monoruby'>#{escape_html(base)}(#{escape_html(ruby)})</span>]
47
+ %Q[<span class='monoruby'>#{escape(base)}(#{escape(ruby)})</span>]
48
48
  else
49
- %Q[<span class='groupruby'>#{escape_html(base)}(#{escape_html(ruby)})</span>]
49
+ %Q[<span class='groupruby'>#{escape(base)}(#{escape(ruby)})</span>]
50
50
  end
51
51
  end
52
52
  end