review 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +5 -0
  3. data/.rubocop.yml +293 -6
  4. data/.rubocop_todo.yml +3 -608
  5. data/.travis.yml +6 -13
  6. data/README.md +5 -3
  7. data/Rakefile +6 -6
  8. data/bin/review-catalog-converter +2 -2
  9. data/bin/review-check +1 -1
  10. data/bin/review-compile +1 -2
  11. data/bin/review-init +6 -3
  12. data/bin/review-validate +3 -3
  13. data/bin/review-vol +2 -1
  14. data/doc/NEWS.ja.md +138 -25
  15. data/doc/NEWS.md +137 -25
  16. data/doc/config.yml.sample +2 -2
  17. data/doc/config.yml.sample-simple +1 -1
  18. data/doc/format.ja.md +86 -5
  19. data/doc/format.md +67 -2
  20. data/doc/makeindex.ja.md +95 -0
  21. data/doc/makeindex.md +97 -0
  22. data/doc/sample.css +214 -0
  23. data/lib/epubmaker.rb +6 -6
  24. data/lib/epubmaker/epubcommon.rb +19 -47
  25. data/lib/epubmaker/epubv2.rb +3 -1
  26. data/lib/epubmaker/epubv3.rb +4 -26
  27. data/lib/epubmaker/producer.rb +46 -46
  28. data/lib/epubmaker/zip_exporter.rb +86 -0
  29. data/lib/review/book/base.rb +13 -15
  30. data/lib/review/book/chapter.rb +2 -1
  31. data/lib/review/book/compilable.rb +9 -9
  32. data/lib/review/book/image_finder.rb +13 -13
  33. data/lib/review/book/index.rb +2 -2
  34. data/lib/review/book/volume.rb +2 -2
  35. data/lib/review/builder.rb +57 -1
  36. data/lib/review/catalog.rb +2 -2
  37. data/lib/review/compiler.rb +15 -7
  38. data/lib/review/configure.rb +11 -0
  39. data/lib/review/epubmaker.rb +403 -401
  40. data/lib/review/ewbbuilder.rb +16 -16
  41. data/lib/review/htmlbuilder.rb +42 -58
  42. data/lib/review/htmltoc.rb +1 -1
  43. data/lib/review/htmlutils.rb +50 -4
  44. data/lib/review/i18n.rb +2 -2
  45. data/lib/review/idgxmlbuilder.rb +30 -47
  46. data/lib/review/latexbuilder.rb +86 -41
  47. data/lib/review/latexutils.rb +19 -19
  48. data/lib/review/markdownbuilder.rb +16 -4
  49. data/lib/review/md2inaobuilder.rb +0 -9
  50. data/lib/review/pdfmaker.rb +91 -48
  51. data/lib/review/preprocessor.rb +1 -1
  52. data/lib/review/rstbuilder.rb +763 -0
  53. data/lib/review/sec_counter.rb +7 -9
  54. data/lib/review/tocparser.rb +3 -3
  55. data/lib/review/tocprinter.rb +5 -5
  56. data/lib/review/topbuilder.rb +48 -56
  57. data/lib/review/version.rb +1 -1
  58. data/lib/review/webmaker.rb +6 -7
  59. data/review.gemspec +1 -0
  60. data/templates/latex/layout.tex.erb +27 -2
  61. data/test/assets/test_template.tex +10 -1
  62. data/test/book_test_helper.rb +1 -2
  63. data/test/run_test.rb +10 -0
  64. data/test/sample-book/src/style.css +215 -0
  65. data/test/sample-book/src/vendor/jumoline/lppl.txt +416 -0
  66. data/test/test_book.rb +0 -1
  67. data/test/test_catalog.rb +1 -0
  68. data/test/test_converter.rb +1 -1
  69. data/test/test_epub3maker.rb +44 -51
  70. data/test/test_epubmaker.rb +82 -38
  71. data/test/test_epubmaker_cmd.rb +1 -1
  72. data/test/test_extentions_hash.rb +8 -1
  73. data/test/test_htmlbuilder.rb +411 -18
  74. data/test/test_i18n.rb +17 -0
  75. data/test/test_idgxmlbuilder.rb +88 -3
  76. data/test/test_image_finder.rb +18 -0
  77. data/test/test_index.rb +2 -0
  78. data/test/test_latexbuilder.rb +96 -8
  79. data/test/test_makerhelper.rb +2 -2
  80. data/test/test_markdownbuilder.rb +22 -1
  81. data/test/test_md2inaobuilder.rb +0 -5
  82. data/test/test_pdfmaker.rb +54 -36
  83. data/test/test_pdfmaker_cmd.rb +1 -1
  84. data/test/test_rstbuilder.rb +356 -0
  85. data/test/test_textutils.rb +14 -4
  86. data/test/test_topbuilder.rb +23 -4
  87. data/test/test_zip_exporter.rb +113 -0
  88. metadata +28 -2
@@ -27,11 +27,11 @@ module ReVIEW
27
27
  puts
28
28
  end
29
29
 
30
- # Compiler.defsyntax(:emlist, :block, 0..1) {|args|
31
- # if args[0] and not args[0] == 'noescape'
32
- # raise SyntaxError, "unknown //emlist option: #{args[0]}"
33
- # end
34
- # }
30
+ # Compiler.defsyntax(:emlist, :block, 0..1) {|args|
31
+ # if args[0] and not args[0] == 'noescape'
32
+ # raise SyntaxError, "unknown //emlist option: #{args[0]}"
33
+ # end
34
+ # }
35
35
 
36
36
  def emlist(lines, caption = nil)
37
37
  # firstline = f.lineno
@@ -49,11 +49,11 @@ module ReVIEW
49
49
  puts
50
50
  end
51
51
 
52
- # Compiler.defsyntax(:cmd, :block, 0..1) {|args|
53
- # if args[0] and not args[0] == 'noescape'
54
- # raise SyntaxError, "unknown //cmd option: #{args[0]}"
55
- # end
56
- # }
52
+ # Compiler.defsyntax(:cmd, :block, 0..1) {|args|
53
+ # if args[0] and not args[0] == 'noescape'
54
+ # raise SyntaxError, "unknown //cmd option: #{args[0]}"
55
+ # end
56
+ # }
57
57
 
58
58
  def cmd(lines, caption = nil)
59
59
  puts
@@ -73,11 +73,11 @@ module ReVIEW
73
73
  puts
74
74
  end
75
75
 
76
- # Compiler.defsyntax(:list, :block, 0..1) {|args|
77
- # if args[0] and not args[0] == 'noescape'
78
- # raise SyntaxError, "unknown //list option: #{args[0]}"
79
- # end
80
- # }
76
+ # Compiler.defsyntax(:list, :block, 0..1) {|args|
77
+ # if args[0] and not args[0] == 'noescape'
78
+ # raise SyntaxError, "unknown //list option: #{args[0]}"
79
+ # end
80
+ # }
81
81
 
82
82
  def list(lines, id, caption)
83
83
  puts
@@ -91,7 +91,7 @@ module ReVIEW
91
91
  end
92
92
 
93
93
  def image_header(file, caption)
94
- if /\.png\z/ =~ file and not FileTest.exist?('images/' + file)
94
+ if /\.png\z/ =~ file and !FileTest.exist?('images/' + file)
95
95
  warn "image file not exist: #{file}"
96
96
  end
97
97
  id = file.sub(/\.\w+\z/, '')
@@ -32,6 +32,7 @@ module ReVIEW
32
32
  def pre_paragraph
33
33
  '<p>'
34
34
  end
35
+
35
36
  def post_paragraph
36
37
  '</p>'
37
38
  end
@@ -44,6 +45,8 @@ module ReVIEW
44
45
  @no_error = no_error
45
46
  @noindent = nil
46
47
  @ol_num = nil
48
+ @error_messages = nil
49
+ @warning_messages = nil
47
50
  end
48
51
  private :builder_init
49
52
 
@@ -54,12 +57,13 @@ module ReVIEW
54
57
  @column = 0
55
58
  @sec_counter = SecCounter.new(5, @chapter)
56
59
  @nonum_counter = 0
60
+ @first_line_num = nil
57
61
  @body_ext = nil
58
62
  @toc = nil
59
63
  end
60
64
  private :builder_init_file
61
65
 
62
- def result
66
+ def layoutfile
63
67
  if @book.config.maker == "webmaker"
64
68
  htmldir = "web/html"
65
69
  localfilename = "layout-web.html.erb"
@@ -85,10 +89,11 @@ module ReVIEW
85
89
  else
86
90
  layout_file = File.expand_path(htmlfilename, ReVIEW::Template::TEMPLATE_DIR)
87
91
  end
92
+ layout_file
93
+ end
88
94
 
95
+ def result
89
96
  # default XHTML header/footer
90
- @error_messages = error_messages
91
- @warning_messages = warning_messages
92
97
  @title = strip_html(compile_inline(@chapter.title))
93
98
  @body = @output.string
94
99
  @language = @book.config['language']
@@ -102,7 +107,7 @@ module ReVIEW
102
107
  @toc = ReVIEW::WEBTOCPrinter.book_to_string(@book)
103
108
  end
104
109
 
105
- tmpl = ReVIEW::Template.load(layout_file)
110
+ tmpl = ReVIEW::Template.load(layoutfile)
106
111
  tmpl.result(binding)
107
112
  end
108
113
 
@@ -132,30 +137,6 @@ module ReVIEW
132
137
  end
133
138
  end
134
139
 
135
- def messages
136
- error_messages() + warning_messages()
137
- end
138
-
139
- def error_messages
140
- return '' if @errors.empty?
141
- "<h2>Syntax Errors</h2>\n" +
142
- "<ul>\n" +
143
- @errors.map {|file, line, msg|
144
- "<li>#{escape_html(file)}:#{line}: #{escape_html(msg.to_s)}</li>\n"
145
- }.join('') +
146
- "</ul>\n"
147
- end
148
-
149
- def warning_messages
150
- return '' if @warns.empty?
151
- "<h2>Warnings</h2>\n" +
152
- "<ul>\n" +
153
- @warns.map {|file, line, msg|
154
- "<li>#{escape_html(file)}:#{line}: #{escape_html(msg)}</li>\n"
155
- }.join('') +
156
- "</ul>\n"
157
- end
158
-
159
140
  def headline(level, label, caption)
160
141
  prefix, anchor = headline_prefix(level)
161
142
  unless prefix.nil?
@@ -241,7 +222,7 @@ module ReVIEW
241
222
  puts %Q[<h#{level} id="#{normalize_id(label)}">#{a_id}#{compile_inline(caption)}</h#{level}>]
242
223
  end
243
224
  end
244
- # headline(level, label, caption)
225
+ # headline(level, label, caption)
245
226
  end
246
227
 
247
228
  def column_end(level)
@@ -275,10 +256,6 @@ module ReVIEW
275
256
  puts '</div>'
276
257
  end
277
258
 
278
- def tsize(str)
279
- # null
280
- end
281
-
282
259
  def captionblock(type, lines, caption)
283
260
  puts %Q[<div class="#{type}">]
284
261
  unless caption.nil?
@@ -354,10 +331,6 @@ module ReVIEW
354
331
  puts '<ul>'
355
332
  end
356
333
 
357
- def ul_item(lines)
358
- puts "<li>#{lines.join}</li>"
359
- end
360
-
361
334
  def ul_item_begin(lines)
362
335
  print "<li>#{lines.join}"
363
336
  end
@@ -424,7 +397,7 @@ module ReVIEW
424
397
  alias_method :lead, :read
425
398
 
426
399
  def list(lines, id, caption, lang = nil)
427
- puts %Q[<div class="caption-code">]
400
+ puts %Q[<div id="#{normalize_id(id)}" class="caption-code">]
428
401
  begin
429
402
  list_header id, caption, lang
430
403
  rescue KeyError
@@ -447,6 +420,7 @@ module ReVIEW
447
420
  class_names = ["list"]
448
421
  lexer = lang || File.extname(id).gsub(/\./, '')
449
422
  class_names.push("language-#{lexer}") unless lexer.blank?
423
+ class_names.push("highlight") if highlight?
450
424
  print %Q[<pre class="#{class_names.join(" ")}">]
451
425
  body = lines.inject(''){|i, j| i + detab(j) + "\n"}
452
426
  puts highlight(:body => body, :lexer => lexer, :format => 'html')
@@ -476,7 +450,7 @@ module ReVIEW
476
450
  end
477
451
 
478
452
  def listnum(lines, id, caption, lang = nil)
479
- puts %Q[<div class="code">]
453
+ puts %Q[<div id="#{normalize_id(id)}" class="code">]
480
454
  begin
481
455
  list_header id, caption, lang
482
456
  rescue KeyError
@@ -490,14 +464,17 @@ module ReVIEW
490
464
  if highlight?
491
465
  body = lines.inject(''){|i, j| i + detab(j) + "\n"}
492
466
  lexer = lang
493
- puts highlight(:body => body, :lexer => lexer, :format => 'html',
494
- :options => {:linenos => 'inline', :nowrap => false})
467
+ first_line_number = get_line_num
468
+ puts highlight(:body => body, :lexer => lexer, :format => 'html', :linenum => true,
469
+ :options => {:linenostart => first_line_number})
495
470
  else
496
471
  class_names = ["list"]
497
472
  class_names.push("language-#{lang}") unless lang.blank?
473
+ class_names.push("highlight") if highlight?
498
474
  print %Q[<pre class="#{class_names.join(" ")}">]
475
+ first_line_num = get_line_num
499
476
  lines.each_with_index do |line, i|
500
- puts detab((i+1).to_s.rjust(2) + ": " + line)
477
+ puts detab((i+first_line_num).to_s.rjust(2) + ": " + line)
501
478
  end
502
479
  puts '</pre>'
503
480
  end
@@ -510,6 +487,7 @@ module ReVIEW
510
487
  end
511
488
  class_names = ["emlist"]
512
489
  class_names.push("language-#{lang}") unless lang.blank?
490
+ class_names.push("highlight") if highlight?
513
491
  print %Q[<pre class="#{class_names.join(" ")}">]
514
492
  body = lines.inject(''){|i, j| i + detab(j) + "\n"}
515
493
  lexer = lang
@@ -527,14 +505,17 @@ module ReVIEW
527
505
  if highlight?
528
506
  body = lines.inject(''){|i, j| i + detab(j) + "\n"}
529
507
  lexer = lang
530
- puts highlight(:body => body, :lexer => lexer, :format => 'html',
531
- :options => {:linenos => 'inline', :nowrap => false})
508
+ first_line_number = get_line_num
509
+ puts highlight(:body => body, :lexer => lexer, :format => 'html', :linenum => true,
510
+ :options => {:linenostart => first_line_number})
532
511
  else
533
512
  class_names = ["emlist"]
534
513
  class_names.push("language-#{lang}") unless lang.blank?
514
+ class_names.push("highlight") if highlight?
535
515
  print %Q[<pre class="#{class_names.join(" ")}">]
516
+ first_line_num = get_line_num
536
517
  lines.each_with_index do |line, i|
537
- puts detab((i+1).to_s.rjust(2) + ": " + line)
518
+ puts detab((i+first_line_num).to_s.rjust(2) + ": " + line)
538
519
  end
539
520
  puts '</pre>'
540
521
  end
@@ -751,10 +732,7 @@ module ReVIEW
751
732
  lines.unshift comment unless comment.blank?
752
733
  if @book.config["draft"]
753
734
  str = lines.join("<br />")
754
- puts %Q(<div class="draft-comment">#{str}</div>)
755
- else
756
- str = lines.join("\n")
757
- puts %Q(<!-- #{escape_comment(str)} -->)
735
+ puts %Q(<div class="draft-comment">#{escape_html(str)}</div>)
758
736
  end
759
737
  end
760
738
 
@@ -998,18 +976,24 @@ module ReVIEW
998
976
 
999
977
  def inline_column_chap(chapter, id)
1000
978
  if @book.config["chapterlink"]
1001
- %Q(<a href="\##{column_label(id)}" class="columnref">#{I18n.t("column", escape_html(chapter.column(id).caption))}</a>)
979
+ %Q(<a href="\##{column_label(id)}" class="columnref">#{I18n.t("column", compile_inline(chapter.column(id).caption))}</a>)
1002
980
  else
1003
- I18n.t("column", escape_html(chapter.column(id).caption))
981
+ I18n.t("column", compile_inline(chapter.column(id).caption))
1004
982
  end
1005
983
  end
1006
984
 
1007
985
  def inline_list(id)
1008
986
  chapter, id = extract_chapter_id(id)
987
+ str = nil
1009
988
  if get_chap(chapter).nil?
1010
- "#{I18n.t("list")}#{I18n.t("format_number_without_header", [chapter.list(id).number])}"
989
+ str = "#{I18n.t("list")}#{I18n.t("format_number_without_header", [chapter.list(id).number])}"
1011
990
  else
1012
- "#{I18n.t("list")}#{I18n.t("format_number", [get_chap(chapter), chapter.list(id).number])}"
991
+ str = "#{I18n.t("list")}#{I18n.t("format_number", [get_chap(chapter), chapter.list(id).number])}"
992
+ end
993
+ if @book.config["chapterlink"]
994
+ %Q(<span class="listref"><a href="./#{chapter.id}#{extname}##{id}">#{str}</a></span>)
995
+ else
996
+ %Q(<span class="listref">#{str}</span>)
1013
997
  end
1014
998
  rescue KeyError
1015
999
  error "unknown list: #{id}"
@@ -1025,9 +1009,9 @@ module ReVIEW
1025
1009
  str = "#{I18n.t("table")}#{I18n.t("format_number", [get_chap(chapter), chapter.table(id).number])}"
1026
1010
  end
1027
1011
  if @book.config["chapterlink"]
1028
- %Q(<a href="./#{chapter.id}#{extname}##{id}">#{str}</a>)
1012
+ %Q(<span class="tableref"><a href="./#{chapter.id}#{extname}##{id}">#{str}</a></span>)
1029
1013
  else
1030
- str
1014
+ %Q(<span class="tableref">#{str}</span>)
1031
1015
  end
1032
1016
  rescue KeyError
1033
1017
  error "unknown table: #{id}"
@@ -1043,9 +1027,9 @@ module ReVIEW
1043
1027
  str = "#{I18n.t("image")}#{I18n.t("format_number", [get_chap(chapter), chapter.image(id).number])}"
1044
1028
  end
1045
1029
  if @book.config["chapterlink"]
1046
- %Q(<a href="./#{chapter.id}#{extname}##{normalize_id(id)}">#{str}</a>)
1030
+ %Q(<span class="imgref"><a href="./#{chapter.id}#{extname}##{normalize_id(id)}">#{str}</a></span>)
1047
1031
  else
1048
- str
1032
+ %Q(<span class="imgref">#{str}</span>)
1049
1033
  end
1050
1034
  rescue KeyError
1051
1035
  error "unknown image: #{id}"
@@ -1148,7 +1132,7 @@ module ReVIEW
1148
1132
  if @book.config["draft"]
1149
1133
  %Q(<span class="draft-comment">#{escape_html(str)}</span>)
1150
1134
  else
1151
- %Q(<!-- #{escape_comment(escape_html(str))} -->)
1135
+ ""
1152
1136
  end
1153
1137
  end
1154
1138
 
@@ -28,7 +28,7 @@ module ReVIEW
28
28
  end
29
29
 
30
30
  def decode_args(args_str)
31
- args = Hash.new
31
+ args = {}
32
32
  args_str.split(/,\s*/).each do |pair|
33
33
  key, val = pair.split("=")
34
34
  args[key.to_sym] = val
@@ -28,7 +28,7 @@ module ReVIEW
28
28
  alias_method :h, :escape_html
29
29
 
30
30
  def unescape_html(str)
31
- # FIXME better code
31
+ # FIXME: better code
32
32
  str.gsub('&quot;', '"').gsub('&gt;', '>').gsub('&lt;', '<').gsub('&amp;', '&')
33
33
  end
34
34
 
@@ -44,14 +44,25 @@ module ReVIEW
44
44
 
45
45
  def highlight?
46
46
  @book.config["highlight"] &&
47
- @book.config["highlight"]["html"] == "pygments"
47
+ @book.config["highlight"]["html"]
48
48
  end
49
49
 
50
50
  def highlight(ops)
51
51
  if @book.config["pygments"].present?
52
52
  raise ReVIEW::ConfigError, "'pygments:' in config.yml is obsoleted."
53
53
  end
54
+ return ops[:body].to_s if !highlight?
54
55
 
56
+ if @book.config["highlight"]["html"] == "pygments"
57
+ highlight_pygments(ops)
58
+ elsif @book.config["highlight"]["html"] == "rouge"
59
+ highlight_rouge(ops)
60
+ else
61
+ raise ReVIEW::ConfigError, "unknown highlight method #{@book.config["highlight"]["html"]} in config.yml."
62
+ end
63
+ end
64
+
65
+ def highlight_pygments(ops)
55
66
  body = ops[:body] || ''
56
67
  if @book.config["highlight"] && @book.config["highlight"]["lang"]
57
68
  lexer = @book.config["highlight"]["lang"] # default setting
@@ -61,10 +72,13 @@ module ReVIEW
61
72
  lexer = ops[:lexer] if ops[:lexer].present?
62
73
  format = ops[:format] || ''
63
74
  options = {:nowrap => true, :noclasses => true}
75
+ if ops[:linenum]
76
+ options[:nowrap] = false
77
+ options[:linenos] = 'inline'
78
+ end
64
79
  if ops[:options] && ops[:options].kind_of?(Hash)
65
80
  options.merge!(ops[:options])
66
81
  end
67
- return body if !highlight?
68
82
 
69
83
  begin
70
84
  require 'pygments'
@@ -77,8 +91,40 @@ module ReVIEW
77
91
  body
78
92
  end
79
93
  rescue LoadError
80
- body
94
+ body
95
+ end
96
+ end
97
+
98
+ def highlight_rouge(ops)
99
+ body = ops[:body] || ''
100
+ if ops[:lexer].present?
101
+ lexer = ops[:lexer]
102
+ elsif @book.config["highlight"] && @book.config["highlight"]["lang"]
103
+ lexer = @book.config["highlight"]["lang"] # default setting
104
+ else
105
+ lexer = 'text'
106
+ end
107
+ format = ops[:format] || ''
108
+
109
+ first_line_num = 1 ## default
110
+ if ops[:options] && ops[:options][:linenostart]
111
+ first_line_num = ops[:options][:linenostart]
81
112
  end
113
+
114
+ require 'rouge'
115
+ lexer = Rouge::Lexer.find(lexer)
116
+ raise "unknown lexer #{lexer}" unless lexer
117
+
118
+ formatter = Rouge::Formatters::HTML.new(:css_class => 'highlight')
119
+ if ops[:linenum]
120
+ formatter = Rouge::Formatters::HTMLTable.new(formatter,
121
+ :table_class => 'highlight rouge-table',
122
+ :start_line => first_line_num)
123
+ end
124
+ raise "unknown formatter #{formatter}" unless formatter
125
+
126
+ text = unescape_html(body)
127
+ formatter.format(lexer.lex(text))
82
128
  end
83
129
 
84
130
  def normalize_id(id)
data/lib/review/i18n.rb CHANGED
@@ -154,13 +154,13 @@ module ReVIEW
154
154
  frmt.sub!(i, ARABIC_UW[args[idx]])
155
155
  remove_args << idx
156
156
  else
157
- # noop
157
+ # do nothing
158
158
  end
159
159
  end
160
160
  remove_args.reverse_each do |idx|
161
161
  args.delete_at idx
162
162
  end
163
- args_matched = (frmt.count("%") == args.size)
163
+ args_matched = (frmt.count("%") <= args.size)
164
164
  frmt.gsub!('##', '%%')
165
165
  args_matched ? (frmt % args) : frmt
166
166
  rescue
@@ -64,6 +64,7 @@ module ReVIEW
64
64
  @column = 0
65
65
  @noindent = nil
66
66
  @ol_num = nil
67
+ @first_line_num = nil
67
68
  @rootelement = "doc"
68
69
  @secttags = nil
69
70
  @tsize = nil
@@ -92,7 +93,7 @@ module ReVIEW
92
93
  s += "</sect>" if @section > 0
93
94
  s += "</chapter>" if @chapter.number > 0
94
95
  end
95
- messages() + @output.string + s + "</#{@rootelement}>\n"
96
+ @output.string + s + "</#{@rootelement}>\n"
96
97
  end
97
98
 
98
99
  def warn(msg)
@@ -113,30 +114,6 @@ module ReVIEW
113
114
  end
114
115
  end
115
116
 
116
- def messages
117
- error_messages() + warning_messages()
118
- end
119
-
120
- def error_messages
121
- return '' if @errors.empty?
122
- "<h2>Syntax Errors</h2>\n" +
123
- "<ul>\n" +
124
- @errors.map {|file, line, msg|
125
- "<li>#{escape_html(file)}:#{line}: #{escape_html(msg.to_s)}</li>\n"
126
- }.join('') +
127
- "</ul>\n"
128
- end
129
-
130
- def warning_messages
131
- return '' if @warns.empty?
132
- "<h2>Warnings</h2>\n" +
133
- "<ul>\n" +
134
- @warns.map {|file, line, msg|
135
- "<li>#{escape_html(file)}:#{line}: #{escape_html(msg)}</li>\n"
136
- }.join('') +
137
- "</ul>\n"
138
- end
139
-
140
117
  def headline(level, label, caption)
141
118
  case level
142
119
  when 1
@@ -162,7 +139,7 @@ module ReVIEW
162
139
  end
163
140
  @section += 1
164
141
  print %Q(<sect id="sect:#{@chapter.number}.#{@section}">) unless @secttags.nil?
165
-
142
+
166
143
  @subsection = 0
167
144
  @subsubsection = 0
168
145
  @subsubsubsection = 0
@@ -212,10 +189,6 @@ module ReVIEW
212
189
  puts "<ul#{level == 1 ? nil : level}>"
213
190
  end
214
191
 
215
- def ul_item(lines)
216
- puts %Q(<li aid:pstyle="ul-item">#{lines.join.chomp}</li>)
217
- end
218
-
219
192
  def ul_item_begin(lines)
220
193
  print %Q(<li aid:pstyle="ul-item">#{lines.join.chomp})
221
194
  end
@@ -310,9 +283,9 @@ module ReVIEW
310
283
 
311
284
  def inline_column_chap(chapter, id)
312
285
  if @book.config["chapterlink"]
313
- %Q(<link href="#{column_label(id)}">#{escape_html(chapter.column(id).caption)}</link>)
286
+ %Q(<link href="#{column_label(id)}">#{I18n.t("column", compile_inline(chapter.column(id).caption))}</link>)
314
287
  else
315
- escape_html(chapter.column(id).caption)
288
+ I18n.t("column", compile_inline(chapter.column(id).caption))
316
289
  end
317
290
  end
318
291
 
@@ -362,8 +335,9 @@ module ReVIEW
362
335
 
363
336
  def emlistnum(lines, caption = nil, lang = nil)
364
337
  _lines = []
338
+ first_line_num = get_line_num
365
339
  lines.each_with_index do |line, i|
366
- _lines << detab("<span type='lineno'>" + (i + 1).to_s.rjust(2) + ": </span>" + line)
340
+ _lines << detab("<span type='lineno'>" + (i + first_line_num).to_s.rjust(2) + ": </span>" + line)
367
341
  end
368
342
  quotedlist _lines, 'emlistnum', caption
369
343
  end
@@ -371,6 +345,7 @@ module ReVIEW
371
345
  def listnum_body(lines, lang)
372
346
  print %Q(<pre>)
373
347
  no = 1
348
+ first_line_num = get_line_num
374
349
  lines.each_with_index do |line, i|
375
350
  unless @book.config["listinfo"].nil?
376
351
  print "<listinfo line=\"#{no}\""
@@ -378,7 +353,7 @@ module ReVIEW
378
353
  print " end=\"#{no}\"" if no == lines.size
379
354
  print ">"
380
355
  end
381
- print detab("<span type='lineno'>" + (i + 1).to_s.rjust(2) + ": </span>" + line)
356
+ print detab("<span type='lineno'>" + (i + first_line_num).to_s.rjust(2) + ": </span>" + line)
382
357
  print "\n"
383
358
  print "</listinfo>" unless @book.config["listinfo"].nil?
384
359
  no += 1
@@ -532,7 +507,7 @@ module ReVIEW
532
507
  if cellwidth.size < col
533
508
  cw = (tablewidth - totallength) / (col - cellwidth.size)
534
509
  warn "auto cell sizing exceeds limit for table: #{id}" if cw <= 0
535
- for i in cellwidth.size..(col - 1)
510
+ (cellwidth.size..(col - 1)).each do |i|
536
511
  cellwidth[i] = cw
537
512
  end
538
513
  end
@@ -589,7 +564,7 @@ module ReVIEW
589
564
 
590
565
  def table_header(id, caption)
591
566
  if get_chap.nil?
592
- puts %Q[<caption>#{I18n.t("table")}#{I18n.t("format_number_without_chapter", [@chapter.table(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}</caption>]
567
+ puts %Q[<caption>#{I18n.t("table")}#{I18n.t("format_number_without_chapter", [@chapter.table(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}</caption>]
593
568
  else
594
569
  puts %Q[<caption>#{I18n.t("table")}#{I18n.t("format_number", [get_chap, @chapter.table(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}</caption>]
595
570
  end
@@ -627,8 +602,21 @@ module ReVIEW
627
602
  end
628
603
  end
629
604
 
630
- def comment(str)
631
- print %Q(<!-- [Comment] #{escape_html(str)} -->)
605
+ def comment(lines, comment = nil)
606
+ if @book.config["draft"]
607
+ lines ||= []
608
+ lines.unshift comment unless comment.blank?
609
+ str = lines.join("\n")
610
+ print "<msg>#{escape_html(str)}</msg>"
611
+ end
612
+ end
613
+
614
+ def inline_comment(str)
615
+ if @book.config["draft"]
616
+ %Q(<msg>#{escape_html(str)}</msg>)
617
+ else
618
+ ''
619
+ end
632
620
  end
633
621
 
634
622
  def footnote(id, str)
@@ -758,7 +746,7 @@ module ReVIEW
758
746
  end
759
747
 
760
748
  def inline_labelref(idref)
761
- %Q[<ref idref='#{escape_html(idref)}'>「#{I18n.t("label_marker")}#{escape_html(idref)}」</ref>] # FIXME:節名とタイトルも込みで要出力
749
+ %Q[<ref idref='#{escape_html(idref)}'>「#{I18n.t("label_marker")}#{escape_html(idref)}」</ref>] # FIXME: 節名とタイトルも込みで要出力
762
750
  end
763
751
 
764
752
  alias_method :inline_ref, :inline_labelref
@@ -785,7 +773,7 @@ module ReVIEW
785
773
  end
786
774
 
787
775
  def linebreak
788
- # FIXME:pが閉じちゃってるので一度戻らないといけないが、難しい…。
776
+ # FIXME: pが閉じちゃってるので一度戻らないといけないが、難しい…。
789
777
  puts "<br />"
790
778
  end
791
779
 
@@ -1045,10 +1033,6 @@ module ReVIEW
1045
1033
  print "<label id='#{id}' />"
1046
1034
  end
1047
1035
 
1048
- def tsize(str)
1049
- @tsize = str
1050
- end
1051
-
1052
1036
  def dtp(str)
1053
1037
  print %Q(<?dtp #{str} ?>)
1054
1038
  end
@@ -1088,14 +1072,13 @@ module ReVIEW
1088
1072
 
1089
1073
  def inline_chapref(id)
1090
1074
  chs = ["", "「", "」"]
1091
- unless @book.config["chapref"].nil?
1075
+ if @book.config["chapref"]
1092
1076
  _chs = @book.config["chapref"].split(",")
1093
1077
  if _chs.size != 3
1094
1078
  error "--chapsplitter must have exactly 3 parameters with comma."
1095
1079
  else
1096
1080
  chs = _chs
1097
1081
  end
1098
- else
1099
1082
  end
1100
1083
  s = "#{chs[0]}#{@book.chapter_index.number(id)}#{chs[1]}#{@book.chapter_index.title(id)}#{chs[2]}"
1101
1084
  if @book.config["chapterlink"]
@@ -1156,7 +1139,7 @@ module ReVIEW
1156
1139
  end
1157
1140
 
1158
1141
  def bibpaper_bibpaper(id, caption, lines)
1159
- print split_paragraph(lines).join("")
1142
+ print split_paragraph(lines).join("")
1160
1143
  end
1161
1144
 
1162
1145
  def inline_bib(id)