review 3.2.0 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby-tex.yml +31 -0
- data/.github/workflows/ruby-win.yml +45 -0
- data/.github/workflows/ruby.yml +27 -0
- data/.rubocop.yml +167 -42
- data/.travis.yml +1 -1
- data/Dockerfile +21 -5
- data/NEWS.ja.md +428 -1
- data/NEWS.md +429 -2
- data/README.md +11 -7
- data/Rakefile +7 -2
- data/appveyor.yml +0 -20
- data/bin/review +2 -4
- data/bin/review-catalog-converter +5 -5
- data/bin/review-check +13 -17
- data/bin/review-checkdep +3 -6
- data/bin/review-compile +13 -22
- data/bin/review-epub2html +1 -4
- data/bin/review-epubmaker +3 -4
- data/bin/review-idgxmlmaker +14 -0
- data/bin/review-index +5 -86
- data/bin/review-init +1 -4
- data/bin/review-pdfmaker +1 -3
- data/bin/review-preproc +11 -13
- data/bin/review-textmaker +1 -3
- data/bin/review-update +1 -4
- data/bin/review-validate +7 -7
- data/bin/review-vol +5 -82
- data/bin/review-webmaker +1 -3
- data/doc/config.yml.sample +67 -16
- data/doc/config.yml.sample-simple +4 -3
- data/doc/format.ja.md +133 -21
- data/doc/format.md +135 -34
- data/doc/makeindex.ja.md +2 -2
- data/doc/pdfmaker.ja.md +43 -1
- data/doc/pdfmaker.md +42 -1
- data/doc/quickstart.ja.md +55 -25
- data/doc/quickstart.md +47 -17
- data/lib/review.rb +1 -1
- data/lib/review/book.rb +2 -2
- data/lib/review/book/base.rb +89 -90
- data/lib/review/book/bib.rb +21 -0
- data/lib/review/book/book_unit.rb +158 -0
- data/lib/review/book/chapter.rb +51 -29
- data/lib/review/book/index.rb +42 -248
- data/lib/review/book/index/item.rb +46 -0
- data/lib/review/book/page_metric.rb +7 -7
- data/lib/review/book/part.rb +45 -10
- data/lib/review/book/volume.rb +5 -5
- data/lib/review/builder.rb +171 -54
- data/lib/review/call_hook.rb +20 -0
- data/lib/review/catalog.rb +15 -17
- data/lib/review/compiler.rb +240 -102
- data/lib/review/configure.rb +101 -12
- data/lib/review/converter.rb +1 -1
- data/lib/review/epub2html.rb +6 -1
- data/lib/review/epubmaker.rb +120 -118
- data/lib/review/epubmaker/content.rb +113 -0
- data/lib/review/epubmaker/epubcommon.rb +372 -0
- data/lib/review/epubmaker/epubv2.rb +178 -0
- data/lib/review/epubmaker/epubv3.rb +231 -0
- data/lib/review/epubmaker/producer.rb +168 -0
- data/lib/review/epubmaker/reviewheaderlistener.rb +12 -2
- data/lib/review/epubmaker/zip_exporter.rb +84 -0
- data/lib/review/exception.rb +6 -0
- data/lib/review/extentions/string.rb +0 -4
- data/lib/review/htmlbuilder.rb +147 -149
- data/lib/review/htmlutils.rb +10 -14
- data/lib/review/i18n.rb +4 -3
- data/lib/review/idgxmlbuilder.rb +229 -103
- data/lib/review/idgxmlmaker.rb +188 -0
- data/lib/review/img_math.rb +245 -0
- data/lib/review/index_builder.rb +654 -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 +124 -41
- data/lib/review/latexbox.rb +58 -0
- data/lib/review/latexbuilder.rb +249 -97
- data/lib/review/latexutils.rb +9 -1
- data/lib/review/lineinput.rb +113 -3
- data/lib/review/logger.rb +43 -8
- data/lib/review/makerhelper.rb +13 -186
- data/lib/review/markdownbuilder.rb +75 -39
- data/lib/review/md2inaobuilder.rb +3 -5
- data/lib/review/pdfmaker.rb +88 -83
- data/lib/review/plaintextbuilder.rb +158 -83
- data/lib/review/preprocessor.rb +30 -24
- data/lib/review/rstbuilder.rb +58 -39
- data/lib/review/sec_counter.rb +14 -0
- data/lib/review/template.rb +6 -0
- data/lib/review/textmaker.rb +29 -17
- data/lib/review/textutils.rb +68 -2
- data/lib/review/tocprinter.rb +242 -97
- data/lib/review/topbuilder.rb +147 -61
- data/lib/review/update.rb +27 -28
- data/lib/review/version.rb +1 -1
- data/lib/review/volumeprinter.rb +97 -0
- data/lib/review/webmaker.rb +36 -35
- data/lib/review/webtocprinter.rb +39 -35
- data/lib/review/yamlloader.rb +4 -0
- data/review.gemspec +8 -5
- data/samples/sample-book/README.md +7 -2
- data/samples/sample-book/src/.gitignore +154 -0
- data/samples/sample-book/src/config-ebook.yml +4 -0
- data/samples/sample-book/src/config-epub2.yml +1 -1
- data/samples/sample-book/src/config-jlreq-ebook.yml +4 -0
- data/samples/sample-book/src/config-jlreq.yml +6 -0
- data/samples/sample-book/src/config.yml +3 -3
- data/samples/sample-book/src/lib/tasks/review.rake +45 -14
- data/samples/sample-book/src/lib/tasks/z01_copy_sty.rake +14 -8
- data/samples/syntax-book/Gemfile +1 -1
- data/samples/syntax-book/ch01.re +3 -1
- data/samples/syntax-book/ch02.re +28 -21
- data/samples/syntax-book/ch03.re +4 -7
- data/samples/syntax-book/config-jlreq-lualatex.yml +4 -0
- data/samples/syntax-book/config-jlreq.yml +5 -0
- data/samples/syntax-book/config-print.yml +3 -0
- data/samples/syntax-book/config.yml +1 -1
- data/samples/syntax-book/images/img3-2.png +0 -0
- data/samples/syntax-book/lib/tasks/review.rake +30 -15
- data/samples/syntax-book/lib/tasks/z01_copy_sty.rake +14 -8
- data/templates/html/_colophon.html.erb +23 -0
- data/templates/html/_colophon_history.html.erb +9 -0
- data/templates/html/_cover.html.erb +10 -0
- data/templates/html/_part_body.html.erb +6 -0
- data/templates/html/_titlepage.html.erb +20 -0
- data/templates/html/layout-html5.html.erb +6 -0
- data/templates/html/layout-xhtml1.html.erb +6 -0
- data/templates/latex/config.erb +45 -27
- data/templates/latex/layout.tex.erb +1 -0
- data/templates/latex/review-jlreq/README.md +3 -1
- data/templates/latex/review-jlreq/review-base.sty +124 -37
- data/templates/latex/review-jlreq/review-jlreq.cls +29 -22
- data/templates/latex/review-jlreq/review-style.sty +9 -1
- data/templates/latex/review-jlreq/review-tcbox.sty +348 -0
- data/templates/latex/review-jlreq/reviewmacro.sty +5 -0
- data/templates/latex/review-jsbook/README.md +46 -5
- data/templates/latex/review-jsbook/review-base.sty +111 -30
- data/templates/latex/review-jsbook/review-jsbook.cls +16 -2
- data/templates/latex/review-jsbook/review-style.sty +10 -2
- data/templates/latex/review-jsbook/review-tcbox.sty +348 -0
- data/templates/latex/review-jsbook/reviewmacro.sty +5 -0
- data/templates/opf/epubv2.opf.erb +7 -7
- data/templates/opf/epubv3.opf.erb +7 -7
- data/templates/opf/opf_manifest_epubv2.opf.erb +10 -0
- data/templates/opf/opf_manifest_epubv3.opf.erb +10 -0
- data/templates/opf/opf_metainfo_epubv2.opf.erb +17 -0
- data/templates/opf/opf_metainfo_epubv3.opf.erb +49 -0
- data/templates/opf/opf_tocx_epubv2.opf.erb +9 -0
- data/templates/opf/opf_tocx_epubv3.opf.erb +17 -0
- data/templates/web/html/layout-html5.html.erb +9 -8
- data/templates/web/html/layout-xhtml1.html.erb +6 -0
- data/test/assets/header_listener.html +35 -0
- data/test/assets/img_math/img1.png +0 -0
- data/test/assets/img_math/img2.png +0 -0
- data/test/assets/img_math/img3.png +0 -0
- data/test/assets/syntax_book_index_detail.txt +58 -0
- data/test/assets/test_template.tex +20 -9
- data/test/assets/test_template_backmatter.tex +20 -9
- data/test/book_test_helper.rb +11 -5
- data/test/run_test.rb +1 -1
- data/test/test_book.rb +123 -78
- data/test/test_book_chapter.rb +99 -56
- data/test/test_book_part.rb +3 -3
- data/test/test_builder.rb +24 -15
- data/test/test_catalog.rb +19 -42
- data/test/test_catalog_converter_cmd.rb +1 -1
- data/test/test_converter.rb +1 -0
- data/test/test_epub3maker.rb +170 -126
- data/test/test_epubmaker.rb +249 -129
- data/test/test_epubmaker_cmd.rb +16 -9
- data/test/test_helper.rb +23 -11
- data/test/test_htmlbuilder.rb +1083 -114
- data/test/test_htmlutils.rb +0 -12
- data/test/test_i18n.rb +37 -37
- data/test/test_idgxmlbuilder.rb +627 -27
- data/test/test_idgxmlmaker_cmd.rb +50 -0
- data/test/test_image_finder.rb +52 -70
- data/test/test_img_math.rb +111 -0
- data/test/test_index.rb +62 -52
- data/test/test_indexbuilder.rb +52 -0
- data/test/test_latexbuilder.rb +1189 -59
- data/test/test_latexbuilder_v2.rb +74 -34
- data/test/test_lineinput.rb +20 -93
- data/test/test_logger.rb +17 -4
- data/test/test_makerhelper.rb +2 -14
- data/test/test_markdownbuilder.rb +77 -4
- data/test/test_md2inaobuilder.rb +12 -2
- data/test/test_pdfmaker.rb +101 -12
- data/test/test_pdfmaker_cmd.rb +102 -8
- data/test/test_plaintextbuilder.rb +562 -31
- data/test/test_review_ext.rb +2 -1
- data/test/test_reviewheaderlistener.rb +49 -0
- data/test/test_rstbuilder.rb +58 -5
- data/test/test_sec_counter.rb +156 -0
- data/test/test_template.rb +12 -2
- data/test/test_textmaker_cmd.rb +58 -0
- data/test/test_textutils.rb +109 -2
- data/test/test_tocprinter.rb +46 -0
- data/test/test_topbuilder.rb +400 -17
- data/test/test_update.rb +53 -44
- data/test/test_webtocprinter.rb +75 -43
- data/test/test_yamlloader.rb +13 -0
- data/test/test_zip_exporter.rb +5 -6
- data/vendor/gentombow/LICENSE +1 -1
- data/vendor/gentombow/Makefile +0 -1
- data/vendor/gentombow/bounddvi-en.pdf +0 -0
- data/vendor/gentombow/bounddvi-en.tex +1 -0
- data/vendor/gentombow/bounddvi.pdf +0 -0
- data/vendor/gentombow/bounddvi.sty +30 -7
- data/vendor/gentombow/bounddvi.tex +1 -0
- data/vendor/gentombow/create_archive.sh +1 -0
- data/vendor/gentombow/gentombow-ja.pdf +0 -0
- data/vendor/gentombow/gentombow-ja.tex +9 -0
- data/vendor/gentombow/gentombow.pdf +0 -0
- data/vendor/gentombow/gentombow.sty +32 -10
- data/vendor/gentombow/gentombow.tex +8 -0
- data/vendor/gentombow/tests/gentombow-01-pdfx.tex +8 -0
- data/vendor/gentombow/tests/gentombow-02-pdfx.tex +8 -0
- data/vendor/jsclasses/LICENSE +1 -1
- data/vendor/jsclasses/Makefile +3 -2
- data/vendor/jsclasses/create_archive.sh +5 -5
- data/vendor/jsclasses/jis/Makefile +3 -2
- data/vendor/jsclasses/jis/jsarticle.cls +74 -31
- data/vendor/jsclasses/jis/jsbook.cls +74 -31
- data/vendor/jsclasses/jis/jsclasses.dtx +176 -36
- data/vendor/jsclasses/jis/jsclasses.ins +15 -5
- data/vendor/jsclasses/jis/jslogo.dtx +4 -4
- data/vendor/jsclasses/jis/jslogo.ins +9 -0
- data/vendor/jsclasses/jis/jslogo.sty +4 -16
- data/vendor/jsclasses/jis/jspf.cls +73 -30
- data/vendor/jsclasses/jis/jsreport.cls +74 -31
- data/vendor/jsclasses/jis/jsverb.ins +9 -0
- data/vendor/jsclasses/jis/jsverb.sty +1 -13
- data/vendor/jsclasses/jis/kiyou.cls +74 -31
- data/vendor/jsclasses/jis/minijs.sty +65 -22
- data/vendor/jsclasses/jis/okumacro.dtx +4 -5
- data/vendor/jsclasses/jis/okumacro.ins +9 -0
- data/vendor/jsclasses/jis/okumacro.sty +4 -17
- data/vendor/jsclasses/jis/okuverb.ins +9 -0
- data/vendor/jsclasses/jis/okuverb.sty +1 -13
- data/vendor/jsclasses/jis/winjis.sty +23 -19
- data/vendor/jsclasses/jsarticle.cls +74 -31
- data/vendor/jsclasses/jsbook.cls +74 -31
- data/vendor/jsclasses/jsclasses.dtx +176 -36
- data/vendor/jsclasses/jsclasses.ins +15 -5
- data/vendor/jsclasses/jsclasses.pdf +0 -0
- data/vendor/jsclasses/jslogo.dtx +4 -4
- data/vendor/jsclasses/jslogo.ins +9 -0
- data/vendor/jsclasses/jslogo.pdf +0 -0
- data/vendor/jsclasses/jslogo.sty +4 -16
- data/vendor/jsclasses/jspf.cls +73 -30
- data/vendor/jsclasses/jsreport.cls +74 -31
- data/vendor/jsclasses/jsverb.ins +9 -0
- data/vendor/jsclasses/jsverb.pdf +0 -0
- data/vendor/jsclasses/jsverb.sty +1 -13
- data/vendor/jsclasses/kiyou.cls +74 -31
- data/vendor/jsclasses/minijs.sty +68 -22
- data/vendor/jsclasses/okumacro.dtx +4 -5
- data/vendor/jsclasses/okumacro.ins +9 -0
- data/vendor/jsclasses/okumacro.pdf +0 -0
- data/vendor/jsclasses/okumacro.sty +4 -17
- data/vendor/jsclasses/okuverb.ins +9 -0
- data/vendor/jsclasses/okuverb.pdf +0 -0
- data/vendor/jsclasses/okuverb.sty +1 -13
- data/vendor/jsclasses/tests/relfont.tex +10 -0
- data/vendor/jsclasses/winjis.sty +23 -19
- metadata +136 -23
- data/.rubocop_todo.yml +0 -7
- data/lib/epubmaker.rb +0 -23
- data/lib/epubmaker/content.rb +0 -110
- data/lib/epubmaker/epubcommon.rb +0 -441
- data/lib/epubmaker/epubv2.rb +0 -143
- data/lib/epubmaker/epubv3.rb +0 -233
- data/lib/epubmaker/producer.rb +0 -375
- data/lib/epubmaker/zip_exporter.rb +0 -81
- data/lib/lineinput.rb +0 -155
- data/lib/review/book/compilable.rb +0 -173
- data/lib/review/tocparser.rb +0 -271
- data/samples/syntax-book/review-ext.rb +0 -14
- data/test/test_tocparser.rb +0 -25
@@ -14,10 +14,10 @@ class LATEXBuidlerV2Test < Test::Unit::TestCase
|
|
14
14
|
'secnolevel' => 2, # for IDGXMLBuilder, EPUBBuilder
|
15
15
|
'toclevel' => 2,
|
16
16
|
'stylesheet' => nil, # for EPUBBuilder
|
17
|
-
'image_scale2width' => false,
|
18
17
|
'texcommand' => 'uplatex',
|
19
18
|
'review_version' => '2.0'
|
20
19
|
)
|
20
|
+
@config['pdfmaker']['image_scale2width'] = nil
|
21
21
|
@book = Book::Base.new
|
22
22
|
@book.config = @config
|
23
23
|
@compiler = ReVIEW::Compiler.new(@builder)
|
@@ -221,12 +221,18 @@ EOS
|
|
221
221
|
|
222
222
|
def test_inline_hd_chap
|
223
223
|
def @chapter.headline_index
|
224
|
-
|
225
|
-
Book::HeadlineIndex.new(
|
224
|
+
item = Book::Index::Item.new('chap1|test', [1, 1], 'te_st')
|
225
|
+
idx = Book::HeadlineIndex.new(self)
|
226
|
+
idx.add_item(item)
|
227
|
+
idx
|
226
228
|
end
|
227
229
|
|
228
230
|
@config['secnolevel'] = 3
|
229
231
|
actual = compile_inline('test @<hd>{chap1|test} test2')
|
232
|
+
assert_equal 'test \reviewsecref{「1.1.1 te\\textunderscore{}st」}{sec:1-1-1} test2', actual
|
233
|
+
|
234
|
+
@config['chapterlink'] = nil
|
235
|
+
actual = compile_inline('test @<hd>{chap1|test} test2')
|
230
236
|
assert_equal 'test 「1.1.1 te\\textunderscore{}st」 test2', actual
|
231
237
|
end
|
232
238
|
|
@@ -251,9 +257,9 @@ EOS
|
|
251
257
|
end
|
252
258
|
|
253
259
|
def test_inline_idx_yomi
|
260
|
+
require 'nkf'
|
254
261
|
begin
|
255
262
|
require 'MeCab'
|
256
|
-
require 'nkf'
|
257
263
|
rescue LoadError
|
258
264
|
$stderr.puts 'skip test_inline_idx_yomi (cannot find MeCab)'
|
259
265
|
return true
|
@@ -276,7 +282,7 @@ EOS
|
|
276
282
|
end
|
277
283
|
|
278
284
|
def test_dlist
|
279
|
-
actual = compile_block(": foo\n foo.\n bar.\n")
|
285
|
+
actual = compile_block(" : foo\n foo.\n bar.\n")
|
280
286
|
expected = <<-EOS
|
281
287
|
|
282
288
|
\\begin{description}
|
@@ -289,7 +295,7 @@ EOS
|
|
289
295
|
end
|
290
296
|
|
291
297
|
def test_dlist_with_bracket
|
292
|
-
actual = compile_block(": foo[bar]\n foo.\n bar.\n")
|
298
|
+
actual = compile_block(" : foo[bar]\n foo.\n bar.\n")
|
293
299
|
expected = <<-EOS
|
294
300
|
|
295
301
|
\\begin{description}
|
@@ -660,9 +666,11 @@ EOS
|
|
660
666
|
expected = <<-EOS
|
661
667
|
\\begin{reviewminicolumn}
|
662
668
|
\\reviewminicolumntitle{this is \\textbf{test}\\textless{}\\&\\textgreater{}\\textunderscore{}}
|
669
|
+
|
663
670
|
test1
|
664
671
|
|
665
672
|
test\\textit{2}
|
673
|
+
|
666
674
|
\\end{reviewminicolumn}
|
667
675
|
EOS
|
668
676
|
assert_equal expected, actual
|
@@ -719,7 +727,7 @@ EOS
|
|
719
727
|
|
720
728
|
def test_image
|
721
729
|
def @chapter.image(_id)
|
722
|
-
item = Book::
|
730
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
723
731
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
724
732
|
item
|
725
733
|
end
|
@@ -737,7 +745,7 @@ EOS
|
|
737
745
|
|
738
746
|
def test_image_with_metric
|
739
747
|
def @chapter.image(_id)
|
740
|
-
item = Book::
|
748
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
741
749
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
742
750
|
item
|
743
751
|
end
|
@@ -755,12 +763,12 @@ EOS
|
|
755
763
|
|
756
764
|
def test_image_with_metric_width
|
757
765
|
def @chapter.image(_id)
|
758
|
-
item = Book::
|
766
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
759
767
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
760
768
|
item
|
761
769
|
end
|
762
770
|
|
763
|
-
@config['image_scale2width'] = true
|
771
|
+
@config['pdfmaker']['image_scale2width'] = true
|
764
772
|
actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n")
|
765
773
|
expected = <<-EOS
|
766
774
|
\\begin{reviewimage}%%sampleimg
|
@@ -774,7 +782,7 @@ EOS
|
|
774
782
|
|
775
783
|
def test_image_with_metric2
|
776
784
|
def @chapter.image(_id)
|
777
|
-
item = Book::
|
785
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
778
786
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
779
787
|
item
|
780
788
|
end
|
@@ -792,12 +800,12 @@ EOS
|
|
792
800
|
|
793
801
|
def test_image_with_metric2_width
|
794
802
|
def @chapter.image(_id)
|
795
|
-
item = Book::
|
803
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
796
804
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
797
805
|
item
|
798
806
|
end
|
799
807
|
|
800
|
-
@config['image_scale2width'] = true
|
808
|
+
@config['pdfmaker']['image_scale2width'] = true
|
801
809
|
actual = compile_block("//image[sampleimg][sample photo][scale=1.2,html::class=sample,latex::ignore=params]{\n//}\n")
|
802
810
|
expected = <<-EOS
|
803
811
|
\\begin{reviewimage}%%sampleimg
|
@@ -811,7 +819,7 @@ EOS
|
|
811
819
|
|
812
820
|
def test_indepimage
|
813
821
|
def @chapter.image(_id)
|
814
|
-
item = Book::
|
822
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
815
823
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
816
824
|
item
|
817
825
|
end
|
@@ -828,7 +836,7 @@ EOS
|
|
828
836
|
|
829
837
|
def test_indepimage_without_caption
|
830
838
|
def @chapter.image(_id)
|
831
|
-
item = Book::
|
839
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
832
840
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
833
841
|
item
|
834
842
|
end
|
@@ -845,7 +853,7 @@ EOS
|
|
845
853
|
|
846
854
|
def test_indepimage_with_metric
|
847
855
|
def @chapter.image(_id)
|
848
|
-
item = Book::
|
856
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
849
857
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
850
858
|
item
|
851
859
|
end
|
@@ -862,12 +870,12 @@ EOS
|
|
862
870
|
|
863
871
|
def test_indepimage_with_metric_width
|
864
872
|
def @chapter.image(_id)
|
865
|
-
item = Book::
|
873
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
866
874
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
867
875
|
item
|
868
876
|
end
|
869
877
|
|
870
|
-
@config['image_scale2width'] = true
|
878
|
+
@config['pdfmaker']['image_scale2width'] = true
|
871
879
|
actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
|
872
880
|
expected = <<-EOS
|
873
881
|
\\begin{reviewimage}%%sampleimg
|
@@ -880,7 +888,7 @@ EOS
|
|
880
888
|
|
881
889
|
def test_indepimage_with_metric2
|
882
890
|
def @chapter.image(_id)
|
883
|
-
item = Book::
|
891
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
884
892
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
885
893
|
item
|
886
894
|
end
|
@@ -897,7 +905,7 @@ EOS
|
|
897
905
|
|
898
906
|
def test_indepimage_without_caption_but_with_metric
|
899
907
|
def @chapter.image(_id)
|
900
|
-
item = Book::
|
908
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
901
909
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
902
910
|
item
|
903
911
|
end
|
@@ -1008,7 +1016,7 @@ EOS
|
|
1008
1016
|
|
1009
1017
|
def test_imgtable
|
1010
1018
|
def @chapter.image(_id)
|
1011
|
-
item = Book::
|
1019
|
+
item = Book::Index::Item.new('sampleimg', 1, 'sample img')
|
1012
1020
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
1013
1021
|
item
|
1014
1022
|
end
|
@@ -1029,7 +1037,7 @@ EOS
|
|
1029
1037
|
|
1030
1038
|
def test_bib
|
1031
1039
|
def @chapter.bibpaper(_id)
|
1032
|
-
Book::
|
1040
|
+
Book::Index::Item.new('samplebib', 1, 'sample bib')
|
1033
1041
|
end
|
1034
1042
|
|
1035
1043
|
assert_equal '\\reviewbibref{[1]}{bib:samplebib}', compile_inline('@<bib>{samplebib}')
|
@@ -1037,7 +1045,7 @@ EOS
|
|
1037
1045
|
|
1038
1046
|
def test_bibpaper
|
1039
1047
|
def @chapter.bibpaper(_id)
|
1040
|
-
Book::
|
1048
|
+
Book::Index::Item.new('samplebib', 1, 'sample bib')
|
1041
1049
|
end
|
1042
1050
|
|
1043
1051
|
actual = compile_block("//bibpaper[samplebib][sample bib @<b>{bold}]{\na\nb\n//}\n")
|
@@ -1053,7 +1061,7 @@ EOS
|
|
1053
1061
|
|
1054
1062
|
def test_bibpaper_without_body
|
1055
1063
|
def @chapter.bibpaper(_id)
|
1056
|
-
Book::
|
1064
|
+
Book::Index::Item.new('samplebib', 1, 'sample bib')
|
1057
1065
|
end
|
1058
1066
|
|
1059
1067
|
actual = compile_block("//bibpaper[samplebib][sample bib]\n")
|
@@ -1283,13 +1291,17 @@ EOS
|
|
1283
1291
|
actual = compile_block("//note{\nA\n\nB\n//}\n//note[caption]{\nA\n//}")
|
1284
1292
|
expected = <<-EOS
|
1285
1293
|
\\begin{reviewminicolumn}
|
1294
|
+
|
1286
1295
|
A
|
1287
1296
|
|
1288
1297
|
B
|
1298
|
+
|
1289
1299
|
\\end{reviewminicolumn}
|
1290
1300
|
\\begin{reviewminicolumn}
|
1291
1301
|
\\reviewminicolumntitle{caption}
|
1302
|
+
|
1292
1303
|
A
|
1304
|
+
|
1293
1305
|
\\end{reviewminicolumn}
|
1294
1306
|
EOS
|
1295
1307
|
assert_equal expected, actual
|
@@ -1297,13 +1309,17 @@ EOS
|
|
1297
1309
|
actual = compile_block("//memo{\nA\n\nB\n//}\n//memo[caption]{\nA\n//}")
|
1298
1310
|
expected = <<-EOS
|
1299
1311
|
\\begin{reviewminicolumn}
|
1312
|
+
|
1300
1313
|
A
|
1301
1314
|
|
1302
1315
|
B
|
1316
|
+
|
1303
1317
|
\\end{reviewminicolumn}
|
1304
1318
|
\\begin{reviewminicolumn}
|
1305
1319
|
\\reviewminicolumntitle{caption}
|
1320
|
+
|
1306
1321
|
A
|
1322
|
+
|
1307
1323
|
\\end{reviewminicolumn}
|
1308
1324
|
EOS
|
1309
1325
|
assert_equal expected, actual
|
@@ -1311,13 +1327,17 @@ EOS
|
|
1311
1327
|
actual = compile_block("//info{\nA\n\nB\n//}\n//info[caption]{\nA\n//}")
|
1312
1328
|
expected = <<-EOS
|
1313
1329
|
\\begin{reviewminicolumn}
|
1330
|
+
|
1314
1331
|
A
|
1315
1332
|
|
1316
1333
|
B
|
1334
|
+
|
1317
1335
|
\\end{reviewminicolumn}
|
1318
1336
|
\\begin{reviewminicolumn}
|
1319
1337
|
\\reviewminicolumntitle{caption}
|
1338
|
+
|
1320
1339
|
A
|
1340
|
+
|
1321
1341
|
\\end{reviewminicolumn}
|
1322
1342
|
EOS
|
1323
1343
|
assert_equal expected, actual
|
@@ -1325,13 +1345,17 @@ EOS
|
|
1325
1345
|
actual = compile_block("//important{\nA\n\nB\n//}\n//important[caption]{\nA\n//}")
|
1326
1346
|
expected = <<-EOS
|
1327
1347
|
\\begin{reviewminicolumn}
|
1348
|
+
|
1328
1349
|
A
|
1329
1350
|
|
1330
1351
|
B
|
1352
|
+
|
1331
1353
|
\\end{reviewminicolumn}
|
1332
1354
|
\\begin{reviewminicolumn}
|
1333
1355
|
\\reviewminicolumntitle{caption}
|
1356
|
+
|
1334
1357
|
A
|
1358
|
+
|
1335
1359
|
\\end{reviewminicolumn}
|
1336
1360
|
EOS
|
1337
1361
|
assert_equal expected, actual
|
@@ -1339,13 +1363,17 @@ EOS
|
|
1339
1363
|
actual = compile_block("//caution{\nA\n\nB\n//}\n//caution[caption]{\nA\n//}")
|
1340
1364
|
expected = <<-EOS
|
1341
1365
|
\\begin{reviewminicolumn}
|
1366
|
+
|
1342
1367
|
A
|
1343
1368
|
|
1344
1369
|
B
|
1370
|
+
|
1345
1371
|
\\end{reviewminicolumn}
|
1346
1372
|
\\begin{reviewminicolumn}
|
1347
1373
|
\\reviewminicolumntitle{caption}
|
1374
|
+
|
1348
1375
|
A
|
1376
|
+
|
1349
1377
|
\\end{reviewminicolumn}
|
1350
1378
|
EOS
|
1351
1379
|
assert_equal expected, actual
|
@@ -1353,13 +1381,17 @@ EOS
|
|
1353
1381
|
actual = compile_block("//notice{\nA\n\nB\n//}\n//notice[caption]{\nA\n//}")
|
1354
1382
|
expected = <<-EOS
|
1355
1383
|
\\begin{reviewminicolumn}
|
1384
|
+
|
1356
1385
|
A
|
1357
1386
|
|
1358
1387
|
B
|
1388
|
+
|
1359
1389
|
\\end{reviewminicolumn}
|
1360
1390
|
\\begin{reviewminicolumn}
|
1361
1391
|
\\reviewminicolumntitle{caption}
|
1392
|
+
|
1362
1393
|
A
|
1394
|
+
|
1363
1395
|
\\end{reviewminicolumn}
|
1364
1396
|
EOS
|
1365
1397
|
assert_equal expected, actual
|
@@ -1367,13 +1399,17 @@ EOS
|
|
1367
1399
|
actual = compile_block("//warning{\nA\n\nB\n//}\n//warning[caption]{\nA\n//}")
|
1368
1400
|
expected = <<-EOS
|
1369
1401
|
\\begin{reviewminicolumn}
|
1402
|
+
|
1370
1403
|
A
|
1371
1404
|
|
1372
1405
|
B
|
1406
|
+
|
1373
1407
|
\\end{reviewminicolumn}
|
1374
1408
|
\\begin{reviewminicolumn}
|
1375
1409
|
\\reviewminicolumntitle{caption}
|
1410
|
+
|
1376
1411
|
A
|
1412
|
+
|
1377
1413
|
\\end{reviewminicolumn}
|
1378
1414
|
EOS
|
1379
1415
|
assert_equal expected, actual
|
@@ -1381,13 +1417,17 @@ EOS
|
|
1381
1417
|
actual = compile_block("//tip{\nA\n\nB\n//}\n//tip[caption]{\nA\n//}")
|
1382
1418
|
expected = <<-EOS
|
1383
1419
|
\\begin{reviewminicolumn}
|
1420
|
+
|
1384
1421
|
A
|
1385
1422
|
|
1386
1423
|
B
|
1424
|
+
|
1387
1425
|
\\end{reviewminicolumn}
|
1388
1426
|
\\begin{reviewminicolumn}
|
1389
1427
|
\\reviewminicolumntitle{caption}
|
1428
|
+
|
1390
1429
|
A
|
1430
|
+
|
1391
1431
|
\\end{reviewminicolumn}
|
1392
1432
|
EOS
|
1393
1433
|
assert_equal expected, actual
|
@@ -1424,24 +1464,24 @@ EOS
|
|
1424
1464
|
|
1425
1465
|
def test_inline_imgref
|
1426
1466
|
def @chapter.image(_id)
|
1427
|
-
item = Book::
|
1467
|
+
item = Book::Index::Item.new('sampleimg', 1, 'sample photo')
|
1428
1468
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
1429
1469
|
item
|
1430
1470
|
end
|
1431
1471
|
|
1432
|
-
actual = compile_block
|
1472
|
+
actual = compile_block("@<imgref>{sampleimg}\n")
|
1433
1473
|
expected = "\n\\reviewimageref{1.1}{image:chap1:sampleimg}「sample photo」\n"
|
1434
1474
|
assert_equal expected, actual
|
1435
1475
|
end
|
1436
1476
|
|
1437
1477
|
def test_inline_imgref2
|
1438
1478
|
def @chapter.image(_id)
|
1439
|
-
item = Book::
|
1479
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
1440
1480
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
1441
1481
|
item
|
1442
1482
|
end
|
1443
1483
|
|
1444
|
-
actual = compile_block
|
1484
|
+
actual = compile_block("@<imgref>{sampleimg}\n")
|
1445
1485
|
expected = "\n\\reviewimageref{1.1}{image:chap1:sampleimg}\n"
|
1446
1486
|
assert_equal expected, actual
|
1447
1487
|
end
|
@@ -1504,18 +1544,18 @@ EOS
|
|
1504
1544
|
end
|
1505
1545
|
|
1506
1546
|
def test_inline_unknown
|
1507
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
1547
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<img>{n}\n") }
|
1508
1548
|
assert_equal ':1: error: unknown image: n', e.message
|
1509
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
1549
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<fn>{n}\n") }
|
1510
1550
|
assert_equal ':1: error: unknown footnote: n', e.message
|
1511
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
1551
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<hd>{n}\n") }
|
1512
1552
|
assert_equal ':1: error: unknown headline: n', e.message
|
1513
1553
|
%w[list table column].each do |name|
|
1514
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
1554
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
1515
1555
|
assert_equal ":1: error: unknown #{name}: n", e.message
|
1516
1556
|
end
|
1517
1557
|
%w[chap chapref title].each do |name|
|
1518
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
1558
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
1519
1559
|
assert_equal ':1: error: key not found: "n"', e.message
|
1520
1560
|
end
|
1521
1561
|
end
|
@@ -1580,7 +1620,7 @@ EOS
|
|
1580
1620
|
end
|
1581
1621
|
|
1582
1622
|
def @chapter.image(_id)
|
1583
|
-
item = Book::
|
1623
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
1584
1624
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
1585
1625
|
item
|
1586
1626
|
end
|
data/test/test_lineinput.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'test_helper'
|
2
|
-
require 'lineinput'
|
2
|
+
require 'review/lineinput'
|
3
3
|
require 'tempfile'
|
4
4
|
require 'stringio'
|
5
5
|
|
@@ -9,7 +9,7 @@ class LineInputTest < Test::Unit::TestCase
|
|
9
9
|
li = LineInput.new(io)
|
10
10
|
assert_equal 0, li.lineno
|
11
11
|
assert !li.eof?
|
12
|
-
assert_equal "#<LineInput file=#{io.inspect} line=0>", li.inspect
|
12
|
+
assert_equal "#<ReVIEW::LineInput file=#{io.inspect} line=0>", li.inspect
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_gets
|
@@ -40,21 +40,6 @@ class LineInputTest < Test::Unit::TestCase
|
|
40
40
|
assert li.eof?
|
41
41
|
end
|
42
42
|
|
43
|
-
def test_ungets
|
44
|
-
io = StringIO.new('abc')
|
45
|
-
li = LineInput.new(io)
|
46
|
-
|
47
|
-
line = li.gets
|
48
|
-
assert_equal line, li.ungets(line)
|
49
|
-
assert_equal 0, li.lineno
|
50
|
-
assert_equal line, li.gets
|
51
|
-
|
52
|
-
li.ungets('xyz')
|
53
|
-
assert_equal 0, li.lineno
|
54
|
-
li.ungets('xyz')
|
55
|
-
assert_equal(-1, li.lineno) # XXX: OK?
|
56
|
-
end
|
57
|
-
|
58
43
|
def test_peek
|
59
44
|
li = LineInput.new(StringIO.new)
|
60
45
|
assert_equal nil, li.peek
|
@@ -71,33 +56,6 @@ class LineInputTest < Test::Unit::TestCase
|
|
71
56
|
assert li.next?
|
72
57
|
end
|
73
58
|
|
74
|
-
def test_gets_if
|
75
|
-
io = StringIO.new
|
76
|
-
li = LineInput.new(io)
|
77
|
-
assert_equal nil, li.gets_if(//)
|
78
|
-
|
79
|
-
io = StringIO.new("abc\ndef\nghi")
|
80
|
-
li = LineInput.new(io)
|
81
|
-
|
82
|
-
assert_equal "abc\n", li.gets_if(//)
|
83
|
-
assert_equal nil, li.gets_if(/^X/)
|
84
|
-
assert_equal nil, li.gets_if(/^g/)
|
85
|
-
assert_equal "def\n", li.gets_if(/^d/)
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_gets_unless
|
89
|
-
io = StringIO.new
|
90
|
-
li = LineInput.new(io)
|
91
|
-
assert_equal nil, li.gets_unless(//)
|
92
|
-
|
93
|
-
io = StringIO.new("abc\ndef\nghi")
|
94
|
-
li = LineInput.new(io)
|
95
|
-
|
96
|
-
assert_equal nil, li.gets_unless(//)
|
97
|
-
assert_equal "abc\n", li.gets_unless(/^X/)
|
98
|
-
assert_equal nil, li.gets_unless(/^d/)
|
99
|
-
end
|
100
|
-
|
101
59
|
def test_each
|
102
60
|
content = "abc\ndef\nghi"
|
103
61
|
io = StringIO.new(content)
|
@@ -112,17 +70,9 @@ class LineInputTest < Test::Unit::TestCase
|
|
112
70
|
io = StringIO.new("abc\ndef\nghi")
|
113
71
|
li = LineInput.new(io)
|
114
72
|
|
115
|
-
li.while_match(/^[ad]/)
|
116
|
-
|
117
|
-
|
118
|
-
end
|
119
|
-
|
120
|
-
def test_getlines_while
|
121
|
-
io = StringIO.new("abc\ndef\nghi")
|
122
|
-
li = LineInput.new(io)
|
123
|
-
|
124
|
-
buf = li.getlines_while(/^[ad]/)
|
125
|
-
assert_equal ["abc\n", "def\n"], buf
|
73
|
+
li.while_match(/^[ad]/) do
|
74
|
+
# skip
|
75
|
+
end
|
126
76
|
assert_equal 2, li.lineno
|
127
77
|
assert_equal 'ghi', li.gets
|
128
78
|
end
|
@@ -131,47 +81,24 @@ class LineInputTest < Test::Unit::TestCase
|
|
131
81
|
io = StringIO.new("abc\ndef\nghi")
|
132
82
|
li = LineInput.new(io)
|
133
83
|
|
134
|
-
li.until_match(/^[^a]/)
|
135
|
-
|
136
|
-
|
137
|
-
end
|
138
|
-
|
139
|
-
def test_getlines_until
|
140
|
-
io = StringIO.new("abc\ndef\nghi")
|
141
|
-
li = LineInput.new(io)
|
142
|
-
|
143
|
-
buf = li.getlines_until(/^[^a]/)
|
144
|
-
assert_equal ["abc\n"], buf
|
84
|
+
li.until_match(/^[^a]/) do
|
85
|
+
# skip
|
86
|
+
end
|
145
87
|
assert_equal 1, li.lineno
|
146
88
|
assert_equal "def\n", li.gets
|
147
89
|
end
|
148
90
|
|
149
|
-
def
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
assert_equal 5, li.lineno
|
162
|
-
|
163
|
-
data = ''
|
164
|
-
li.until_terminator(%r<\A//\}>) { |l| data << l }
|
165
|
-
assert_equal "jkl\nmno", data
|
166
|
-
assert_equal 8, li.lineno
|
167
|
-
end
|
168
|
-
|
169
|
-
def test_until_terminator2
|
170
|
-
io = StringIO.new("abc\ndef\n//}\nghi\n//}")
|
171
|
-
li = LineInput.new(io)
|
172
|
-
|
173
|
-
data = li.getblock(%r<\A//\}>)
|
174
|
-
assert_equal ["abc\n", "def\n"], data
|
175
|
-
assert_equal 3, li.lineno
|
91
|
+
def test_invalid_control_sequence
|
92
|
+
0.upto(31) do |n|
|
93
|
+
content = n.chr
|
94
|
+
io = StringIO.new(content)
|
95
|
+
li = ReVIEW::LineInput.new(io)
|
96
|
+
if [9, 10, 13].include?(n) # TAB, LF, CR
|
97
|
+
assert_equal content, li.gets
|
98
|
+
else
|
99
|
+
e = assert_raise(ReVIEW::SyntaxError) { li.gets }
|
100
|
+
assert_match(/found invalid control/, e.message)
|
101
|
+
end
|
102
|
+
end
|
176
103
|
end
|
177
104
|
end
|