review-peg 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +36 -0
- data/.rubocop.yml +47 -0
- data/.rubocop_todo.yml +605 -0
- data/.travis.yml +18 -0
- data/COPYING +515 -0
- data/ChangeLog +2449 -0
- data/Dockerfile +22 -0
- data/Gemfile +6 -0
- data/README.rdoc +81 -0
- data/Rakefile +51 -0
- data/bin/review-catalog-converter-peg +129 -0
- data/bin/review-check-peg +169 -0
- data/bin/review-checkdep-peg +63 -0
- data/bin/review-compile-peg +202 -0
- data/bin/review-epubmaker-legacy-peg +1024 -0
- data/bin/review-epubmaker-peg +44 -0
- data/bin/review-index-peg +110 -0
- data/bin/review-init-peg +151 -0
- data/bin/review-pdfmaker-peg +18 -0
- data/bin/review-preproc-peg +131 -0
- data/bin/review-validate-peg +51 -0
- data/bin/review-vol-peg +100 -0
- data/debian/README.Debian +12 -0
- data/debian/README.source +5 -0
- data/debian/changelog +5 -0
- data/debian/compat +1 -0
- data/debian/control +22 -0
- data/debian/copyright +62 -0
- data/debian/docs +6 -0
- data/debian/manpage.1.ex +59 -0
- data/debian/patches/path.diff +91 -0
- data/debian/patches/series +1 -0
- data/debian/review.install +13 -0
- data/debian/review.links +4 -0
- data/debian/rules +13 -0
- data/debian/source/format +1 -0
- data/doc/NEWS.ja.md +350 -0
- data/doc/NEWS.md +354 -0
- data/doc/catalog.ja.md +53 -0
- data/doc/catalog.md +52 -0
- data/doc/format.ja.md +734 -0
- data/doc/format.md +746 -0
- data/doc/format_idg.ja.md +203 -0
- data/doc/quickstart.ja.md +222 -0
- data/doc/quickstart.md +252 -0
- data/doc/ruby-uuid/README +11 -0
- data/doc/ruby-uuid/README.ja +34 -0
- data/doc/sample.css +108 -0
- data/doc/sample.yml +238 -0
- data/lib/epubmaker.rb +24 -0
- data/lib/epubmaker/content.rb +93 -0
- data/lib/epubmaker/epubcommon.rb +424 -0
- data/lib/epubmaker/epubv2.rb +139 -0
- data/lib/epubmaker/epubv3.rb +222 -0
- data/lib/epubmaker/producer.rb +330 -0
- data/lib/lineinput.rb +107 -0
- data/lib/review.rb +3 -0
- data/lib/review/book.rb +43 -0
- data/lib/review/book/base.rb +401 -0
- data/lib/review/book/chapter.rb +100 -0
- data/lib/review/book/compilable.rb +184 -0
- data/lib/review/book/image_finder.rb +71 -0
- data/lib/review/book/index.rb +413 -0
- data/lib/review/book/page_metric.rb +47 -0
- data/lib/review/book/part.rb +54 -0
- data/lib/review/book/volume.rb +67 -0
- data/lib/review/builder.rb +452 -0
- data/lib/review/catalog.rb +52 -0
- data/lib/review/compiler.rb +5183 -0
- data/lib/review/compiler/literals_1_9.kpeg +22 -0
- data/lib/review/compiler/literals_1_9.rb +435 -0
- data/lib/review/configure.rb +64 -0
- data/lib/review/epubbuilder.rb +18 -0
- data/lib/review/epubmaker.rb +480 -0
- data/lib/review/ewbbuilder.rb +381 -0
- data/lib/review/exception.rb +21 -0
- data/lib/review/extentions.rb +4 -0
- data/lib/review/extentions/array.rb +25 -0
- data/lib/review/extentions/object.rb +9 -0
- data/lib/review/extentions/string.rb +33 -0
- data/lib/review/htmlbuilder.rb +1166 -0
- data/lib/review/htmllayout.rb +41 -0
- data/lib/review/htmltoc.rb +45 -0
- data/lib/review/htmlutils.rb +90 -0
- data/lib/review/i18n.rb +96 -0
- data/lib/review/i18n.yml +169 -0
- data/lib/review/idgxmlbuilder.rb +1233 -0
- data/lib/review/inaobuilder.rb +357 -0
- data/lib/review/latexbuilder.rb +941 -0
- data/lib/review/latexindex.rb +35 -0
- data/lib/review/latexutils.rb +95 -0
- data/lib/review/layout.tex.erb +340 -0
- data/lib/review/lineinput.rb +17 -0
- data/lib/review/location.rb +24 -0
- data/lib/review/makerhelper.rb +67 -0
- data/lib/review/markdownbuilder.rb +339 -0
- data/lib/review/node.rb +288 -0
- data/lib/review/pdfmaker.rb +332 -0
- data/lib/review/preprocessor.rb +530 -0
- data/lib/review/review.kpeg +745 -0
- data/lib/review/sec_counter.rb +69 -0
- data/lib/review/template.rb +21 -0
- data/lib/review/textbuilder.rb +17 -0
- data/lib/review/textutils.rb +16 -0
- data/lib/review/tocparser.rb +348 -0
- data/lib/review/tocprinter.rb +205 -0
- data/lib/review/topbuilder.rb +796 -0
- data/lib/review/unfold.rb +138 -0
- data/lib/review/version.rb +3 -0
- data/lib/uuid.rb +312 -0
- data/review.gemspec +32 -0
- data/templates/html/layout-html5.html.erb +17 -0
- data/templates/html/layout-xhtml1.html.erb +20 -0
- data/templates/ncx/epubv2.ncx.erb +11 -0
- data/templates/opf/epubv2.opf.erb +21 -0
- data/templates/opf/epubv3.opf.erb +18 -0
- data/templates/xml/container.xml.erb +6 -0
- data/test/CHAPS +2 -0
- data/test/assets/test.xml.erb +3 -0
- data/test/assets/test_template.tex +255 -0
- data/test/assets/test_template_backmatter.tex +32 -0
- data/test/bib.re +13 -0
- data/test/book_test_helper.rb +35 -0
- data/test/sample-book/README.md +7 -0
- data/test/sample-book/src/Rakefile +58 -0
- data/test/sample-book/src/_cover.html +3 -0
- data/test/sample-book/src/catalog.yml +10 -0
- data/test/sample-book/src/ch01.re +71 -0
- data/test/sample-book/src/ch02.re +3 -0
- data/test/sample-book/src/config.yml +186 -0
- data/test/sample-book/src/images/ch01-imgsample.jpg +0 -0
- data/test/sample-book/src/images/cover.jpg +0 -0
- data/test/sample-book/src/preface.re +15 -0
- data/test/sample-book/src/sty/jumoline.sty +310 -0
- data/test/sample-book/src/sty/reviewmacro.sty +39 -0
- data/test/sample-book/src/style.css +251 -0
- data/test/sample-book/src/vendor/jumoline/README +29 -0
- data/test/sample-book/src/vendor/jumoline/jumoline.dtx +2988 -0
- data/test/sample-book/src/vendor/jumoline/jumoline.ins +6 -0
- data/test/test.re +43 -0
- data/test/test_book.rb +556 -0
- data/test/test_book_chapter.rb +280 -0
- data/test/test_book_part.rb +54 -0
- data/test/test_builder.rb +80 -0
- data/test/test_catalog.rb +119 -0
- data/test/test_catalog_converter_cmd.rb +73 -0
- data/test/test_compiler.rb +92 -0
- data/test/test_configure.rb +50 -0
- data/test/test_epub3maker.rb +529 -0
- data/test/test_epubmaker.rb +569 -0
- data/test/test_epubmaker_cmd.rb +40 -0
- data/test/test_helper.rb +92 -0
- data/test/test_htmlbuilder.rb +1114 -0
- data/test/test_htmltoc.rb +32 -0
- data/test/test_htmlutils.rb +50 -0
- data/test/test_i18n.rb +180 -0
- data/test/test_idgxmlbuilder.rb +608 -0
- data/test/test_image_finder.rb +82 -0
- data/test/test_inaobuilder.rb +245 -0
- data/test/test_index.rb +174 -0
- data/test/test_latexbuilder.rb +732 -0
- data/test/test_lineinput.rb +182 -0
- data/test/test_makerhelper.rb +66 -0
- data/test/test_markdownbuilder.rb +125 -0
- data/test/test_pdfmaker.rb +171 -0
- data/test/test_pdfmaker_cmd.rb +40 -0
- data/test/test_preprocessor.rb +23 -0
- data/test/test_review_ext.rb +31 -0
- data/test/test_template.rb +26 -0
- data/test/test_textutils.rb +32 -0
- data/test/test_topbuilder.rb +291 -0
- data/test/test_uuid.rb +157 -0
- metadata +357 -0
@@ -0,0 +1,40 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
require 'tmpdir'
|
5
|
+
require 'fileutils'
|
6
|
+
require 'yaml'
|
7
|
+
require 'rbconfig'
|
8
|
+
|
9
|
+
REVIEW_PDFMAKER = File.expand_path('../bin/review-pdfmaker-peg', File.dirname(__FILE__))
|
10
|
+
|
11
|
+
class PDFMakerCmdTest < Test::Unit::TestCase
|
12
|
+
def setup
|
13
|
+
@tmpdir1 = Dir.mktmpdir
|
14
|
+
@tmpdir2 = Dir.mktmpdir
|
15
|
+
|
16
|
+
@old_rubylib = ENV['RUBYLIB']
|
17
|
+
ENV['RUBYLIB'] = File.expand_path('../lib', File.dirname(__FILE__))
|
18
|
+
end
|
19
|
+
|
20
|
+
def teardown
|
21
|
+
FileUtils.rm_rf @tmpdir1
|
22
|
+
FileUtils.rm_rf @tmpdir2
|
23
|
+
ENV['RUBYLIB'] = @old_rubylib
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_pdfmaker_cmd
|
27
|
+
if RUBY_VERSION !~ /^1.8/
|
28
|
+
config = prepare_samplebook(@tmpdir1)
|
29
|
+
builddir = @tmpdir1 + "/" + config['bookname'] + '-pdf'
|
30
|
+
assert ! File.exist?(builddir)
|
31
|
+
|
32
|
+
ruby_cmd = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
|
33
|
+
Dir.chdir(@tmpdir1) do
|
34
|
+
system("#{ruby_cmd} -S #{REVIEW_PDFMAKER} config.yml 1>/dev/null 2>/dev/null")
|
35
|
+
end
|
36
|
+
|
37
|
+
assert File.exist?(builddir)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'review/preprocessor'
|
3
|
+
require 'stringio'
|
4
|
+
|
5
|
+
class PreprocessorStripTest < Test::Unit::TestCase
|
6
|
+
include ReVIEW
|
7
|
+
|
8
|
+
def test_gets
|
9
|
+
f = StringIO.new '= Header'
|
10
|
+
s = Preprocessor::Strip.new(f)
|
11
|
+
expect = '= Header'
|
12
|
+
actual = s.gets
|
13
|
+
assert_equal expect, actual
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_gets_with_comment
|
17
|
+
f = StringIO.new '#@warn(write it later)'
|
18
|
+
s = Preprocessor::Strip.new(f)
|
19
|
+
expect = '#@#' + "\n"
|
20
|
+
actual = s.gets
|
21
|
+
assert_equal expect, actual
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
require 'book_test_helper'
|
5
|
+
require 'review/compiler'
|
6
|
+
require 'review/book'
|
7
|
+
require 'review/htmlbuilder'
|
8
|
+
|
9
|
+
class ReviewExtTest < Test::Unit::TestCase
|
10
|
+
include BookTestHelper
|
11
|
+
|
12
|
+
def test_builder_init_on_review_ext
|
13
|
+
review_ext = <<-EOB
|
14
|
+
module ReVIEW
|
15
|
+
class HTMLBuilder
|
16
|
+
def builder_init
|
17
|
+
@builder_init_test = "test"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
EOB
|
22
|
+
|
23
|
+
mktmpbookdir('CHAPS' => "ch01.re\n",
|
24
|
+
"ch01.re" => "= test\n\ntest.\n",
|
25
|
+
"review-ext.rb" => review_ext) do |dir, book, files|
|
26
|
+
builder = ReVIEW::HTMLBuilder.new(false)
|
27
|
+
c = ReVIEW::Compiler.new(builder)
|
28
|
+
assert_equal "test", builder.instance_eval{@builder_init_test}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
require 'review/template'
|
5
|
+
|
6
|
+
class TemplateTest < Test::Unit::TestCase
|
7
|
+
include ReVIEW
|
8
|
+
|
9
|
+
def setup
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_load
|
13
|
+
tmplfile = File.expand_path('./assets/test.xml.erb', File.dirname(__FILE__))
|
14
|
+
tmpl = ReVIEW::Template.load(tmplfile)
|
15
|
+
assert_equal("<test>\n<name></name>\n</test>\n",tmpl.result)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_open_with_value
|
19
|
+
tmplfile = File.expand_path('./assets/test.xml.erb', File.dirname(__FILE__))
|
20
|
+
tmpl = ReVIEW::Template.load(tmplfile)
|
21
|
+
@name = "test"
|
22
|
+
assert_equal("<test>\n<name>test</name>\n</test>\n",tmpl.result(binding))
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'review/textutils'
|
3
|
+
|
4
|
+
class TextUtilsTest < Test::Unit::TestCase
|
5
|
+
include ReVIEW::TextUtils
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@tu_nil = Object.new
|
9
|
+
@tu_nil.extend ReVIEW::TextUtils
|
10
|
+
def @tu_nil.pre_paragraph;nil;end
|
11
|
+
def @tu_nil.post_paragraph;nil;end
|
12
|
+
|
13
|
+
@tu_p = Object.new
|
14
|
+
@tu_p.extend ReVIEW::TextUtils
|
15
|
+
def @tu_p.pre_paragraph;'<p>';end
|
16
|
+
def @tu_p.post_paragraph;'</p>';end
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_detab
|
20
|
+
detabed = detab("\t\tabc")
|
21
|
+
assert_equal " abc", detabed
|
22
|
+
detabed = detab("\tabc\tbcd")
|
23
|
+
assert_equal " abc bcd", detabed
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_detab_with_arg
|
27
|
+
detabed = detab("\t\tabcd\tef",2)
|
28
|
+
assert_equal " abcd ef", detabed
|
29
|
+
detabed = detab("\tabc\tdef", 4)
|
30
|
+
assert_equal " abc def", detabed
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,291 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
require 'review/compiler'
|
5
|
+
require 'review/book'
|
6
|
+
require 'review/topbuilder'
|
7
|
+
require 'review/i18n'
|
8
|
+
|
9
|
+
class TOPBuidlerTest < Test::Unit::TestCase
|
10
|
+
include ReVIEW
|
11
|
+
|
12
|
+
def setup
|
13
|
+
@builder = TOPBuilder.new()
|
14
|
+
@config = ReVIEW::Configure.values
|
15
|
+
@config.merge!({
|
16
|
+
"secnolevel" => 2,
|
17
|
+
"language" => "ja",
|
18
|
+
})
|
19
|
+
@book = Book::Base.new(nil)
|
20
|
+
@book.config = @config
|
21
|
+
@compiler = ReVIEW::Compiler.new(@builder)
|
22
|
+
@chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
|
23
|
+
location = Location.new(nil, nil)
|
24
|
+
@builder.bind(@compiler, @chapter, location)
|
25
|
+
|
26
|
+
@builder.instance_eval do
|
27
|
+
# to ignore lineno in original method
|
28
|
+
def warn(msg)
|
29
|
+
puts msg
|
30
|
+
end
|
31
|
+
end
|
32
|
+
I18n.setup(@config["language"])
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_headline_level1
|
36
|
+
actual = compile_block("={test} this is test.\n")
|
37
|
+
assert_equal %Q|■H1■第1章 this is test.\n|, actual
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_headline_level1_without_secno
|
41
|
+
@config["secnolevel"] = 0
|
42
|
+
actual = compile_block("={test} this is test.\n")
|
43
|
+
assert_equal %Q|■H1■this is test.\n|, actual
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_headline_level2
|
47
|
+
actual = compile_block("=={test} this is test.\n")
|
48
|
+
assert_equal %Q|■H2■1.1 this is test.\n|, actual
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_headline_level3
|
52
|
+
actual = compile_block("==={test} this is test.\n")
|
53
|
+
assert_equal %Q|■H3■this is test.\n|, actual
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_headline_level3_with_secno
|
57
|
+
@config["secnolevel"] = 3
|
58
|
+
actual = compile_block("==={test} this is test.\n")
|
59
|
+
assert_equal %Q|■H3■1.0.1 this is test.\n|, actual
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_href
|
63
|
+
actual = compile_inline("@<href>{http://github.com, GitHub}")
|
64
|
+
assert_equal %Q|GitHub(△http://github.com☆)|, actual
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_href_without_label
|
68
|
+
actual = compile_inline("@<href>{http://github.com}")
|
69
|
+
assert_equal %Q|△http://github.com☆|, actual
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_inline_raw
|
73
|
+
actual = compile_inline("@<raw>{@<tt>{inline\}}")
|
74
|
+
assert_equal %Q|@<tt>{inline}|, actual
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_inline_ruby
|
78
|
+
actual = compile_inline("@<ruby>{coffin,bed}")
|
79
|
+
assert_equal %Q|coffin◆→DTP連絡:「coffin」に「bed」とルビ←◆|, actual
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_inline_kw
|
83
|
+
actual = compile_inline("@<kw>{ISO, International Organization for Standardization } @<kw>{Ruby<>}")
|
84
|
+
assert_equal %Q|★ISO☆(International Organization for Standardization) ★Ruby<>☆|, actual
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_inline_maru
|
88
|
+
actual = compile_inline("@<maru>{1}@<maru>{20}@<maru>{A}@<maru>{z}")
|
89
|
+
assert_equal %Q|1◆→丸数字1←◆20◆→丸数字20←◆A◆→丸数字A←◆z◆→丸数字z←◆|, actual
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_inline_br
|
93
|
+
actual = compile_inline("@<br>{}")
|
94
|
+
assert_equal %Q|\n|, actual
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_inline_i
|
98
|
+
actual = compile_inline("test @<i>{inline test} test2")
|
99
|
+
assert_equal %Q|test ▲inline test☆ test2|, actual
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_inline_i_and_escape
|
103
|
+
actual = compile_inline("test @<i>{inline<&;\\ test} test2")
|
104
|
+
assert_equal %Q|test ▲inline<&;\\ test☆ test2|, actual
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_inline_b
|
108
|
+
actual = compile_inline("test @<b>{inline test} test2")
|
109
|
+
assert_equal %Q|test ★inline test☆ test2|, actual
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_inline_b_and_escape
|
113
|
+
actual = compile_inline("test @<b>{inline<&;\\ test} test2")
|
114
|
+
assert_equal %Q|test ★inline<&;\\ test☆ test2|, actual
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_inline_tt
|
118
|
+
actual = compile_inline("test @<tt>{inline test} test2@<tt>{\\}}")
|
119
|
+
assert_equal %Q|test △inline test☆ test2△}☆|, actual
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_inline_tti
|
123
|
+
actual = compile_inline("test @<tti>{inline test} test2")
|
124
|
+
assert_equal %Q|test ▲inline test☆◆→等幅フォントイタ←◆ test2|, actual
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_inline_ttb
|
128
|
+
actual = compile_inline("test @<ttb>{inline test} test2")
|
129
|
+
assert_equal %Q|test ★inline test☆◆→等幅フォント太字←◆ test2|, actual
|
130
|
+
end
|
131
|
+
|
132
|
+
def test_inline_uchar
|
133
|
+
actual = compile_inline("test @<uchar>{2460} test2")
|
134
|
+
assert_equal %Q|test ① test2|, actual
|
135
|
+
end
|
136
|
+
|
137
|
+
def test_inline_in_table
|
138
|
+
actual = compile_block("//table{\n★1☆\t▲2☆\n------------\n★3☆\t▲4☆<>&\n//}\n")
|
139
|
+
assert_equal %Q|★★1☆☆\t★▲2☆☆\n★3☆\t▲4☆<>&\n◆→終了:表←◆\n\n|, actual
|
140
|
+
end
|
141
|
+
|
142
|
+
def test_paragraph
|
143
|
+
actual = compile_block("foo\nbar\n")
|
144
|
+
assert_equal %Q|foobar\n|, actual
|
145
|
+
end
|
146
|
+
|
147
|
+
def test_tabbed_paragraph
|
148
|
+
actual = compile_block("\tfoo\nbar\n")
|
149
|
+
assert_equal %Q|\tfoobar\n|, actual
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_flushright
|
153
|
+
actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
|
154
|
+
assert_equal %Q|◆→開始:右寄せ←◆\nfoobar\nbuz\n◆→終了:右寄せ←◆\n\n|, actual
|
155
|
+
end
|
156
|
+
|
157
|
+
def test_noindent
|
158
|
+
actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
|
159
|
+
assert_equal %Q|◆→DTP連絡:次の1行インデントなし←◆\nfoobar\nfoo2bar2\n|, actual
|
160
|
+
end
|
161
|
+
|
162
|
+
def test_list
|
163
|
+
def @chapter.list(id)
|
164
|
+
Book::ListIndex::Item.new("test",1)
|
165
|
+
end
|
166
|
+
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
|
167
|
+
assert_equal %Q|◆→開始:リスト←◆\nリスト1.1 this is ★test☆<&>_\n\nfoo\nbar\n◆→終了:リスト←◆\n\n|, actual
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_listnum
|
171
|
+
def @chapter.list(id)
|
172
|
+
Book::ListIndex::Item.new("test",1)
|
173
|
+
end
|
174
|
+
actual = compile_block("//listnum[test][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
|
175
|
+
assert_equal %Q|◆→開始:リスト←◆\nリスト1.1 this is ★test☆<&>_\n\n 1: foo\n 2: bar\n◆→終了:リスト←◆\n\n|, actual
|
176
|
+
end
|
177
|
+
|
178
|
+
def test_emlistnum
|
179
|
+
actual = compile_block("//emlistnum[this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
|
180
|
+
assert_equal %Q|◆→開始:インラインリスト←◆\n■this is ★test☆<&>_\n 1: foo\n 2: bar\n◆→終了:インラインリスト←◆\n\n|, actual
|
181
|
+
end
|
182
|
+
|
183
|
+
def test_image
|
184
|
+
def @chapter.image(id)
|
185
|
+
item = Book::ImageIndex::Item.new("sampleimg",1)
|
186
|
+
item.instance_eval{@path="./images/chap1-sampleimg.png"}
|
187
|
+
item
|
188
|
+
end
|
189
|
+
|
190
|
+
actual = compile_block("//image[sampleimg][sample photo]{\nfoo\n//}\n")
|
191
|
+
assert_equal %Q|◆→開始:図←◆\n図1.1 sample photo\n\n◆→./images/chap1-sampleimg.png←◆\n◆→終了:図←◆\n\n|, actual
|
192
|
+
end
|
193
|
+
|
194
|
+
def test_image_with_metric
|
195
|
+
def @chapter.image(id)
|
196
|
+
item = Book::ImageIndex::Item.new("sampleimg",1)
|
197
|
+
item.instance_eval{@path="./images/chap1-sampleimg.png"}
|
198
|
+
item
|
199
|
+
end
|
200
|
+
|
201
|
+
actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\nfoo\n//}\n")
|
202
|
+
assert_equal %Q|◆→開始:図←◆\n図1.1 sample photo\n\n◆→./images/chap1-sampleimg.png←◆\n◆→終了:図←◆\n\n|, actual
|
203
|
+
end
|
204
|
+
|
205
|
+
def test_texequation
|
206
|
+
actual = compile_block("//texequation{\n\\sin\n1^{2}\n//}\n")
|
207
|
+
assert_equal %Q|◆→開始:TeX式←◆\n\\sin\n1^{2}\n◆→終了:TeX式←◆\n\n|, actual
|
208
|
+
end
|
209
|
+
|
210
|
+
def test_inline_raw0
|
211
|
+
assert_equal "normal", compile_inline("@<raw>{normal}")
|
212
|
+
end
|
213
|
+
|
214
|
+
def test_inline_raw1
|
215
|
+
assert_equal "body", compile_inline("@<raw>{|top|body}")
|
216
|
+
end
|
217
|
+
|
218
|
+
def test_inline_raw2
|
219
|
+
assert_equal "body", compile_inline("@<raw>{|top, latex|body}")
|
220
|
+
end
|
221
|
+
|
222
|
+
def test_inline_raw3
|
223
|
+
assert_equal "", compile_inline("@<raw>{|idgxml, html|body}")
|
224
|
+
end
|
225
|
+
|
226
|
+
def test_inline_raw4
|
227
|
+
assert_equal "|top body", compile_inline("@<raw>{|top body}")
|
228
|
+
end
|
229
|
+
|
230
|
+
def test_inline_raw5
|
231
|
+
assert_equal "nor\nmal", compile_inline("@<raw>{|top|nor\\nmal}")
|
232
|
+
end
|
233
|
+
|
234
|
+
def test_block_raw0
|
235
|
+
actual = compile_block("//raw[<>!\"\\n& ]\n")
|
236
|
+
expected = %Q(<>!\"\n& )
|
237
|
+
assert_equal expected.chomp, actual
|
238
|
+
end
|
239
|
+
|
240
|
+
def test_block_raw1
|
241
|
+
actual = compile_block("//raw[|top|<>!\"\\n& ]\n")
|
242
|
+
expected = %Q(<>!\"\n& )
|
243
|
+
assert_equal expected.chomp, actual
|
244
|
+
end
|
245
|
+
|
246
|
+
def test_block_raw2
|
247
|
+
actual = compile_block("//raw[|top, latex|<>!\"\\n& ]\n")
|
248
|
+
expected = %Q(<>!\"\n& )
|
249
|
+
assert_equal expected.chomp, actual
|
250
|
+
end
|
251
|
+
|
252
|
+
def test_block_raw3
|
253
|
+
actual = compile_block("//raw[|latex, idgxml|<>!\"\\n& ]\n")
|
254
|
+
expected = ''
|
255
|
+
assert_equal expected.chomp, actual
|
256
|
+
end
|
257
|
+
|
258
|
+
def test_block_raw4
|
259
|
+
actual = compile_block("//raw[|top <>!\"\\n& ]\n")
|
260
|
+
expected = %Q(|top <>!\"\n& )
|
261
|
+
assert_equal expected.chomp, actual
|
262
|
+
end
|
263
|
+
|
264
|
+
def column_helper(review)
|
265
|
+
compile_block(review)
|
266
|
+
end
|
267
|
+
|
268
|
+
def test_column_ref
|
269
|
+
review =<<-EOS
|
270
|
+
===[column]{foo} test
|
271
|
+
|
272
|
+
inside column
|
273
|
+
|
274
|
+
=== next level
|
275
|
+
|
276
|
+
this is @<column>{foo}.
|
277
|
+
EOS
|
278
|
+
expected =<<-EOS
|
279
|
+
◆→開始:コラム←◆
|
280
|
+
■test
|
281
|
+
inside column
|
282
|
+
◆→終了:コラム←◆
|
283
|
+
|
284
|
+
■H3■next level
|
285
|
+
this is test.
|
286
|
+
EOS
|
287
|
+
|
288
|
+
assert_equal expected, column_helper(review)
|
289
|
+
end
|
290
|
+
|
291
|
+
end
|