review 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +43 -1
- data/.rubocop_todo.yml +0 -5
- data/.travis.yml +2 -1
- data/README.md +2 -1
- data/appveyor.yml +10 -1
- data/bin/review-init +12 -0
- data/bin/review-validate +5 -4
- data/doc/NEWS.ja.md +82 -0
- data/doc/NEWS.md +84 -0
- data/doc/config.yml.sample +1 -0
- data/doc/config.yml.sample-simple +77 -0
- data/doc/customize_epub.md +47 -0
- data/doc/preproc.ja.md +153 -0
- data/doc/preproc.md +160 -0
- data/lib/epubmaker/producer.rb +6 -3
- data/lib/lineinput.rb +4 -4
- data/lib/review/book/base.rb +4 -0
- data/lib/review/book/compilable.rb +3 -3
- data/lib/review/book/index.rb +3 -24
- data/lib/review/book/part.rb +6 -2
- data/lib/review/configure.rb +4 -2
- data/lib/review/htmlbuilder.rb +17 -10
- data/lib/review/htmlutils.rb +4 -5
- data/lib/review/i18n.rb +17 -11
- data/lib/review/i18n.yml +6 -0
- data/lib/review/idgxmlbuilder.rb +2 -2
- data/lib/review/makerhelper.rb +1 -1
- data/lib/review/markdownbuilder.rb +12 -1
- data/lib/review/md2inaobuilder.rb +66 -0
- data/lib/review/pdfmaker.rb +20 -7
- data/lib/review/preprocessor.rb +2 -2
- data/lib/review/topbuilder.rb +18 -0
- data/lib/review/version.rb +1 -1
- data/lib/review/webtocprinter.rb +9 -2
- data/templates/LICENSE +20 -0
- data/templates/README.md +8 -0
- data/templates/latex/layout.tex.erb +58 -36
- data/templates/web/html/layout-html5.html.erb +1 -1
- data/test/assets/test_template.tex +44 -8
- data/test/book_test_helper.rb +10 -7
- data/test/sample-book/src/Rakefile +7 -0
- data/test/test_book.rb +1 -4
- data/test/test_epub3maker.rb +1 -3
- data/test/test_htmlbuilder.rb +30 -8
- data/test/test_i18n.rb +28 -0
- data/test/test_idgxmlbuilder.rb +2 -2
- data/test/test_index.rb +10 -0
- data/test/test_location.rb +30 -0
- data/test/test_markdownbuilder.rb +6 -0
- data/test/test_md2inaobuilder.rb +75 -0
- data/test/test_pdfmaker.rb +1 -0
- data/test/test_review_ext.rb +3 -2
- data/test/test_topbuilder.rb +11 -0
- data/test/test_webtocprinter.rb +164 -0
- data/test/test_yamlloader.rb +6 -7
- metadata +14 -1
data/test/test_epub3maker.rb
CHANGED
@@ -403,9 +403,7 @@ EOT
|
|
403
403
|
end
|
404
404
|
|
405
405
|
def test_stage3_flat
|
406
|
-
@producer.merge_params({"epubmaker" =>
|
407
|
-
{"flattoc" => true, "flattocindent" => false}
|
408
|
-
})
|
406
|
+
@producer.merge_params({"epubmaker" => {"flattoc" => true, "flattocindent" => false}})
|
409
407
|
stage3
|
410
408
|
@producer.mytoc(@output)
|
411
409
|
expect = <<EOT
|
data/test/test_htmlbuilder.rb
CHANGED
@@ -433,7 +433,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
433
433
|
end
|
434
434
|
|
435
435
|
actual = compile_block("//indepimage[sampleimg][sample photo]\n")
|
436
|
-
assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" />\n<p class="caption">\n図: sample photo\n</p>\n</div>\n|, actual
|
436
|
+
assert_equal %Q|<div id="sampleimg" class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" />\n<p class="caption">\n図: sample photo\n</p>\n</div>\n|, actual
|
437
437
|
end
|
438
438
|
|
439
439
|
def test_indepimage_without_caption
|
@@ -444,7 +444,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
444
444
|
end
|
445
445
|
|
446
446
|
actual = compile_block("//indepimage[sampleimg]\n")
|
447
|
-
assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="" />\n</div>\n|, actual
|
447
|
+
assert_equal %Q|<div id="sampleimg" class="image">\n<img src="images/chap1-sampleimg.png" alt="" />\n</div>\n|, actual
|
448
448
|
end
|
449
449
|
|
450
450
|
def test_indepimage_with_metric
|
@@ -455,7 +455,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
455
455
|
end
|
456
456
|
|
457
457
|
actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
|
458
|
-
assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" class="width-120per" />\n<p class="caption">\n図: sample photo\n</p>\n</div>\n|, actual
|
458
|
+
assert_equal %Q|<div id="sampleimg" class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" class="width-120per" />\n<p class="caption">\n図: sample photo\n</p>\n</div>\n|, actual
|
459
459
|
end
|
460
460
|
|
461
461
|
def test_indepimage_with_metric2
|
@@ -466,7 +466,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
466
466
|
end
|
467
467
|
|
468
468
|
actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2, html::class=\"sample\",latex::ignore=params]\n")
|
469
|
-
assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" class="width-120per sample" />\n<p class="caption">\n図: sample photo\n</p>\n</div>\n|, actual
|
469
|
+
assert_equal %Q|<div id="sampleimg" class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" class="width-120per sample" />\n<p class="caption">\n図: sample photo\n</p>\n</div>\n|, actual
|
470
470
|
end
|
471
471
|
|
472
472
|
def test_indepimage_without_caption_but_with_metric
|
@@ -477,7 +477,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
477
477
|
end
|
478
478
|
|
479
479
|
actual = compile_block("//indepimage[sampleimg][][scale=1.2]\n")
|
480
|
-
assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="" class="width-120per" />\n</div>\n|, actual
|
480
|
+
assert_equal %Q|<div id="sampleimg" class="image">\n<img src="images/chap1-sampleimg.png" alt="" class="width-120per" />\n</div>\n|, actual
|
481
481
|
end
|
482
482
|
|
483
483
|
def test_dlist
|
@@ -536,7 +536,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
536
536
|
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_][ruby]{\ndef foo(a1, a2=:test)\n (1..3).times{|i| a.include?(:foo)}\n return true\nend\n\n//}\n")
|
537
537
|
|
538
538
|
assert_equal %Q|<div class=\"caption-code\">\n<p class=\"caption\">リスト1.1: this is <b>test</b><&>_</p>\n| +
|
539
|
-
%Q|<pre class=\"list\"><span style=\"color: #008000; font-weight: bold\">def</span> <span style=\"color: #0000FF\">foo</span>(a1, a2<span style=\"color: #666666\">=</span><span style=\"color: #19177C\">:test</span>)\n| +
|
539
|
+
%Q|<pre class=\"list language-ruby\"><span style=\"color: #008000; font-weight: bold\">def</span> <span style=\"color: #0000FF\">foo</span>(a1, a2<span style=\"color: #666666\">=</span><span style=\"color: #19177C\">:test</span>)\n| +
|
540
540
|
%Q| (<span style=\"color: #666666\">1.</span>.<span style=\"color: #666666\">3</span>)<span style=\"color: #666666\">.</span>times{<span style=\"color: #666666\">\|</span>i<span style=\"color: #666666\">\|</span> a<span style=\"color: #666666\">.</span>include?(<span style=\"color: #19177C\">:foo</span>)}\n| +
|
541
541
|
%Q| <span style=\"color: #008000; font-weight: bold\">return</span> <span style=\"color: #008000\">true</span>\n| +
|
542
542
|
%Q|<span style=\"color: #008000; font-weight: bold\">end</span>\n| +
|
@@ -561,6 +561,14 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
561
561
|
assert_equal "<div class=\"caption-code\">\n<p class=\"caption\">リスト1.1: this is <b>test</b><&>_</p>\n<pre class=\"list\">def foo(a1, a2=:test)\n (1..3).times{|i| a.include?(:foo)}\n return true\nend\n</pre>\n</div>\n", actual
|
562
562
|
end
|
563
563
|
|
564
|
+
def test_list_ext
|
565
|
+
def @chapter.list(id)
|
566
|
+
Book::ListIndex::Item.new("samplelist.rb",1)
|
567
|
+
end
|
568
|
+
actual = compile_block("//list[samplelist.rb][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
569
|
+
assert_equal %Q|<div class="caption-code">\n<p class="caption">リスト1.1: this is <b>test</b><&>_</p>\n<pre class="list language-rb">test1\ntest1.5\n\ntest<i>2</i>\n</pre>\n</div>\n|, actual
|
570
|
+
end
|
571
|
+
|
564
572
|
def test_listnum
|
565
573
|
def @chapter.list(id)
|
566
574
|
Book::ListIndex::Item.new("samplelist",1)
|
@@ -579,7 +587,7 @@ EOS
|
|
579
587
|
expected =<<-EOS
|
580
588
|
<div class="code">
|
581
589
|
<p class="caption">リスト1.1: this is <b>test</b><&>_</p>
|
582
|
-
<pre class="list"> 1: def foo(a1, a2=:test)
|
590
|
+
<pre class="list language-ruby"> 1: def foo(a1, a2=:test)
|
583
591
|
2: (1..3).times{|i| a.include?(:foo)}
|
584
592
|
3: return true
|
585
593
|
4: end
|
@@ -641,7 +649,7 @@ EOS
|
|
641
649
|
@book.config["highlight"] = {}
|
642
650
|
@book.config["highlight"]["html"] = "pygments"
|
643
651
|
actual = compile_block("//emlist[][sql]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
|
644
|
-
assert_equal "<div class=\"emlist-code\">\n<pre class=\"emlist\"><span style=\"color: #008000; font-weight: bold\">SELECT</span> <span style=\"color: #008000; font-weight: bold\">COUNT</span>(<span style=\"color: #666666\">*</span>) <span style=\"color: #008000; font-weight: bold\">FROM</span> tests <span style=\"color: #008000; font-weight: bold\">WHERE</span> tests.<span style=\"color: #008000; font-weight: bold\">no</span> <span style=\"color: #666666\">></span> <span style=\"color: #666666\">10</span> <span style=\"color: #008000; font-weight: bold\">AND</span> test.name <span style=\"color: #008000; font-weight: bold\">LIKE</span> <span style=\"color: #BA2121\">'ABC%'</span>\n</pre>\n</div>\n", actual
|
652
|
+
assert_equal "<div class=\"emlist-code\">\n<pre class=\"emlist language-sql\"><span style=\"color: #008000; font-weight: bold\">SELECT</span> <span style=\"color: #008000; font-weight: bold\">COUNT</span>(<span style=\"color: #666666\">*</span>) <span style=\"color: #008000; font-weight: bold\">FROM</span> tests <span style=\"color: #008000; font-weight: bold\">WHERE</span> tests.<span style=\"color: #008000; font-weight: bold\">no</span> <span style=\"color: #666666\">></span> <span style=\"color: #666666\">10</span> <span style=\"color: #008000; font-weight: bold\">AND</span> test.name <span style=\"color: #008000; font-weight: bold\">LIKE</span> <span style=\"color: #BA2121\">'ABC%'</span>\n</pre>\n</div>\n", actual
|
645
653
|
end
|
646
654
|
|
647
655
|
def test_emlist_caption
|
@@ -667,6 +675,20 @@ EOS
|
|
667
675
|
assert_equal expected, actual
|
668
676
|
end
|
669
677
|
|
678
|
+
def test_emlistnum_lang
|
679
|
+
@book.config["highlight"] = false
|
680
|
+
actual = compile_block("//emlistnum[cap][text]{\nlineA\nlineB\n//}\n")
|
681
|
+
expected =<<-EOS
|
682
|
+
<div class="emlistnum-code">
|
683
|
+
<p class="caption">cap</p>
|
684
|
+
<pre class="emlist language-text"> 1: lineA
|
685
|
+
2: lineB
|
686
|
+
</pre>
|
687
|
+
</div>
|
688
|
+
EOS
|
689
|
+
assert_equal expected, actual
|
690
|
+
end
|
691
|
+
|
670
692
|
def test_emlist_with_4tab
|
671
693
|
@config["tabwidth"] = 4
|
672
694
|
actual = compile_block("//emlist{\n\tlineA\n\t\tlineB\n\tlineC\n//}\n")
|
data/test/test_i18n.rb
CHANGED
@@ -153,6 +153,34 @@ class I18nTest < Test::Unit::TestCase
|
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
156
|
+
def test_custom_format_numbers
|
157
|
+
Dir.mktmpdir do |dir|
|
158
|
+
Dir.chdir(dir) do
|
159
|
+
file = File.join(dir, "locale.yml")
|
160
|
+
|
161
|
+
File.open(file, "w"){|f| f.write %Q|locale: ja\nformat_number_header: "%s-%pA:"| }
|
162
|
+
I18n.setup("ja")
|
163
|
+
assert_equal "1-B:", I18n.t("format_number_header", [1, 2])
|
164
|
+
|
165
|
+
File.open(file, "w"){|f| f.write %Q|locale: ja\nformat_number_header: "%s.%pa:"| }
|
166
|
+
I18n.setup("ja")
|
167
|
+
assert_equal "2.c:", I18n.t("format_number_header", [2, 3])
|
168
|
+
|
169
|
+
File.open(file, "w"){|f| f.write %Q|locale: ja\nformat_number_header: "%pA,%pAW:"| }
|
170
|
+
I18n.setup("ja")
|
171
|
+
assert_equal "C,D:", I18n.t("format_number_header", [3, 4])
|
172
|
+
|
173
|
+
File.open(file, "w"){|f| f.write %Q|locale: ja\nformat_number_header: "%pJ・%pJ:"| }
|
174
|
+
I18n.setup("ja")
|
175
|
+
assert_equal "十二・二十六:", I18n.t("format_number_header", [12, 26])
|
176
|
+
|
177
|
+
File.open(file, "w"){|f| f.write %Q|locale: ja\nformat_number_header: "%pdW―%pdW:"| }
|
178
|
+
I18n.setup("ja")
|
179
|
+
assert_equal "3―12:", I18n.t("format_number_header", [3, 12])
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
156
184
|
def test_ja
|
157
185
|
I18n.setup("ja")
|
158
186
|
assert_equal "図", I18n.t("image")
|
data/test/test_idgxmlbuilder.rb
CHANGED
@@ -412,7 +412,7 @@ inside column
|
|
412
412
|
===[/column]
|
413
413
|
EOS
|
414
414
|
expected =<<-EOS.chomp
|
415
|
-
<column id="column-1"><title aid:pstyle="column-title">prev column</title
|
415
|
+
<column id="column-1"><title aid:pstyle="column-title">prev column</title><?dtp level="9" section="prev column"?><p>inside prev column</p></column><column id="column-2"><title aid:pstyle="column-title">test</title><?dtp level="9" section="test"?><p>inside column</p></column>
|
416
416
|
EOS
|
417
417
|
assert_equal expected, column_helper(review)
|
418
418
|
end
|
@@ -426,7 +426,7 @@ inside column
|
|
426
426
|
=== next level
|
427
427
|
EOS
|
428
428
|
expected =<<-EOS.chomp
|
429
|
-
<column id="column-1"><title aid:pstyle="column-title">test</title
|
429
|
+
<column id="column-1"><title aid:pstyle="column-title">test</title><?dtp level="9" section="test"?><p>inside column</p></column><title aid:pstyle=\"h3\">next level</title><?dtp level="3" section="next level"?>
|
430
430
|
EOS
|
431
431
|
|
432
432
|
assert_equal expected, column_helper(review)
|
data/test/test_index.rb
CHANGED
@@ -28,6 +28,16 @@ class IndexTest < Test::Unit::TestCase
|
|
28
28
|
assert_equal 'bar\\a\\$buz', item.content
|
29
29
|
end
|
30
30
|
|
31
|
+
def test_footnote_index_key?
|
32
|
+
fn = Book::FootnoteIndex.parse(['//footnote[foo][bar]'])
|
33
|
+
assert_equal true, fn.key?('foo')
|
34
|
+
|
35
|
+
## for compatibility
|
36
|
+
# rubocop:disable Style/PreferredHashMethods
|
37
|
+
assert_equal true, fn.has_key?('foo')
|
38
|
+
# rubocop:enable Style/PreferredHashMethods
|
39
|
+
end
|
40
|
+
|
31
41
|
def test_HeadelineIndex
|
32
42
|
src = <<-EOB
|
33
43
|
= chap1
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'review/compiler'
|
3
|
+
|
4
|
+
class LocationTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_lineno
|
9
|
+
f = StringIO.new("a\nb\nc\n")
|
10
|
+
location = ReVIEW::Location.new("foo", f)
|
11
|
+
assert_equal 0, location.lineno
|
12
|
+
f.gets
|
13
|
+
assert_equal 1, location.lineno
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_string
|
17
|
+
location = ReVIEW::Location.new("foo", StringIO.new("a\nb\nc\n"))
|
18
|
+
assert_equal "foo:0", location.string
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_to_s
|
22
|
+
location = ReVIEW::Location.new("foo", StringIO.new("a\nb\nc\n"))
|
23
|
+
assert_equal "foo:0", "#{location}"
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_to_s_nil
|
27
|
+
location = ReVIEW::Location.new("foo", nil)
|
28
|
+
assert_equal "foo:nil", "#{location}"
|
29
|
+
end
|
30
|
+
end
|
@@ -139,4 +139,10 @@ BBB
|
|
139
139
|
actual = compile_block("//table{\ntestA\ttestB\n------------\ncontentA\tcontentB\n//}\n")
|
140
140
|
assert_equal "|testA|testB|\n|:--|:--|\n|contentA|contentB|\n\n", actual
|
141
141
|
end
|
142
|
+
|
143
|
+
def test_ruby
|
144
|
+
actual = compile_block("@<ruby>{謳,うた}い文句")
|
145
|
+
assert_equal "<ruby><rb>謳</rb><rp>(</rp><rt>うた</rt><rp>)</rp></ruby>い文句\n\n", actual
|
146
|
+
end
|
147
|
+
|
142
148
|
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
require 'review/compiler'
|
5
|
+
require 'review/book'
|
6
|
+
require 'review/md2inaobuilder'
|
7
|
+
require 'review/i18n'
|
8
|
+
|
9
|
+
class MD2INAOBuilderTest < Test::Unit::TestCase
|
10
|
+
include ReVIEW
|
11
|
+
|
12
|
+
def setup
|
13
|
+
@builder = MD2INAOBuilder.new()
|
14
|
+
@config = {
|
15
|
+
"secnolevel" => 2, # for IDGXMLBuilder, HTMLBuilder
|
16
|
+
"stylesheet" => nil, # for HTMLBuilder
|
17
|
+
}
|
18
|
+
@book = Book::Base.new(".")
|
19
|
+
@book.config = @config
|
20
|
+
@compiler = ReVIEW::Compiler.new(@builder)
|
21
|
+
@chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
|
22
|
+
location = Location.new(nil, nil)
|
23
|
+
@builder.bind(@compiler, @chapter, location)
|
24
|
+
I18n.setup("ja")
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_paragraph
|
28
|
+
actual = compile_block("Hello, world!")
|
29
|
+
assert_equal " Hello, world!\n\n", actual
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_cmd
|
33
|
+
actual = compile_block("//cmd{\nlineA\nlineB\n//}\n")
|
34
|
+
assert_equal "!!! cmd\nlineA\nlineB\n\n", actual
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_dlist
|
38
|
+
actual = compile_block(": foo\n foo.\n bar.\n")
|
39
|
+
assert_equal "<dl>\n<dt>foo</dt>\n<dd>foo.bar.</dd>\n</dl>\n", actual
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_list
|
43
|
+
actual = compile_block(<<-EOS)
|
44
|
+
//list[name][caption]{
|
45
|
+
AAA
|
46
|
+
BBB
|
47
|
+
//}
|
48
|
+
EOS
|
49
|
+
|
50
|
+
assert_equal <<-EOS, actual
|
51
|
+
```
|
52
|
+
●リスト1::caption
|
53
|
+
|
54
|
+
AAA
|
55
|
+
BBB
|
56
|
+
```
|
57
|
+
EOS
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_comment
|
61
|
+
actual = compile_block("//comment{\nHello, world!\n//}\n")
|
62
|
+
assert_equal "<span class=\"red\">\nHello, world!\n</span>\n", actual
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_ruby_mono
|
66
|
+
actual = compile_block("@<ruby>{謳,うた}い文句")
|
67
|
+
assert_equal " <span class='monoruby'>謳(うた)</span>い文句\n\n", actual
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_ruby_group
|
71
|
+
actual = compile_block("@<ruby>{欠伸,あくび}が出る")
|
72
|
+
assert_equal " <span class='groupruby'>欠伸(あくび)</span>が出る\n\n", actual
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
data/test/test_pdfmaker.rb
CHANGED
data/test/test_review_ext.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
require 'test_helper'
|
4
4
|
require 'book_test_helper'
|
5
5
|
require 'review/compiler'
|
6
|
-
require 'review/book'
|
7
6
|
require 'review/htmlbuilder'
|
8
7
|
|
9
8
|
class ReviewExtTest < Test::Unit::TestCase
|
@@ -13,6 +12,7 @@ class ReviewExtTest < Test::Unit::TestCase
|
|
13
12
|
review_ext = <<-EOB
|
14
13
|
module ReVIEW
|
15
14
|
class HTMLBuilder
|
15
|
+
attr_reader :builder_init_test
|
16
16
|
def builder_init
|
17
17
|
@builder_init_test = "test"
|
18
18
|
end
|
@@ -20,12 +20,13 @@ module ReVIEW
|
|
20
20
|
end
|
21
21
|
EOB
|
22
22
|
|
23
|
+
ReVIEW::Book::Base.clear_rubyenv ## to load review-ext.rb
|
23
24
|
mktmpbookdir('CHAPS' => "ch01.re\n",
|
24
25
|
"ch01.re" => "= test\n\ntest.\n",
|
25
26
|
"review-ext.rb" => review_ext) do |dir, book, files|
|
26
27
|
builder = ReVIEW::HTMLBuilder.new(false)
|
27
28
|
ReVIEW::Compiler.new(builder)
|
28
|
-
assert_equal "test", builder.
|
29
|
+
assert_equal "test", builder.builder_init_test
|
29
30
|
end
|
30
31
|
end
|
31
32
|
end
|
data/test/test_topbuilder.rb
CHANGED
@@ -134,6 +134,17 @@ class TOPBuidlerTest < Test::Unit::TestCase
|
|
134
134
|
assert_equal %Q|test ① test2|, actual
|
135
135
|
end
|
136
136
|
|
137
|
+
def test_inline_comment
|
138
|
+
actual = compile_inline("test @<comment>{コメント} test2")
|
139
|
+
assert_equal %Q|test test2|, actual
|
140
|
+
end
|
141
|
+
|
142
|
+
def test_inline_comment_for_draft
|
143
|
+
@config["draft"] = true
|
144
|
+
actual = compile_inline("test @<comment>{コメント} test2")
|
145
|
+
assert_equal %Q|test ◆→DTP連絡:コメント←◆ test2|, actual
|
146
|
+
end
|
147
|
+
|
137
148
|
def test_inline_in_table
|
138
149
|
actual = compile_block("//table{\n★1☆\t▲2☆\n------------\n★3☆\t▲4☆<>&\n//}\n")
|
139
150
|
assert_equal %Q|★★1☆☆\t★▲2☆☆\n★3☆\t▲4☆<>&\n◆→終了:表←◆\n\n|, actual
|
@@ -0,0 +1,164 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'review/webtocprinter'
|
3
|
+
require 'book_test_helper'
|
4
|
+
|
5
|
+
class WEBTOCPrinterTest < Test::Unit::TestCase
|
6
|
+
include ReVIEW
|
7
|
+
include BookTestHelper
|
8
|
+
|
9
|
+
def setup
|
10
|
+
I18n.setup
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_webtocprinter_null
|
14
|
+
dummy_book = ReVIEW::Book::Base.load
|
15
|
+
chap = ReVIEW::Book::Chapter.new(dummy_book, 1, '-', nil, StringIO.new)
|
16
|
+
str = WEBTOCPrinter.book_to_string(dummy_book)
|
17
|
+
expect = <<-EOB
|
18
|
+
<ul class="book-toc">
|
19
|
+
<li><a href="index.html">TOP</a></li>
|
20
|
+
</ul>
|
21
|
+
EOB
|
22
|
+
assert_equal expect, str
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_webtocprinter_with_chapters
|
26
|
+
catalog_yml = <<-EOB
|
27
|
+
CHAPS:
|
28
|
+
- ch1.re
|
29
|
+
- ch2.re
|
30
|
+
EOB
|
31
|
+
mktmpbookdir 'catalog.yml' => catalog_yml,
|
32
|
+
'ch1.re' => "= ch. 1\n\n111\n",
|
33
|
+
'ch2.re' => "= ch. 2\n\n222\n" do |dir, book, files|
|
34
|
+
str = WEBTOCPrinter.book_to_string(book)
|
35
|
+
expect = <<-EOB
|
36
|
+
<ul class="book-toc">
|
37
|
+
<li><a href="index.html">TOP</a></li>
|
38
|
+
<li><a href="./ch1.html">1 ch. 1</a></li>
|
39
|
+
<li><a href="./ch2.html">2 ch. 2</a></li>
|
40
|
+
</ul>
|
41
|
+
EOB
|
42
|
+
assert_equal expect, str
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_webtocprinter_with_parts
|
47
|
+
catalog_yml = <<-EOB
|
48
|
+
CHAPS:
|
49
|
+
- part1:
|
50
|
+
- ch1.re
|
51
|
+
- part2:
|
52
|
+
- ch2.re
|
53
|
+
EOB
|
54
|
+
mktmpbookdir 'catalog.yml' => catalog_yml,
|
55
|
+
'ch1.re' => "= ch. 1\n\n111\n",
|
56
|
+
'ch2.re' => "= ch. 2\n\n222\n" do |dir, book, files|
|
57
|
+
str = WEBTOCPrinter.book_to_string(book)
|
58
|
+
expect = <<-EOB
|
59
|
+
<ul class="book-toc">
|
60
|
+
<li><a href="index.html">TOP</a></li>
|
61
|
+
<li>I part1
|
62
|
+
<ul>
|
63
|
+
<li><a href="./ch1.html">1 ch. 1</a></li>
|
64
|
+
</ul>
|
65
|
+
</li>
|
66
|
+
<li>II part2
|
67
|
+
<ul>
|
68
|
+
<li><a href="./ch2.html">2 ch. 2</a></li>
|
69
|
+
</ul>
|
70
|
+
</li>
|
71
|
+
</ul>
|
72
|
+
EOB
|
73
|
+
assert_equal expect, str
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_webtocprinter_with_partfiles
|
78
|
+
catalog_yml = <<-EOB
|
79
|
+
CHAPS:
|
80
|
+
- p1.re:
|
81
|
+
- ch1.re
|
82
|
+
- p2.re:
|
83
|
+
- ch2.re
|
84
|
+
EOB
|
85
|
+
mktmpbookdir 'catalog.yml' => catalog_yml,
|
86
|
+
'p1.re' => "= This is PART1\n\np111\n",
|
87
|
+
'p2.re' => "= This is PART2\n\np111\n",
|
88
|
+
'ch1.re' => "= ch. 1\n\n111\n",
|
89
|
+
'ch2.re' => "= ch. 2\n\n222\n" do |dir, book, files|
|
90
|
+
str = WEBTOCPrinter.book_to_string(book)
|
91
|
+
expect = <<-EOB
|
92
|
+
<ul class="book-toc">
|
93
|
+
<li><a href="index.html">TOP</a></li>
|
94
|
+
<li><a href="p1.html">I This is PART1</a>
|
95
|
+
<ul>
|
96
|
+
<li><a href="./ch1.html">1 ch. 1</a></li>
|
97
|
+
</ul>
|
98
|
+
</li>
|
99
|
+
<li><a href="p2.html">II This is PART2</a>
|
100
|
+
<ul>
|
101
|
+
<li><a href="./ch2.html">2 ch. 2</a></li>
|
102
|
+
</ul>
|
103
|
+
</li>
|
104
|
+
</ul>
|
105
|
+
EOB
|
106
|
+
assert_equal expect, str
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_webtocprinter_full
|
111
|
+
catalog_yml = <<-EOB
|
112
|
+
PREDEF:
|
113
|
+
- pre1.re
|
114
|
+
- pre2.re
|
115
|
+
CHAPS:
|
116
|
+
- part1.re:
|
117
|
+
- ch1.re
|
118
|
+
- part2.re:
|
119
|
+
- ch2.re
|
120
|
+
APPENDIX:
|
121
|
+
- app1.re
|
122
|
+
- app2.re
|
123
|
+
POSTDEF:
|
124
|
+
- post1.re
|
125
|
+
- post2.re
|
126
|
+
EOB
|
127
|
+
mktmpbookdir 'catalog.yml' => catalog_yml,
|
128
|
+
'pre1.re' => "= PRE1\n\npre111\n",
|
129
|
+
'pre2.re' => "= PRE2\n\npre222\n",
|
130
|
+
'app1.re' => "= APP1\n\napp111\n",
|
131
|
+
'app2.re' => "= APP2\n\napp222\n",
|
132
|
+
'part1.re' => "= PART1\n\np111\n",
|
133
|
+
'part2.re' => "= PART2\n\np111\n",
|
134
|
+
'post1.re' => "= POST1\n\npo111\n",
|
135
|
+
'post2.re' => "= POST2\n\npo222\n",
|
136
|
+
'ch1.re' => "= ch. 1\n\n111\n",
|
137
|
+
'ch2.re' => "= ch. 2\n\n222\n" do |dir, book, files|
|
138
|
+
str = WEBTOCPrinter.book_to_string(book)
|
139
|
+
expect = <<-EOB
|
140
|
+
<ul class="book-toc">
|
141
|
+
<li><a href="index.html">TOP</a></li>
|
142
|
+
<li><a href="./pre1.html">PRE1</a></li>
|
143
|
+
<li><a href="./pre2.html">PRE2</a></li>
|
144
|
+
<li><a href="part1.html">I PART1</a>
|
145
|
+
<ul>
|
146
|
+
<li><a href="./ch1.html">1 ch. 1</a></li>
|
147
|
+
</ul>
|
148
|
+
</li>
|
149
|
+
<li><a href="part2.html">II PART2</a>
|
150
|
+
<ul>
|
151
|
+
<li><a href="./ch2.html">2 ch. 2</a></li>
|
152
|
+
</ul>
|
153
|
+
</li>
|
154
|
+
<li><a href="./app1.html">APP1</a></li>
|
155
|
+
<li><a href="./app2.html">APP2</a></li>
|
156
|
+
<li><a href="./post1.html">POST1</a></li>
|
157
|
+
<li><a href="./post2.html">POST2</a></li>
|
158
|
+
</ul>
|
159
|
+
EOB
|
160
|
+
assert_equal expect, str
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
end
|