review 3.2.0 → 4.0.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.
- checksums.yaml +4 -4
- data/.rubocop.yml +26 -4
- data/.travis.yml +1 -1
- data/NEWS.ja.md +97 -1
- data/NEWS.md +97 -1
- data/bin/review-catalog-converter +1 -1
- data/bin/review-check +5 -5
- data/bin/review-checkdep +1 -1
- data/bin/review-compile +5 -5
- data/bin/review-idgxmlmaker +16 -0
- data/bin/review-index +7 -7
- data/bin/review-preproc +9 -9
- data/bin/review-validate +2 -2
- data/bin/review-vol +5 -5
- data/doc/config.yml.sample +14 -6
- data/doc/config.yml.sample-simple +1 -1
- data/doc/format.ja.md +15 -5
- data/doc/format.md +30 -18
- data/doc/pdfmaker.ja.md +1 -1
- data/doc/pdfmaker.md +1 -1
- data/lib/review/book.rb +1 -1
- data/lib/review/book/base.rb +23 -63
- data/lib/review/book/chapter.rb +18 -3
- data/lib/review/book/compilable.rb +5 -0
- data/lib/review/book/index.rb +26 -65
- data/lib/review/book/index/item.rb +40 -0
- data/lib/review/book/part.rb +22 -2
- data/lib/review/builder.rb +60 -40
- data/lib/review/catalog.rb +12 -15
- data/lib/review/compiler.rb +68 -36
- data/lib/review/configure.rb +10 -7
- data/lib/review/epubmaker.rb +5 -2
- data/lib/review/htmlbuilder.rb +24 -71
- data/lib/review/htmlutils.rb +2 -3
- data/lib/review/i18n.rb +2 -2
- data/lib/review/idgxmlbuilder.rb +101 -55
- data/lib/review/idgxmlmaker.rb +184 -0
- data/lib/review/init-web/finish.html +10 -0
- data/lib/review/init-web/index.html +190 -0
- data/lib/review/init-web/review-layout-design.js +691 -0
- data/lib/review/init.rb +110 -26
- data/lib/review/latexbuilder.rb +76 -54
- data/lib/review/lineinput.rb +1 -1
- data/lib/review/logger.rb +4 -8
- data/lib/review/makerhelper.rb +6 -4
- data/lib/review/markdownbuilder.rb +25 -38
- data/lib/review/md2inaobuilder.rb +3 -5
- data/lib/review/pdfmaker.rb +15 -15
- data/lib/review/plaintextbuilder.rb +67 -76
- data/lib/review/preprocessor.rb +13 -13
- data/lib/review/rstbuilder.rb +31 -31
- data/lib/review/textmaker.rb +13 -3
- data/lib/review/textutils.rb +77 -2
- data/lib/review/tocparser.rb +17 -17
- data/lib/review/tocprinter.rb +8 -8
- data/lib/review/topbuilder.rb +76 -57
- data/lib/review/update.rb +16 -16
- data/lib/review/version.rb +1 -1
- data/lib/review/webmaker.rb +2 -2
- data/lib/review/yamlloader.rb +3 -0
- data/review.gemspec +4 -3
- data/samples/sample-book/README.md +7 -2
- data/samples/sample-book/src/.gitignore +153 -0
- data/samples/sample-book/src/config-jlreq.yml +6 -0
- data/samples/sample-book/src/lib/tasks/review.rake +20 -9
- data/samples/sample-book/src/lib/tasks/z01_copy_sty.rake +14 -8
- data/samples/syntax-book/ch03.re +3 -6
- data/samples/syntax-book/config-jlreq.yml +5 -0
- data/samples/syntax-book/lib/tasks/review.rake +7 -7
- data/samples/syntax-book/lib/tasks/z01_copy_sty.rake +14 -8
- data/templates/latex/config.erb +6 -0
- data/templates/latex/layout.tex.erb +1 -0
- data/templates/latex/review-jlreq/review-base.sty +93 -31
- data/templates/latex/review-jlreq/review-jlreq.cls +6 -0
- data/templates/latex/review-jlreq/review-style.sty +3 -0
- data/templates/latex/review-jsbook/README.md +39 -0
- data/templates/latex/review-jsbook/review-base.sty +65 -10
- data/templates/latex/review-jsbook/review-jsbook.cls +4 -0
- data/templates/latex/review-jsbook/review-style.sty +4 -1
- data/test/assets/test_template.tex +11 -3
- data/test/assets/test_template_backmatter.tex +11 -3
- data/test/test_book.rb +65 -19
- data/test/test_catalog.rb +18 -42
- data/test/test_catalog_converter_cmd.rb +1 -1
- data/test/test_epubmaker_cmd.rb +2 -2
- data/test/test_helper.rb +1 -1
- data/test/test_htmlbuilder.rb +144 -55
- data/test/test_i18n.rb +25 -25
- data/test/test_idgxmlbuilder.rb +60 -18
- data/test/test_image_finder.rb +6 -6
- data/test/test_latexbuilder.rb +128 -24
- data/test/test_latexbuilder_v2.rb +23 -23
- data/test/test_logger.rb +14 -1
- data/test/test_makerhelper.rb +3 -3
- data/test/test_markdownbuilder.rb +45 -4
- data/test/test_md2inaobuilder.rb +12 -2
- data/test/test_pdfmaker.rb +1 -1
- data/test/test_pdfmaker_cmd.rb +1 -1
- data/test/test_plaintextbuilder.rb +31 -6
- data/test/test_rstbuilder.rb +33 -4
- data/test/test_textutils.rb +109 -2
- data/test/test_topbuilder.rb +35 -7
- data/test/test_update.rb +17 -8
- data/test/test_yamlloader.rb +13 -0
- metadata +26 -2
data/lib/review/htmlbuilder.rb
CHANGED
|
@@ -12,7 +12,6 @@ require 'review/htmlutils'
|
|
|
12
12
|
require 'review/template'
|
|
13
13
|
require 'review/textutils'
|
|
14
14
|
require 'review/webtocprinter'
|
|
15
|
-
require 'digest'
|
|
16
15
|
require 'tmpdir'
|
|
17
16
|
require 'open3'
|
|
18
17
|
|
|
@@ -308,7 +307,7 @@ module ReVIEW
|
|
|
308
307
|
end
|
|
309
308
|
|
|
310
309
|
def ul_item_begin(lines)
|
|
311
|
-
print "<li>#{lines
|
|
310
|
+
print "<li>#{join_lines_to_paragraph(lines)}"
|
|
312
311
|
end
|
|
313
312
|
|
|
314
313
|
def ul_item_end
|
|
@@ -329,7 +328,7 @@ module ReVIEW
|
|
|
329
328
|
end
|
|
330
329
|
|
|
331
330
|
def ol_item(lines, _num)
|
|
332
|
-
puts "<li>#{lines
|
|
331
|
+
puts "<li>#{join_lines_to_paragraph(lines)}</li>"
|
|
333
332
|
end
|
|
334
333
|
|
|
335
334
|
def ol_end
|
|
@@ -345,7 +344,7 @@ module ReVIEW
|
|
|
345
344
|
end
|
|
346
345
|
|
|
347
346
|
def dd(lines)
|
|
348
|
-
puts "<dd>#{lines
|
|
347
|
+
puts "<dd>#{join_lines_to_paragraph(lines)}</dd>"
|
|
349
348
|
end
|
|
350
349
|
|
|
351
350
|
def dl_end
|
|
@@ -354,10 +353,10 @@ module ReVIEW
|
|
|
354
353
|
|
|
355
354
|
def paragraph(lines)
|
|
356
355
|
if @noindent
|
|
357
|
-
puts %Q(<p class="noindent">#{lines
|
|
356
|
+
puts %Q(<p class="noindent">#{join_lines_to_paragraph(lines)}</p>)
|
|
358
357
|
@noindent = nil
|
|
359
358
|
else
|
|
360
|
-
puts "<p>#{lines
|
|
359
|
+
puts "<p>#{join_lines_to_paragraph(lines)}</p>"
|
|
361
360
|
end
|
|
362
361
|
end
|
|
363
362
|
|
|
@@ -375,11 +374,11 @@ module ReVIEW
|
|
|
375
374
|
def list(lines, id, caption, lang = nil)
|
|
376
375
|
puts %Q(<div id="#{normalize_id(id)}" class="caption-code">)
|
|
377
376
|
begin
|
|
378
|
-
list_header
|
|
377
|
+
list_header(id, caption, lang)
|
|
379
378
|
rescue KeyError
|
|
380
379
|
error "no such list: #{id}"
|
|
381
380
|
end
|
|
382
|
-
list_body
|
|
381
|
+
list_body(id, lines, lang)
|
|
383
382
|
puts '</div>'
|
|
384
383
|
end
|
|
385
384
|
|
|
@@ -404,8 +403,8 @@ module ReVIEW
|
|
|
404
403
|
|
|
405
404
|
def source(lines, caption = nil, lang = nil)
|
|
406
405
|
puts %Q(<div class="source-code">)
|
|
407
|
-
source_header
|
|
408
|
-
source_body
|
|
406
|
+
source_header(caption)
|
|
407
|
+
source_body(caption, lines, lang)
|
|
409
408
|
puts '</div>'
|
|
410
409
|
end
|
|
411
410
|
|
|
@@ -426,11 +425,11 @@ module ReVIEW
|
|
|
426
425
|
def listnum(lines, id, caption, lang = nil)
|
|
427
426
|
puts %Q(<div id="#{normalize_id(id)}" class="code">)
|
|
428
427
|
begin
|
|
429
|
-
list_header
|
|
428
|
+
list_header(id, caption, lang)
|
|
430
429
|
rescue KeyError
|
|
431
430
|
error "no such list: #{id}"
|
|
432
431
|
end
|
|
433
|
-
listnum_body
|
|
432
|
+
listnum_body(lines, lang)
|
|
434
433
|
puts '</div>'
|
|
435
434
|
end
|
|
436
435
|
|
|
@@ -541,7 +540,8 @@ module ReVIEW
|
|
|
541
540
|
|
|
542
541
|
def texequation(lines, id = nil, caption = '')
|
|
543
542
|
if id
|
|
544
|
-
|
|
543
|
+
puts %Q(<div id="#{normalize_id(id)}" class="caption-equation">)
|
|
544
|
+
texequation_header(id, caption)
|
|
545
545
|
end
|
|
546
546
|
|
|
547
547
|
texequation_body(lines)
|
|
@@ -552,7 +552,6 @@ module ReVIEW
|
|
|
552
552
|
end
|
|
553
553
|
|
|
554
554
|
def texequation_header(id, caption)
|
|
555
|
-
puts %Q(<div id="#{normalize_id(id)}" class="caption-equation">)
|
|
556
555
|
if get_chap
|
|
557
556
|
puts %Q(<p class="caption">#{I18n.t('equation')}#{I18n.t('format_number_header', [get_chap, @chapter.equation(id).number])}#{I18n.t('caption_prefix')}#{compile_inline(caption)}</p>)
|
|
558
557
|
else
|
|
@@ -566,11 +565,11 @@ module ReVIEW
|
|
|
566
565
|
require 'math_ml'
|
|
567
566
|
require 'math_ml/symbol/character_reference'
|
|
568
567
|
p = MathML::LaTeX::Parser.new(symbol: MathML::Symbol::CharacterReference)
|
|
569
|
-
|
|
568
|
+
print p.parse(lines.join("\n") + "\n", true)
|
|
570
569
|
elsif @book.config['imgmath']
|
|
571
570
|
fontsize = @book.config['imgmath_options']['fontsize'].to_f
|
|
572
571
|
lineheight = @book.config['imgmath_options']['lineheight'].to_f
|
|
573
|
-
math_str = "\\begin{equation*}\n\\fontsize{#{fontsize}}{#{lineheight}}\\selectfont\n#{
|
|
572
|
+
math_str = "\\begin{equation*}\n\\fontsize{#{fontsize}}{#{lineheight}}\\selectfont\n#{lines.join("\n")}\n\\end{equation*}\n"
|
|
574
573
|
key = Digest::SHA256.hexdigest(math_str)
|
|
575
574
|
math_dir = File.join(@book.config['imagedir'], '_review_math')
|
|
576
575
|
Dir.mkdir(math_dir) unless Dir.exist?(math_dir)
|
|
@@ -616,7 +615,7 @@ module ReVIEW
|
|
|
616
615
|
metrics = parse_metric('html', metric)
|
|
617
616
|
puts %Q(<div id="#{normalize_id(id)}" class="image">)
|
|
618
617
|
puts %Q(<img src="#{@chapter.image(id).path.sub(%r{\A\./}, '')}" alt="#{escape(compile_inline(caption))}"#{metrics} />)
|
|
619
|
-
image_header
|
|
618
|
+
image_header(id, caption)
|
|
620
619
|
puts '</div>'
|
|
621
620
|
end
|
|
622
621
|
|
|
@@ -628,7 +627,7 @@ module ReVIEW
|
|
|
628
627
|
puts detab(line)
|
|
629
628
|
end
|
|
630
629
|
puts '</pre>'
|
|
631
|
-
image_header
|
|
630
|
+
image_header(id, caption)
|
|
632
631
|
puts '</div>'
|
|
633
632
|
end
|
|
634
633
|
|
|
@@ -643,47 +642,12 @@ module ReVIEW
|
|
|
643
642
|
end
|
|
644
643
|
|
|
645
644
|
def table(lines, id = nil, caption = nil)
|
|
646
|
-
rows = []
|
|
647
|
-
sepidx = nil
|
|
648
|
-
lines.each_with_index do |line, idx|
|
|
649
|
-
if /\A[\=\-]{12}/ =~ line
|
|
650
|
-
# just ignore
|
|
651
|
-
# error "too many table separator" if sepidx
|
|
652
|
-
sepidx ||= idx
|
|
653
|
-
next
|
|
654
|
-
end
|
|
655
|
-
rows.push(line.strip.split(/\t+/).map { |s| s.sub(/\A\./, '') })
|
|
656
|
-
end
|
|
657
|
-
rows = adjust_n_cols(rows)
|
|
658
|
-
error 'no rows in the table' if rows.empty?
|
|
659
|
-
|
|
660
645
|
if id
|
|
661
646
|
puts %Q(<div id="#{normalize_id(id)}" class="table">)
|
|
662
647
|
else
|
|
663
648
|
puts %Q(<div class="table">)
|
|
664
649
|
end
|
|
665
|
-
|
|
666
|
-
if caption.present?
|
|
667
|
-
table_header id, caption
|
|
668
|
-
end
|
|
669
|
-
rescue KeyError
|
|
670
|
-
error "no such table: #{id}"
|
|
671
|
-
end
|
|
672
|
-
table_begin rows.first.size
|
|
673
|
-
if sepidx
|
|
674
|
-
sepidx.times do
|
|
675
|
-
tr(rows.shift.map { |s| th(s) })
|
|
676
|
-
end
|
|
677
|
-
rows.each do |cols|
|
|
678
|
-
tr(cols.map { |s| td(s) })
|
|
679
|
-
end
|
|
680
|
-
else
|
|
681
|
-
rows.each do |cols|
|
|
682
|
-
h, *cs = *cols
|
|
683
|
-
tr([th(h)] + cs.map { |s| td(s) })
|
|
684
|
-
end
|
|
685
|
-
end
|
|
686
|
-
table_end
|
|
650
|
+
super(lines, id, caption)
|
|
687
651
|
puts '</div>'
|
|
688
652
|
end
|
|
689
653
|
|
|
@@ -718,16 +682,16 @@ module ReVIEW
|
|
|
718
682
|
end
|
|
719
683
|
|
|
720
684
|
def imgtable(lines, id, caption = nil, metric = nil)
|
|
721
|
-
unless @chapter.
|
|
685
|
+
unless @chapter.image_bound?(id)
|
|
722
686
|
warn "image not bound: #{id}"
|
|
723
|
-
image_dummy
|
|
687
|
+
image_dummy(id, caption, lines)
|
|
724
688
|
return
|
|
725
689
|
end
|
|
726
690
|
|
|
727
691
|
puts %Q(<div id="#{normalize_id(id)}" class="imgtable image">)
|
|
728
692
|
begin
|
|
729
693
|
if caption.present?
|
|
730
|
-
table_header
|
|
694
|
+
table_header(id, caption)
|
|
731
695
|
end
|
|
732
696
|
rescue KeyError
|
|
733
697
|
error "no such table: #{id}"
|
|
@@ -750,7 +714,7 @@ module ReVIEW
|
|
|
750
714
|
def comment(lines, comment = nil)
|
|
751
715
|
return unless @book.config['draft']
|
|
752
716
|
lines ||= []
|
|
753
|
-
lines.unshift
|
|
717
|
+
lines.unshift(escape(comment)) unless comment.blank?
|
|
754
718
|
str = lines.join('<br />')
|
|
755
719
|
puts %Q(<div class="draft-comment">#{str}</div>)
|
|
756
720
|
end
|
|
@@ -978,8 +942,8 @@ module ReVIEW
|
|
|
978
942
|
|
|
979
943
|
def bibpaper(lines, id, caption)
|
|
980
944
|
puts %Q(<div class="bibpaper">)
|
|
981
|
-
bibpaper_header
|
|
982
|
-
bibpaper_bibpaper
|
|
945
|
+
bibpaper_header(id, caption)
|
|
946
|
+
bibpaper_bibpaper(id, caption, lines) unless lines.empty?
|
|
983
947
|
puts '</div>'
|
|
984
948
|
end
|
|
985
949
|
|
|
@@ -1219,17 +1183,6 @@ module ReVIEW
|
|
|
1219
1183
|
@ol_num = num.to_i
|
|
1220
1184
|
end
|
|
1221
1185
|
|
|
1222
|
-
def defer_math_image(str, path, key)
|
|
1223
|
-
# for Re:VIEW >3
|
|
1224
|
-
File.open(File.join(File.dirname(path), '__IMGMATH_BODY__.tex'), 'a+') do |f|
|
|
1225
|
-
f.puts str
|
|
1226
|
-
f.puts '\\clearpage'
|
|
1227
|
-
end
|
|
1228
|
-
File.open(File.join(File.dirname(path), '__IMGMATH_BODY__.map'), 'a+') do |f|
|
|
1229
|
-
f.puts key
|
|
1230
|
-
end
|
|
1231
|
-
end
|
|
1232
|
-
|
|
1233
1186
|
def make_math_image(str, path, fontsize = 12)
|
|
1234
1187
|
# Re:VIEW 2 compatibility
|
|
1235
1188
|
fontsize2 = (fontsize * 1.2).round.to_i
|
data/lib/review/htmlutils.rb
CHANGED
|
@@ -82,7 +82,7 @@ module ReVIEW
|
|
|
82
82
|
begin
|
|
83
83
|
require 'pygments'
|
|
84
84
|
begin
|
|
85
|
-
Pygments.highlight(
|
|
85
|
+
Pygments.highlight(body,
|
|
86
86
|
options: options,
|
|
87
87
|
formatter: format,
|
|
88
88
|
lexer: lexer)
|
|
@@ -128,8 +128,7 @@ module ReVIEW
|
|
|
128
128
|
return body
|
|
129
129
|
end
|
|
130
130
|
|
|
131
|
-
|
|
132
|
-
formatter.format(lexer.lex(text))
|
|
131
|
+
formatter.format(lexer.lex(body))
|
|
133
132
|
end
|
|
134
133
|
|
|
135
134
|
def normalize_id(id)
|
data/lib/review/i18n.rb
CHANGED
|
@@ -90,7 +90,7 @@ module ReVIEW
|
|
|
90
90
|
end
|
|
91
91
|
else
|
|
92
92
|
user_i18n.each do |key, values|
|
|
93
|
-
raise KeyError, "Invalid locale file: #{path}" unless values.is_a?
|
|
93
|
+
raise KeyError, "Invalid locale file: #{path}" unless values.is_a?(Hash)
|
|
94
94
|
@store[key].merge!(values)
|
|
95
95
|
end
|
|
96
96
|
end
|
|
@@ -165,7 +165,7 @@ module ReVIEW
|
|
|
165
165
|
end
|
|
166
166
|
end
|
|
167
167
|
remove_args.reverse_each do |idx|
|
|
168
|
-
args.delete_at
|
|
168
|
+
args.delete_at(idx)
|
|
169
169
|
end
|
|
170
170
|
args_matched = (frmt.count('%') <= args.size)
|
|
171
171
|
frmt.gsub!('##', '%%')
|
data/lib/review/idgxmlbuilder.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (c) 2008-
|
|
1
|
+
# Copyright (c) 2008-2019 Minero Aoki, Kenshi Muto
|
|
2
2
|
# 2002-2007 Minero Aoki
|
|
3
3
|
#
|
|
4
4
|
# This program is free software.
|
|
@@ -16,7 +16,9 @@ module ReVIEW
|
|
|
16
16
|
include TextUtils
|
|
17
17
|
include HTMLUtils
|
|
18
18
|
|
|
19
|
-
%i[ttbold hint maru keytop labelref ref].each
|
|
19
|
+
%i[ttbold hint maru keytop labelref ref strong em].each do |e|
|
|
20
|
+
Compiler.definline(e)
|
|
21
|
+
end
|
|
20
22
|
Compiler.defsingle(:dtp, 1)
|
|
21
23
|
|
|
22
24
|
Compiler.defblock(:insn, 0..1)
|
|
@@ -165,7 +167,7 @@ module ReVIEW
|
|
|
165
167
|
end
|
|
166
168
|
|
|
167
169
|
def ul_item_begin(lines)
|
|
168
|
-
print %Q(<li aid:pstyle="ul-item">#{lines.
|
|
170
|
+
print %Q(<li aid:pstyle="ul-item">#{join_lines_to_paragraph(lines).chomp})
|
|
169
171
|
end
|
|
170
172
|
|
|
171
173
|
def ul_item_end
|
|
@@ -200,7 +202,7 @@ module ReVIEW
|
|
|
200
202
|
end
|
|
201
203
|
|
|
202
204
|
def ol_item(lines, num)
|
|
203
|
-
puts %Q(<li aid:pstyle="ol-item" olnum="#{@ol_num}" num="#{num}">#{lines.
|
|
205
|
+
puts %Q(<li aid:pstyle="ol-item" olnum="#{@ol_num}" num="#{num}">#{join_lines_to_paragraph(lines).chomp}</li>)
|
|
204
206
|
@ol_num += 1
|
|
205
207
|
end
|
|
206
208
|
|
|
@@ -222,7 +224,7 @@ module ReVIEW
|
|
|
222
224
|
end
|
|
223
225
|
|
|
224
226
|
def dd(lines)
|
|
225
|
-
puts "<dd>#{lines.
|
|
227
|
+
puts "<dd>#{join_lines_to_paragraph(lines).chomp}</dd>"
|
|
226
228
|
end
|
|
227
229
|
|
|
228
230
|
def dl_end
|
|
@@ -232,12 +234,12 @@ module ReVIEW
|
|
|
232
234
|
def paragraph(lines)
|
|
233
235
|
if @noindent.nil?
|
|
234
236
|
if lines[0] =~ /\A(\t+)/
|
|
235
|
-
puts %Q(<p inlist="#{$1.size}">#{lines.
|
|
237
|
+
puts %Q(<p inlist="#{$1.size}">#{join_lines_to_paragraph(lines).sub(/\A\t+/, '')}</p>)
|
|
236
238
|
else
|
|
237
|
-
puts "<p>#{lines
|
|
239
|
+
puts "<p>#{join_lines_to_paragraph(lines)}</p>"
|
|
238
240
|
end
|
|
239
241
|
else
|
|
240
|
-
puts %Q(<p aid:pstyle="noindent" noindent='1'>#{lines
|
|
242
|
+
puts %Q(<p aid:pstyle="noindent" noindent='1'>#{join_lines_to_paragraph(lines)}</p>)
|
|
241
243
|
@noindent = nil
|
|
242
244
|
end
|
|
243
245
|
end
|
|
@@ -269,7 +271,6 @@ module ReVIEW
|
|
|
269
271
|
end
|
|
270
272
|
|
|
271
273
|
def list_header(id, caption, _lang)
|
|
272
|
-
puts '<codelist>'
|
|
273
274
|
return true unless caption.present?
|
|
274
275
|
if get_chap.nil?
|
|
275
276
|
puts %Q(<caption>#{I18n.t('list')}#{I18n.t('format_number_without_chapter', [@chapter.list(id).number])}#{I18n.t('caption_prefix_idgxml')}#{compile_inline(caption)}</caption>)
|
|
@@ -294,14 +295,25 @@ module ReVIEW
|
|
|
294
295
|
end
|
|
295
296
|
end
|
|
296
297
|
|
|
298
|
+
def list(lines, id, caption, lang = nil)
|
|
299
|
+
puts '<codelist>'
|
|
300
|
+
begin
|
|
301
|
+
list_header(id, caption, lang)
|
|
302
|
+
rescue KeyError
|
|
303
|
+
error "no such list: #{id}"
|
|
304
|
+
end
|
|
305
|
+
list_body(id, lines, lang)
|
|
306
|
+
puts '</codelist>'
|
|
307
|
+
end
|
|
308
|
+
|
|
297
309
|
def list_body(_id, lines, _lang)
|
|
298
310
|
print '<pre>'
|
|
299
311
|
codelines_body(lines)
|
|
300
|
-
|
|
312
|
+
print '</pre>'
|
|
301
313
|
end
|
|
302
314
|
|
|
303
315
|
def emlist(lines, caption = nil, _lang = nil)
|
|
304
|
-
quotedlist
|
|
316
|
+
quotedlist(lines, 'emlist', caption)
|
|
305
317
|
end
|
|
306
318
|
|
|
307
319
|
def emlistnum(lines, caption = nil, _lang = nil)
|
|
@@ -310,7 +322,18 @@ module ReVIEW
|
|
|
310
322
|
lines.each_with_index do |line, i|
|
|
311
323
|
lines2 << detab(%Q(<span type='lineno'>) + (i + first_line_num).to_s.rjust(2) + ': </span>' + line)
|
|
312
324
|
end
|
|
313
|
-
quotedlist
|
|
325
|
+
quotedlist(lines2, 'emlistnum', caption)
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
def listnum(lines, id, caption, lang = nil)
|
|
329
|
+
puts '<codelist>'
|
|
330
|
+
begin
|
|
331
|
+
list_header(id, caption, lang)
|
|
332
|
+
rescue KeyError
|
|
333
|
+
error "no such list: #{id}"
|
|
334
|
+
end
|
|
335
|
+
listnum_body(lines, lang)
|
|
336
|
+
puts '</codelist>'
|
|
314
337
|
end
|
|
315
338
|
|
|
316
339
|
def listnum_body(lines, _lang)
|
|
@@ -329,11 +352,11 @@ module ReVIEW
|
|
|
329
352
|
print '</listinfo>' if @book.config['listinfo']
|
|
330
353
|
no += 1
|
|
331
354
|
end
|
|
332
|
-
|
|
355
|
+
print '</pre>'
|
|
333
356
|
end
|
|
334
357
|
|
|
335
358
|
def cmd(lines, caption = nil)
|
|
336
|
-
quotedlist
|
|
359
|
+
quotedlist(lines, 'cmd', caption)
|
|
337
360
|
end
|
|
338
361
|
|
|
339
362
|
def quotedlist(lines, css_class, caption)
|
|
@@ -398,7 +421,7 @@ module ReVIEW
|
|
|
398
421
|
metrics = parse_metric('idgxml', metric)
|
|
399
422
|
puts '<img>'
|
|
400
423
|
puts %Q(<Image href="file://#{@chapter.image(id).path.sub(%r{\A./}, '')}"#{metrics} />)
|
|
401
|
-
image_header
|
|
424
|
+
image_header(id, caption)
|
|
402
425
|
puts '</img>'
|
|
403
426
|
end
|
|
404
427
|
|
|
@@ -410,7 +433,7 @@ module ReVIEW
|
|
|
410
433
|
print "\n"
|
|
411
434
|
end
|
|
412
435
|
print '</pre>'
|
|
413
|
-
image_header
|
|
436
|
+
image_header(id, caption)
|
|
414
437
|
puts '</img>'
|
|
415
438
|
warn "image not bound: #{id}"
|
|
416
439
|
end
|
|
@@ -437,7 +460,7 @@ module ReVIEW
|
|
|
437
460
|
|
|
438
461
|
puts %Q(<replace idref="texblock-#{@texblockequation}">)
|
|
439
462
|
puts '<pre>'
|
|
440
|
-
|
|
463
|
+
print lines.join("\n")
|
|
441
464
|
puts '</pre>'
|
|
442
465
|
puts '</replace>'
|
|
443
466
|
|
|
@@ -447,63 +470,75 @@ module ReVIEW
|
|
|
447
470
|
end
|
|
448
471
|
|
|
449
472
|
def table(lines, id = nil, caption = nil)
|
|
450
|
-
tablewidth =
|
|
451
|
-
|
|
473
|
+
@tablewidth = nil
|
|
474
|
+
if @book.config['tableopt']
|
|
475
|
+
@tablewidth = @book.config['tableopt'].split(',')[0].to_f / @book.config['pt_to_mm_unit'].to_f
|
|
476
|
+
end
|
|
477
|
+
@col = 0
|
|
452
478
|
|
|
453
|
-
rows =
|
|
479
|
+
sepidx, rows = parse_table_rows(lines)
|
|
480
|
+
puts '<table>'
|
|
481
|
+
|
|
482
|
+
begin
|
|
483
|
+
table_header(id, caption) if caption.present?
|
|
484
|
+
rescue KeyError
|
|
485
|
+
error "no such table: #{id}"
|
|
486
|
+
end
|
|
487
|
+
|
|
488
|
+
if @tablewidth.nil?
|
|
489
|
+
print '<tbody>'
|
|
490
|
+
else
|
|
491
|
+
print %Q(<tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="#{rows.length}" aid:tcols="#{@col}">)
|
|
492
|
+
end
|
|
493
|
+
table_rows(sepidx, rows)
|
|
494
|
+
puts '</tbody></table>'
|
|
495
|
+
@tsize = nil
|
|
496
|
+
end
|
|
497
|
+
|
|
498
|
+
def parse_table_rows(lines)
|
|
454
499
|
sepidx = nil
|
|
500
|
+
rows = []
|
|
455
501
|
lines.each_with_index do |line, idx|
|
|
456
502
|
if /\A[\=\-]{12}/ =~ line
|
|
457
503
|
sepidx ||= idx
|
|
458
504
|
next
|
|
459
505
|
end
|
|
460
|
-
if tablewidth
|
|
506
|
+
if @tablewidth
|
|
461
507
|
rows.push(line.gsub(/\t\.\t/, "\tDUMMYCELLSPLITTER\t").gsub(/\t\.\.\t/, "\t.\t").gsub(/\t\.\Z/, "\tDUMMYCELLSPLITTER").gsub(/\t\.\.\Z/, "\t.").gsub(/\A\./, ''))
|
|
462
508
|
else
|
|
463
509
|
rows.push(line.gsub(/\t\.\t/, "\t\t").gsub(/\t\.\.\t/, "\t.\t").gsub(/\t\.\Z/, "\t").gsub(/\t\.\.\Z/, "\t.").gsub(/\A\./, ''))
|
|
464
510
|
end
|
|
465
511
|
col2 = rows[rows.length - 1].split(/\t/).length
|
|
466
|
-
col = col2 if col2 > col
|
|
512
|
+
@col = col2 if col2 > @col
|
|
467
513
|
end
|
|
468
514
|
error 'no rows in the table' if rows.empty?
|
|
515
|
+
[sepidx, rows]
|
|
516
|
+
end
|
|
469
517
|
|
|
470
|
-
|
|
471
|
-
|
|
518
|
+
def table_rows(sepidx, rows)
|
|
472
519
|
cellwidth = []
|
|
473
|
-
if tablewidth
|
|
520
|
+
if @tablewidth
|
|
474
521
|
if @tsize.nil?
|
|
475
|
-
col.times { |n| cellwidth[n] = tablewidth / col }
|
|
522
|
+
@col.times { |n| cellwidth[n] = @tablewidth / @col }
|
|
476
523
|
else
|
|
477
524
|
cellwidth = @tsize.split(/\s*,\s*/)
|
|
478
525
|
totallength = 0
|
|
479
526
|
cellwidth.size.times do |n|
|
|
480
527
|
cellwidth[n] = cellwidth[n].to_f / @book.config['pt_to_mm_unit'].to_f
|
|
481
528
|
totallength += cellwidth[n]
|
|
482
|
-
warn "total length exceeds limit for table: #{id}" if totallength > tablewidth
|
|
529
|
+
warn "total length exceeds limit for table: #{id}" if totallength > @tablewidth
|
|
483
530
|
end
|
|
484
|
-
if cellwidth.size < col
|
|
485
|
-
cw = (tablewidth - totallength) / (col - cellwidth.size)
|
|
531
|
+
if cellwidth.size < @col
|
|
532
|
+
cw = (@tablewidth - totallength) / (@col - cellwidth.size)
|
|
486
533
|
warn "auto cell sizing exceeds limit for table: #{id}" if cw <= 0
|
|
487
|
-
(cellwidth.size..(col - 1)).each { |i| cellwidth[i] = cw }
|
|
534
|
+
(cellwidth.size..(@col - 1)).each { |i| cellwidth[i] = cw }
|
|
488
535
|
end
|
|
489
536
|
end
|
|
490
537
|
end
|
|
491
538
|
|
|
492
|
-
begin
|
|
493
|
-
table_header id, caption if caption.present?
|
|
494
|
-
rescue KeyError
|
|
495
|
-
error "no such table: #{id}"
|
|
496
|
-
end
|
|
497
|
-
|
|
498
|
-
if tablewidth.nil?
|
|
499
|
-
print '<tbody>'
|
|
500
|
-
else
|
|
501
|
-
print %Q(<tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="#{rows.length}" aid:tcols="#{col}">)
|
|
502
|
-
end
|
|
503
|
-
|
|
504
539
|
if sepidx
|
|
505
540
|
sepidx.times do |y|
|
|
506
|
-
if tablewidth.nil?
|
|
541
|
+
if @tablewidth.nil?
|
|
507
542
|
puts %Q(<tr type="header">#{rows.shift}</tr>)
|
|
508
543
|
else
|
|
509
544
|
i = 0
|
|
@@ -514,9 +549,7 @@ module ReVIEW
|
|
|
514
549
|
end
|
|
515
550
|
end
|
|
516
551
|
end
|
|
517
|
-
trputs(tablewidth, rows, cellwidth, sepidx)
|
|
518
|
-
puts '</tbody></table>'
|
|
519
|
-
@tsize = nil
|
|
552
|
+
trputs(@tablewidth, rows, cellwidth, sepidx)
|
|
520
553
|
end
|
|
521
554
|
|
|
522
555
|
def trputs(tablewidth, rows, cellwidth, sepidx)
|
|
@@ -562,7 +595,6 @@ module ReVIEW
|
|
|
562
595
|
end
|
|
563
596
|
|
|
564
597
|
def table_end
|
|
565
|
-
print '<?dtp tablerow last?>'
|
|
566
598
|
end
|
|
567
599
|
|
|
568
600
|
def emtable(lines, caption = nil)
|
|
@@ -573,19 +605,19 @@ module ReVIEW
|
|
|
573
605
|
if @chapter.image(id).bound?
|
|
574
606
|
metrics = parse_metric('idgxml', metric)
|
|
575
607
|
puts '<table>'
|
|
576
|
-
table_header
|
|
608
|
+
table_header(id, caption) if caption.present?
|
|
577
609
|
puts %Q(<imgtable><Image href="file://#{@chapter.image(id).path.sub(%r{\A./}, '')}"#{metrics} /></imgtable>)
|
|
578
610
|
puts '</table>'
|
|
579
611
|
else
|
|
580
612
|
warn "image not bound: #{id}" if @strict
|
|
581
|
-
image_dummy
|
|
613
|
+
image_dummy(id, caption, lines)
|
|
582
614
|
end
|
|
583
615
|
end
|
|
584
616
|
|
|
585
617
|
def comment(lines, comment = nil)
|
|
586
618
|
return unless @book.config['draft']
|
|
587
619
|
lines ||= []
|
|
588
|
-
lines.unshift
|
|
620
|
+
lines.unshift(escape(comment)) unless comment.blank?
|
|
589
621
|
str = lines.join("\n")
|
|
590
622
|
print "<msg>#{str}</msg>"
|
|
591
623
|
end
|
|
@@ -691,6 +723,14 @@ module ReVIEW
|
|
|
691
723
|
%Q(<b>#{escape(str)}</b>)
|
|
692
724
|
end
|
|
693
725
|
|
|
726
|
+
def inline_em(str)
|
|
727
|
+
%Q(<em>#{escape(str)}</em>)
|
|
728
|
+
end
|
|
729
|
+
|
|
730
|
+
def inline_strong(str)
|
|
731
|
+
%Q(<strong>#{escape(str)}</strong>)
|
|
732
|
+
end
|
|
733
|
+
|
|
694
734
|
def inline_tt(str)
|
|
695
735
|
%Q(<tt>#{escape(str)}</tt>)
|
|
696
736
|
end
|
|
@@ -1115,25 +1155,31 @@ module ReVIEW
|
|
|
1115
1155
|
error "unknown chapter: #{id}"
|
|
1116
1156
|
end
|
|
1117
1157
|
|
|
1118
|
-
def
|
|
1158
|
+
def source(lines, caption, lang = nil)
|
|
1119
1159
|
puts '<source>'
|
|
1160
|
+
source_header(caption)
|
|
1161
|
+
source_body(lines, lang)
|
|
1162
|
+
puts '</source>'
|
|
1163
|
+
end
|
|
1164
|
+
|
|
1165
|
+
def source_header(caption)
|
|
1120
1166
|
puts %Q(<caption>#{compile_inline(caption)}</caption>) if caption.present?
|
|
1121
1167
|
end
|
|
1122
1168
|
|
|
1123
1169
|
def source_body(lines, _lang)
|
|
1124
1170
|
puts '<pre>'
|
|
1125
1171
|
codelines_body(lines)
|
|
1126
|
-
|
|
1172
|
+
print '</pre>'
|
|
1127
1173
|
end
|
|
1128
1174
|
|
|
1129
1175
|
def bibpaper(lines, id, caption)
|
|
1130
|
-
|
|
1131
|
-
|
|
1176
|
+
puts %Q(<bibitem id="bib-#{id}">)
|
|
1177
|
+
bibpaper_header(id, caption)
|
|
1178
|
+
bibpaper_bibpaper(id, caption, lines) unless lines.empty?
|
|
1132
1179
|
puts '</bibitem>'
|
|
1133
1180
|
end
|
|
1134
1181
|
|
|
1135
1182
|
def bibpaper_header(id, caption)
|
|
1136
|
-
puts %Q(<bibitem id="bib-#{id}">)
|
|
1137
1183
|
puts "<caption><span type='bibno'>[#{@chapter.bibpaper(id).number}] </span>#{compile_inline(caption)}</caption>" if caption.present?
|
|
1138
1184
|
end
|
|
1139
1185
|
|