review 1.7.2 → 2.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -43
- data/.travis.yml +0 -9
- data/ChangeLog +0 -16
- data/Gemfile +1 -0
- data/README.rdoc +1 -1
- data/Rakefile +12 -1
- data/bin/review-check +21 -8
- data/bin/review-compile +15 -9
- data/bin/review-epubmaker-legacy +6 -6
- data/bin/review-index +13 -2
- data/bin/review-init +18 -12
- data/bin/review-preproc +14 -1
- data/bin/review-validate +1 -1
- data/bin/review-vol +13 -1
- data/doc/quickstart.ja.md +1 -1
- data/doc/quickstart.md +1 -1
- data/lib/epubmaker/content.rb +3 -3
- data/lib/epubmaker/epubcommon.rb +108 -91
- data/lib/epubmaker/epubv2.rb +67 -14
- data/lib/epubmaker/epubv3.rb +59 -25
- data/lib/epubmaker/producer.rb +1 -13
- data/lib/lineinput.rb +0 -48
- data/lib/review/book/base.rb +4 -12
- data/lib/review/book/compilable.rb +3 -1
- data/lib/review/book/index.rb +4 -4
- data/lib/review/builder.rb +54 -47
- data/lib/review/compiler.rb +4662 -326
- data/lib/review/compiler/literals_1_8.kpeg +19 -0
- data/lib/review/compiler/literals_1_8.rb +432 -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 +8 -20
- data/lib/review/epubbuilder.rb +1 -1
- data/lib/review/epubmaker.rb +122 -52
- data/lib/review/ewbbuilder.rb +4 -4
- data/lib/review/exception.rb +1 -1
- data/lib/review/extentions.rb +1 -0
- data/lib/review/extentions/array.rb +25 -0
- data/lib/review/htmlbuilder.rb +286 -275
- data/lib/review/htmllayout.rb +0 -2
- data/lib/review/htmlutils.rb +4 -4
- data/lib/review/i18n.rb +2 -6
- data/lib/review/i18n.yml +1 -1
- data/lib/review/idgxmlbuilder.rb +239 -204
- data/lib/review/inaobuilder.rb +75 -73
- data/lib/review/latexbuilder.rb +265 -219
- data/lib/review/latexutils.rb +6 -6
- data/lib/review/layout.tex.erb +1 -1
- data/lib/review/location.rb +24 -0
- data/lib/review/markdownbuilder.rb +124 -79
- data/lib/review/node.rb +267 -0
- data/lib/review/pdfmaker.rb +92 -92
- data/lib/review/preprocessor.rb +51 -14
- data/lib/review/review.kpeg +724 -0
- data/lib/review/textbuilder.rb +1 -1
- data/lib/review/textutils.rb +24 -18
- data/lib/review/tocparser.rb +3 -3
- data/lib/review/tocprinter.rb +31 -8
- data/lib/review/topbuilder.rb +119 -111
- data/lib/review/unfold.rb +2 -2
- data/lib/review/version.rb +1 -1
- data/review.gemspec +2 -2
- data/rubocop-todo.yml +456 -0
- data/test/assets/test_template.tex +1 -1
- data/test/sample-book/src/config.yml +0 -1
- data/test/test.re +1 -1
- data/test/test_book.rb +4 -4
- data/test/test_book_chapter.rb +70 -0
- data/test/test_book_part.rb +1 -1
- data/test/test_builder.rb +6 -28
- data/test/test_compiler.rb +59 -14
- data/test/test_helper.rb +47 -4
- data/test/test_htmlbuilder.rb +104 -73
- data/test/test_i18n.rb +5 -3
- data/test/test_idgxmlbuilder.rb +5 -2
- data/test/test_inaobuilder.rb +4 -2
- data/test/test_latexbuilder.rb +18 -37
- data/test/test_lineinput.rb +25 -4
- data/test/test_markdownbuilder.rb +4 -22
- data/test/test_pdfmaker.rb +12 -11
- data/test/test_textutils.rb +0 -36
- data/test/test_topbuilder.rb +2 -0
- metadata +14 -28
- data/.rubocop_todo.yml +0 -605
- data/Dockerfile +0 -22
- data/doc/NEWS.ja.md +0 -362
- data/doc/NEWS.md +0 -366
- data/lib/review/htmltoc.rb +0 -45
- data/lib/review/template.rb +0 -21
- data/templates/html/layout-html5.html.erb +0 -17
- data/templates/html/layout-xhtml1.html.erb +0 -20
- data/templates/ncx/epubv2.ncx.erb +0 -11
- data/templates/opf/epubv2.opf.erb +0 -21
- data/templates/opf/epubv3.opf.erb +0 -18
- data/templates/xml/container.xml.erb +0 -6
- data/test/assets/test.xml.erb +0 -3
- data/test/sample-book/src/config-epub2.yml +0 -186
- data/test/test_configure.rb +0 -50
- data/test/test_htmltoc.rb +0 -32
- data/test/test_template.rb +0 -26
data/test/test.re
CHANGED
data/test/test_book.rb
CHANGED
@@ -158,14 +158,14 @@ class BookTest < Test::Unit::TestCase
|
|
158
158
|
def test_setParameter
|
159
159
|
book = Book::Base.new(File.dirname(__FILE__))
|
160
160
|
book.param = :test
|
161
|
-
assert_equal :test, book.param
|
161
|
+
assert_equal :test, book.param # old way
|
162
162
|
assert_equal :test, book.config # new way
|
163
163
|
end
|
164
164
|
|
165
165
|
def test_setConfig
|
166
166
|
book = Book::Base.new(File.dirname(__FILE__))
|
167
167
|
book.config = :test
|
168
|
-
assert_equal :test, book.param
|
168
|
+
assert_equal :test, book.param # old way
|
169
169
|
assert_equal :test, book.config # new way
|
170
170
|
end
|
171
171
|
|
@@ -391,7 +391,7 @@ EOC
|
|
391
391
|
end
|
392
392
|
|
393
393
|
mktmpbookdir 'catalog.yml' => "APPENDIX:\n - p01.re",
|
394
|
-
'p01.re' => '= appendix'
|
394
|
+
'p01.re' => '= appendix' do |dir, book, files|
|
395
395
|
assert_equal 'appendix', book.appendix.chapters.first.title
|
396
396
|
assert_equal 1, book.appendix.chapters.first.number
|
397
397
|
end
|
@@ -399,7 +399,7 @@ EOC
|
|
399
399
|
|
400
400
|
def test_postscripts
|
401
401
|
mktmpbookdir 'catalog.yml' => "POSTDEF:\n - b01.re",
|
402
|
-
'b01.re' => '= back'
|
402
|
+
'b01.re' => '= back' do |dir, book, files|
|
403
403
|
assert_kind_of Book::Part, book.postscripts
|
404
404
|
assert_equal 1, book.postscripts.chapters.size
|
405
405
|
assert_equal 'back', book.postscripts.chapters.first.title
|
data/test/test_book_chapter.rb
CHANGED
@@ -3,6 +3,21 @@ require 'book_test_helper'
|
|
3
3
|
class ChapterTest < Test::Unit::TestCase
|
4
4
|
include BookTestHelper
|
5
5
|
|
6
|
+
def setup
|
7
|
+
|
8
|
+
if "".respond_to?(:encode)
|
9
|
+
@utf8_str = "あいうえお"
|
10
|
+
@eucjp_str = "あいうえお".encode("EUC-JP")
|
11
|
+
@sjis_str = "あいうえお".encode("Shift_JIS")
|
12
|
+
@jis_str = "あいうえお".encode("ISO-2022-JP")
|
13
|
+
else
|
14
|
+
@utf8_str = "\xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88\xe3\x81\x8a" # "あいうえお"
|
15
|
+
@eucjp_str = "\xa4\xa2\xa4\xa4\xa4\xa6\xa4\xa8\xa4\xaa"
|
16
|
+
@sjis_str = "\x82\xa0\x82\xa2\x82\xa4\x82\xa6\x82\xa8"
|
17
|
+
@jis_str = "\x1b\x24\x42\x24\x22\x24\x24\x24\x26\x24\x28\x24\x2a\x1b\x28\x42"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
6
21
|
def test_initialize
|
7
22
|
ch = Book::Chapter.new(:book, :number, :name, '/foo/bar', :io)
|
8
23
|
assert_equal :book, ch.book
|
@@ -67,6 +82,60 @@ class ChapterTest < Test::Unit::TestCase
|
|
67
82
|
io = StringIO.new("=1\n=2\n")
|
68
83
|
ch = Book::Chapter.new(book, nil, nil, nil, io)
|
69
84
|
assert_equal '1', ch.title
|
85
|
+
|
86
|
+
|
87
|
+
[
|
88
|
+
['EUC', @eucjp_str],
|
89
|
+
['SJIS', @sjis_str],
|
90
|
+
# ['JIS', @jis_str],
|
91
|
+
['XYZ', @eucjp_str],
|
92
|
+
].each do |enc, instr|
|
93
|
+
io = StringIO.new("= #{instr}\n")
|
94
|
+
ch = Book::Chapter.new(book, nil, nil, nil, io)
|
95
|
+
book.config['inencoding'] = enc
|
96
|
+
assert_equal @utf8_str, ch.title
|
97
|
+
assert_equal @utf8_str, ch.instance_eval { @title }
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_content
|
102
|
+
[
|
103
|
+
['EUC', @eucjp_str],
|
104
|
+
['SJIS', @sjis_str],
|
105
|
+
['JIS', @jis_str],
|
106
|
+
['XYZ', @eucjp_str],
|
107
|
+
].each do |enc, instr|
|
108
|
+
tf = Tempfile.new('chapter_test')
|
109
|
+
book = Book::Base.new(nil)
|
110
|
+
begin
|
111
|
+
tf.print instr
|
112
|
+
tf.close
|
113
|
+
|
114
|
+
ch = Book::Chapter.new(book, nil, nil, tf.path)
|
115
|
+
book.config['inencoding'] = enc
|
116
|
+
assert_equal @utf8_str, ch.content
|
117
|
+
assert_equal @utf8_str, ch.instance_eval { @content }
|
118
|
+
ensure
|
119
|
+
tf.close(true)
|
120
|
+
end
|
121
|
+
|
122
|
+
tf1 = Tempfile.new('chapter_test1')
|
123
|
+
tf2 = Tempfile.new('chapter_test2')
|
124
|
+
begin
|
125
|
+
tf1.puts instr
|
126
|
+
tf1.puts instr
|
127
|
+
tf1.close
|
128
|
+
tf2.puts instr
|
129
|
+
tf1.close
|
130
|
+
|
131
|
+
ch = Book::Chapter.new(book, nil, nil, tf1.path, tf2)
|
132
|
+
book.config['inencoding'] = enc
|
133
|
+
assert_equal "#{@utf8_str}\n#{@utf8_str}\n", ch.content # XXX: OK?
|
134
|
+
ensure
|
135
|
+
tf1.close(true)
|
136
|
+
tf2.close(true)
|
137
|
+
end
|
138
|
+
end
|
70
139
|
end
|
71
140
|
|
72
141
|
def test_lines
|
@@ -207,6 +276,7 @@ E
|
|
207
276
|
|
208
277
|
def test_column_index
|
209
278
|
book = Book::Base.new(nil)
|
279
|
+
book.config["inencoding"] = "utf-8"
|
210
280
|
do_test_index(<<E, Book::ColumnIndex, :column_index, :column, :propagate => false)
|
211
281
|
= dummy1
|
212
282
|
===[column]{abc} aaaa
|
data/test/test_book_part.rb
CHANGED
@@ -33,7 +33,7 @@ class PartTest < Test::Unit::TestCase
|
|
33
33
|
assert_equal 0, part.volume.lines
|
34
34
|
|
35
35
|
chs = []
|
36
|
-
tfs = []
|
36
|
+
tfs = [] ## prevent from removing Tempfile
|
37
37
|
Tempfile.open('part_test') do |o|
|
38
38
|
o.print "12345"
|
39
39
|
chs << Book::Chapter.new(book, nil, nil, o.path)
|
data/test/test_builder.rb
CHANGED
@@ -44,16 +44,6 @@ class BuidlerTest < Test::Unit::TestCase
|
|
44
44
|
assert_equal '', b.result
|
45
45
|
end
|
46
46
|
|
47
|
-
def test_print_and_puts
|
48
|
-
b = Builder.new
|
49
|
-
assert_raises(NoMethodError) do # XXX: OK?
|
50
|
-
b.print ""
|
51
|
-
end
|
52
|
-
assert_raises(NoMethodError) do # XXX: OK?
|
53
|
-
b.puts ""
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
47
|
def test_not_implemented_methods
|
58
48
|
ex = NoMethodError # XXX: OK?
|
59
49
|
[
|
@@ -70,24 +60,12 @@ class BuidlerTest < Test::Unit::TestCase
|
|
70
60
|
end
|
71
61
|
end
|
72
62
|
|
73
|
-
def
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
def @b.compile_ruby(base,ruby)
|
80
|
-
[base,ruby]
|
81
|
-
end
|
82
|
-
str = @b.inline_ruby("foo,bar")
|
83
|
-
assert_equal str, ["foo","bar"]
|
84
|
-
str = @b.inline_ruby("foo\\,\\,,\\,bar,buz")
|
85
|
-
assert_equal str, ["foo,,",",bar,buz"]
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_compile_inline_backslash
|
89
|
-
text = "abc\\d\\#a"
|
90
|
-
assert_equal [:text, text], @b.compile_inline(text)
|
63
|
+
def test_convert_outencoding
|
64
|
+
book = ReVIEW::Book::Base.new(nil)
|
65
|
+
book.config = {'outencoding' => "EUC"}
|
66
|
+
b = Builder.new
|
67
|
+
ret = b.convert_outencoding("a", book.config["outencoding"])
|
68
|
+
assert_equal "a", ret
|
91
69
|
end
|
92
70
|
|
93
71
|
class XBuilder < Builder
|
data/test/test_compiler.rb
CHANGED
@@ -4,43 +4,88 @@ require 'test_helper'
|
|
4
4
|
require 'review/compiler'
|
5
5
|
require 'review/book'
|
6
6
|
require 'review/latexbuilder'
|
7
|
+
require 'review/htmlbuilder'
|
7
8
|
|
8
9
|
class CompilerTest < Test::Unit::TestCase
|
9
10
|
include ReVIEW
|
10
11
|
|
11
12
|
def setup
|
12
|
-
@builder =
|
13
|
-
@
|
13
|
+
@builder = HTMLBuilder.new()
|
14
|
+
@param = {
|
15
|
+
"secnolevel" => 2, # for IDGXMLBuilder, HTMLBuilder
|
16
|
+
"inencoding" => "UTF-8",
|
17
|
+
"outencoding" => "UTF-8",
|
18
|
+
"subdirmode" => nil,
|
19
|
+
"stylesheet" => nil, # for HTMLBuilder
|
20
|
+
}
|
21
|
+
ReVIEW.book.param = @param
|
22
|
+
@compiler = ReVIEW::Compiler.new(@builder)
|
23
|
+
@chapter = Book::Chapter.new(Book::Base.new(nil), 1, '-', nil, StringIO.new)
|
24
|
+
location = Location.new(nil, nil)
|
25
|
+
@builder.bind(@compiler, @chapter, location)
|
26
|
+
|
27
|
+
def @compiler.compile_command(name, args, lines, node)
|
28
|
+
args
|
29
|
+
end
|
30
|
+
|
14
31
|
end
|
15
32
|
|
16
33
|
def test_parse_args
|
17
|
-
args =
|
18
|
-
assert_equal ["foo","bar"], args
|
34
|
+
args = compile_blockelem("//dummy[foo][bar]\n", false)
|
35
|
+
assert_equal ["foo","bar"], args.parse_args(:doc,:doc)
|
19
36
|
end
|
20
37
|
|
21
38
|
def test_parse_args_with_brace1
|
22
|
-
args =
|
23
|
-
assert_equal ["fo[][]o","bar"], args
|
39
|
+
args = compile_blockelem("//dummy[fo[\\][\\]o][bar]", false)
|
40
|
+
assert_equal ["fo[][]o","bar"], args.parse_args(:doc, :doc)
|
24
41
|
end
|
25
42
|
|
26
43
|
def test_parse_args_with_brace2
|
27
|
-
args =
|
28
|
-
assert_equal ["f]o]o","bar"], args
|
44
|
+
args = compile_blockelem("//dummy[f\\]o\\]o][bar]", false)
|
45
|
+
assert_equal ["f]o]o","bar"], args.parse_args(:doc, :doc)
|
29
46
|
end
|
30
47
|
|
31
48
|
def test_parse_args_with_backslash
|
32
|
-
args =
|
33
|
-
assert_equal ["foo","bar\\buz"], args
|
49
|
+
args = compile_blockelem("//dummy[foo][bar\\buz]", false)
|
50
|
+
assert_equal ["foo","bar\\buz"], args.parse_args(:doc, :doc)
|
34
51
|
end
|
35
52
|
|
36
53
|
def test_parse_args_with_backslash2
|
37
|
-
args =
|
38
|
-
assert_equal ["foo","bar\\#\\[\\!"], args
|
54
|
+
args = compile_blockelem("//dummy[foo][bar\\#\\[\\!]", false)
|
55
|
+
assert_equal ["foo","bar\\#\\[\\!"], args.parse_args(:doc, :doc)
|
39
56
|
end
|
40
57
|
|
41
58
|
def test_parse_args_with_backslash3
|
42
|
-
args =
|
43
|
-
assert_equal ["foo","bar\\buz"], args
|
59
|
+
args = compile_blockelem("//dummy[foo][bar\\\\buz]", false)
|
60
|
+
assert_equal ["foo","bar\\buz"], args.parse_args(:doc, :doc)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_compile_inline
|
64
|
+
def @compiler.inline_ruby(*args)
|
65
|
+
return args
|
66
|
+
end
|
67
|
+
args = compile_inline("@<ruby>{abc}",false)
|
68
|
+
assert_equal "abc", args.content[0].content.to_doc
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_inline_ruby
|
72
|
+
# def @compiler.inline_ruby(*args)
|
73
|
+
# return args
|
74
|
+
# end
|
75
|
+
args = compile_inline("@<ruby>{foo,bar}",false)
|
76
|
+
assert_equal "foo", args.content[0].content[0].to_doc
|
77
|
+
assert_equal "bar", args.content[0].content[1].to_doc
|
78
|
+
args = compile_inline("@<ruby>{foo\\,\\,,\\,bar\\,buz}", false)
|
79
|
+
assert_equal "foo,,", args.content[0].content[0].to_doc
|
80
|
+
assert_equal ",bar,buz", args.content[0].content[1].to_doc
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_compile_inline_backslash
|
84
|
+
def @compiler.inline_dummy(*args)
|
85
|
+
return args
|
86
|
+
end
|
87
|
+
args = compile_inline("@<dummy>{abc\\d\\#a}", false)
|
88
|
+
assert_equal "abc\\d\\#a", args.content[0].content.to_doc
|
44
89
|
end
|
45
90
|
end
|
46
91
|
|
data/test/test_helper.rb
CHANGED
@@ -1,6 +1,53 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib/')
|
2
2
|
require 'test/unit'
|
3
3
|
|
4
|
+
def compile_document(str, force_to_s=true)
|
5
|
+
@compiler.setup_parser(str)
|
6
|
+
@compiler.parse("Document")
|
7
|
+
if force_to_s
|
8
|
+
@compiler.result.to_doc
|
9
|
+
else
|
10
|
+
@compiler.result
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def compile_block(str, force_to_s=true)
|
15
|
+
@compiler.setup_parser(str)
|
16
|
+
@compiler.parse("Document")
|
17
|
+
if force_to_s
|
18
|
+
@compiler.result.to_doc
|
19
|
+
else
|
20
|
+
@compiler.result
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def compile_inline(str, force_to_s=true)
|
25
|
+
@compiler.setup_parser(str)
|
26
|
+
@compiler.parse("Paragraph")
|
27
|
+
if force_to_s
|
28
|
+
## @compiler.result.map(&:to_doc).join
|
29
|
+
@compiler.result.to_doc
|
30
|
+
else
|
31
|
+
@compiler.result
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def compile_blockelem(str, force_to_s=true)
|
36
|
+
@compiler.setup_parser(str)
|
37
|
+
@compiler.parse("BlockElement")
|
38
|
+
if force_to_s
|
39
|
+
@compiler.result.to_doc
|
40
|
+
else
|
41
|
+
@compiler.result
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def compile_headline(str)
|
46
|
+
@compiler.setup_parser(str)
|
47
|
+
@compiler.parse("Headline")
|
48
|
+
@compiler.result.to_doc
|
49
|
+
end
|
50
|
+
|
4
51
|
def touch_file(path)
|
5
52
|
File.open(path, "w").close
|
6
53
|
path
|
@@ -16,10 +63,6 @@ def prepare_samplebook(srcdir)
|
|
16
63
|
YAML.load(File.open(srcdir + "/config.yml"))
|
17
64
|
end
|
18
65
|
|
19
|
-
def compile_inline(text)
|
20
|
-
@builder.compile_inline(text)
|
21
|
-
end
|
22
|
-
|
23
66
|
def compile_block(text)
|
24
67
|
method_name = "compile_block_#{@builder.target_name}"
|
25
68
|
if !self.respond_to?(method_name, true)
|
data/test/test_htmlbuilder.rb
CHANGED
@@ -14,9 +14,10 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
14
14
|
@builder = HTMLBuilder.new()
|
15
15
|
@config = ReVIEW::Configure.values
|
16
16
|
@config.merge!({
|
17
|
-
"secnolevel" => 2,
|
18
|
-
"
|
19
|
-
"
|
17
|
+
"secnolevel" => 2, # for IDGXMLBuilder, HTMLBuilder
|
18
|
+
"inencoding" => "UTF-8",
|
19
|
+
"outencoding" => "UTF-8",
|
20
|
+
"stylesheet" => nil, # for HTMLBuilder
|
20
21
|
})
|
21
22
|
@book = Book::Base.new(".")
|
22
23
|
@book.config = @config
|
@@ -58,7 +59,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
58
59
|
end
|
59
60
|
end
|
60
61
|
actual = compile_block("=={test} this is test.\n")
|
61
|
-
assert_equal %Q
|
62
|
+
assert_equal %Q|<h2 id="test"><a id="h1-1"></a><span class="secno">1.1 </span>this is test.</h2>\n|, actual
|
62
63
|
end
|
63
64
|
|
64
65
|
def test_headline_level1_postdef_roman
|
@@ -80,7 +81,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
80
81
|
end
|
81
82
|
end
|
82
83
|
actual = compile_block("=={test} this is test.\n")
|
83
|
-
assert_equal %Q
|
84
|
+
assert_equal %Q|<h2 id="test"><a id="hI-1"></a><span class="secno">I.1 </span>this is test.</h2>\n|, actual
|
84
85
|
end
|
85
86
|
|
86
87
|
def test_headline_level1_postdef_alpha
|
@@ -102,7 +103,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
102
103
|
end
|
103
104
|
end
|
104
105
|
actual = compile_block("=={test} this is test.\n")
|
105
|
-
assert_equal %Q
|
106
|
+
assert_equal %Q|<h2 id="test"><a id="hA-1"></a><span class="secno">A.1 </span>this is test.</h2>\n|, actual
|
106
107
|
end
|
107
108
|
|
108
109
|
def test_headline_level1_without_secno
|
@@ -123,18 +124,18 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
123
124
|
|
124
125
|
def test_headline_level2
|
125
126
|
actual = compile_block("=={test} this is test.\n")
|
126
|
-
assert_equal %Q
|
127
|
+
assert_equal %Q|<h2 id="test"><a id="h1-1"></a><span class="secno">1.1 </span>this is test.</h2>\n|, actual
|
127
128
|
end
|
128
129
|
|
129
130
|
def test_headline_level3
|
130
131
|
actual = compile_block("==={test} this is test.\n")
|
131
|
-
assert_equal %Q
|
132
|
+
assert_equal %Q|<h3 id="test"><a id="h1-0-1"></a>this is test.</h3>\n|, actual
|
132
133
|
end
|
133
134
|
|
134
135
|
def test_headline_level3_with_secno
|
135
136
|
@book.config["secnolevel"] = 3
|
136
137
|
actual = compile_block("==={test} this is test.\n")
|
137
|
-
assert_equal %Q
|
138
|
+
assert_equal %Q|<h3 id="test"><a id="h1-0-1"></a><span class="secno">1.0.1 </span>this is test.</h3>\n|, actual
|
138
139
|
end
|
139
140
|
|
140
141
|
def test_label
|
@@ -319,7 +320,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
319
320
|
|
320
321
|
def test_quote
|
321
322
|
actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
|
322
|
-
assert_equal %Q|<blockquote><p>foobar</p>\n<p>buz</p
|
323
|
+
assert_equal %Q|<blockquote><p>foobar</p>\n<p>buz</p>\n</blockquote>\n|, actual
|
323
324
|
end
|
324
325
|
|
325
326
|
def test_memo
|
@@ -479,7 +480,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
479
480
|
@book.config["pygments"] = true
|
480
481
|
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
481
482
|
|
482
|
-
assert_equal %Q|<div class="caption-code">\n<p class="caption">リスト1.1: this is <b>test</b><&>_</p>\n<pre class="list">test1\ntest1.5\n\ntest<i>2</i>
|
483
|
+
assert_equal %Q|<div class="caption-code">\n<p class="caption">リスト1.1: this is <b>test</b><&>_</p>\n<pre class="list">test1\ntest1.5\n\ntest<i>2</i></pre>\n</div>\n|, actual
|
483
484
|
end
|
484
485
|
|
485
486
|
def test_list_pygments_lang
|
@@ -499,7 +500,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
499
500
|
%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| +
|
500
501
|
%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| +
|
501
502
|
%Q| <span style=\"color: #008000; font-weight: bold\">return</span> <span style=\"color: #008000\">true</span>\n| +
|
502
|
-
%Q|<span style=\"color: #008000; font-weight: bold\">end</span
|
503
|
+
%Q|<span style=\"color: #008000; font-weight: bold\">end</span>| +
|
503
504
|
%Q|</pre>\n| +
|
504
505
|
%Q|</div>\n|, actual
|
505
506
|
end
|
@@ -517,36 +518,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
517
518
|
@book.config["pygments"] = true
|
518
519
|
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_][]{\ndef foo(a1, a2=:test)\n (1..3).times{|i| a.include?(:foo)}\n return true\nend\n\n//}\n")
|
519
520
|
|
520
|
-
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
|
521
|
-
end
|
522
|
-
|
523
|
-
def test_listnum
|
524
|
-
def @chapter.list(id)
|
525
|
-
Book::ListIndex::Item.new("samplelist",1)
|
526
|
-
end
|
527
|
-
|
528
|
-
@book.config["highlight"] = false
|
529
|
-
actual = compile_block(<<-EOS)
|
530
|
-
//listnum[samplelist][this is @<b>{test}<&>_][ruby]{
|
531
|
-
def foo(a1, a2=:test)
|
532
|
-
(1..3).times{|i| a.include?(:foo)}
|
533
|
-
return true
|
534
|
-
end
|
535
|
-
//}
|
536
|
-
EOS
|
537
|
-
|
538
|
-
expected =<<-EOS
|
539
|
-
<div class="code">
|
540
|
-
<p class="caption">リスト1.1: this is <b>test</b><&>_</p>
|
541
|
-
<pre class="list"> 1: def foo(a1, a2=:test)
|
542
|
-
2: (1..3).times{|i| a.include?(:foo)}
|
543
|
-
3: return true
|
544
|
-
4: end
|
545
|
-
</pre>
|
546
|
-
</div>
|
547
|
-
EOS
|
548
|
-
|
549
|
-
assert_equal expected, actual
|
521
|
+
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</pre>\n</div>\n", actual
|
550
522
|
end
|
551
523
|
|
552
524
|
def test_listnum_pygments_lang
|
@@ -562,7 +534,7 @@ EOS
|
|
562
534
|
@book.config["pygments"] = true
|
563
535
|
actual = compile_block("//listnum[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")
|
564
536
|
|
565
|
-
assert_equal "<div class=\"code\">\n<p class=\"caption\">リスト1.1: this is <b>test</b><&>_</p>\n<div class=\"highlight\" style=\"background: #f8f8f8\"><pre style=\"line-height: 125%\"><span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">1</span> <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<span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">2</span> (<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<span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">3</span> <span style=\"color: #008000; font-weight: bold\">return</span> <span style=\"color: #008000\">true</span>\n<span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">4</span> <span style=\"color: #008000; font-weight: bold\">end</span>\n</pre></div
|
537
|
+
assert_equal "<div class=\"code\">\n<p class=\"caption\">リスト1.1: this is <b>test</b><&>_</p>\n<div class=\"highlight\" style=\"background: #f8f8f8\"><pre style=\"line-height: 125%\"><span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">1</span> <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<span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">2</span> (<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<span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">3</span> <span style=\"color: #008000; font-weight: bold\">return</span> <span style=\"color: #008000\">true</span>\n<span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">4</span> <span style=\"color: #008000; font-weight: bold\">end</span>\n</pre></div></div>", actual
|
566
538
|
end
|
567
539
|
|
568
540
|
def test_listnum_pygments_lang_without_lang
|
@@ -580,7 +552,7 @@ EOS
|
|
580
552
|
@book.config["highlight"]["lang"] = "ruby"
|
581
553
|
actual = compile_block("//listnum[samplelist][this is @<b>{test}<&>_]{\ndef foo(a1, a2=:test)\n (1..3).times{|i| a.include?(:foo)}\n return true\nend\n\n//}\n")
|
582
554
|
|
583
|
-
assert_equal "<div class=\"code\">\n<p class=\"caption\">リスト1.1: this is <b>test</b><&>_</p>\n<div class=\"highlight\" style=\"background: #f8f8f8\"><pre style=\"line-height: 125%\"><span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">1</span> <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<span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">2</span> (<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<span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">3</span> <span style=\"color: #008000; font-weight: bold\">return</span> <span style=\"color: #008000\">true</span>\n<span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">4</span> <span style=\"color: #008000; font-weight: bold\">end</span>\n</pre></div
|
555
|
+
assert_equal "<div class=\"code\">\n<p class=\"caption\">リスト1.1: this is <b>test</b><&>_</p>\n<div class=\"highlight\" style=\"background: #f8f8f8\"><pre style=\"line-height: 125%\"><span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">1</span> <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<span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">2</span> (<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<span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">3</span> <span style=\"color: #008000; font-weight: bold\">return</span> <span style=\"color: #008000\">true</span>\n<span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">4</span> <span style=\"color: #008000; font-weight: bold\">end</span>\n</pre></div></div>", actual
|
584
556
|
end
|
585
557
|
|
586
558
|
|
@@ -598,7 +570,7 @@ EOS
|
|
598
570
|
end
|
599
571
|
@book.config["pygments"] = true
|
600
572
|
actual = compile_block("//emlist[][sql]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
|
601
|
-
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
|
573
|
+
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></pre>\n</div>\n", actual
|
602
574
|
end
|
603
575
|
|
604
576
|
def test_emlist_caption
|
@@ -611,19 +583,6 @@ EOS
|
|
611
583
|
assert_equal %Q|<div class="emlist-code">\n<pre class="emlist"> lineA\n lineB\n lineC\n</pre>\n</div>\n|, actual
|
612
584
|
end
|
613
585
|
|
614
|
-
def test_emlistnum
|
615
|
-
@book.config["highlight"] = false
|
616
|
-
actual = compile_block("//emlistnum{\nlineA\nlineB\n//}\n")
|
617
|
-
expected =<<-EOS
|
618
|
-
<div class="emlistnum-code">
|
619
|
-
<pre class="emlist"> 1: lineA
|
620
|
-
2: lineB
|
621
|
-
</pre>
|
622
|
-
</div>
|
623
|
-
EOS
|
624
|
-
assert_equal expected, actual
|
625
|
-
end
|
626
|
-
|
627
586
|
def test_emlist_with_4tab
|
628
587
|
@config["tabwidth"] = 4
|
629
588
|
actual = compile_block("//emlist{\n\tlineA\n\t\tlineB\n\tlineC\n//}\n")
|
@@ -643,7 +602,7 @@ EOS
|
|
643
602
|
end
|
644
603
|
@book.config["pygments"] = true
|
645
604
|
actual = compile_block("//cmd{\nlineA\nlineB\n//}\n")
|
646
|
-
assert_equal "<div class=\"cmd-code\">\n<pre class=\"cmd\"><span style=\"color: #888888\">lineA</span>\n<span style=\"color: #888888\">lineB</span
|
605
|
+
assert_equal "<div class=\"cmd-code\">\n<pre class=\"cmd\"><span style=\"color: #888888\">lineA</span>\n<span style=\"color: #888888\">lineB</span></pre>\n</div>\n", actual
|
647
606
|
end
|
648
607
|
|
649
608
|
def test_cmd_caption
|
@@ -667,22 +626,13 @@ EOS
|
|
667
626
|
assert_equal %Q|<a href="bib.html#bib-id_sample_3Dbib">[1]</a>|, compile_inline("@<bib>{sample=bib}")
|
668
627
|
end
|
669
628
|
|
670
|
-
def test_bib_htmlext
|
671
|
-
def @chapter.bibpaper(id)
|
672
|
-
Book::BibpaperIndex::Item.new("samplebib",1,"sample bib")
|
673
|
-
end
|
674
|
-
|
675
|
-
@config["htmlext"] = "xhtml"
|
676
|
-
assert_equal %Q|<a href="bib.xhtml#bib-samplebib">[1]</a>|, compile_inline("@<bib>{samplebib}")
|
677
|
-
end
|
678
|
-
|
679
629
|
def test_bibpaper
|
680
630
|
def @chapter.bibpaper(id)
|
681
631
|
Book::BibpaperIndex::Item.new("samplebib",1,"sample bib")
|
682
632
|
end
|
683
633
|
|
684
634
|
actual = compile_block("//bibpaper[samplebib][sample bib @<b>{bold}]{\na\nb\n//}\n")
|
685
|
-
assert_equal %Q|<div class=\"bibpaper\">\n<a id=\"bib-samplebib\">[1]</a> sample bib <b>bold</b>\n<p>ab</p
|
635
|
+
assert_equal %Q|<div class=\"bibpaper\">\n<a id=\"bib-samplebib\">[1]</a> sample bib <b>bold</b>\n<p>ab</p>\n</div>\n|, actual
|
686
636
|
end
|
687
637
|
|
688
638
|
def test_bibpaper_normalized
|
@@ -691,7 +641,7 @@ EOS
|
|
691
641
|
end
|
692
642
|
|
693
643
|
actual = compile_block("//bibpaper[sample=bib][sample bib @<b>{bold}]{\na\nb\n//}\n")
|
694
|
-
assert_equal %Q|<div class=\"bibpaper\">\n<a id=\"bib-id_sample_3Dbib\">[1]</a> sample bib <b>bold</b>\n<p>ab</p
|
644
|
+
assert_equal %Q|<div class=\"bibpaper\">\n<a id=\"bib-id_sample_3Dbib\">[1]</a> sample bib <b>bold</b>\n<p>ab</p>\n</div>\n|, actual
|
695
645
|
end
|
696
646
|
|
697
647
|
def test_bibpaper_with_anchor
|
@@ -700,7 +650,7 @@ EOS
|
|
700
650
|
end
|
701
651
|
|
702
652
|
actual = compile_block("//bibpaper[samplebib][sample bib @<href>{http://example.jp}]{\na\nb\n//}\n")
|
703
|
-
assert_equal %Q|<div class=\"bibpaper\">\n<a id=\"bib-samplebib\">[1]</a> sample bib <a href=\"http://example.jp\" class=\"link\">http://example.jp</a>\n<p>ab</p
|
653
|
+
assert_equal %Q|<div class=\"bibpaper\">\n<a id=\"bib-samplebib\">[1]</a> sample bib <a href=\"http://example.jp\" class=\"link\">http://example.jp</a>\n<p>ab</p>\n</div>\n|, actual
|
704
654
|
end
|
705
655
|
|
706
656
|
def column_helper(review)
|
@@ -748,7 +698,6 @@ EOS
|
|
748
698
|
<h3><a id="column-1"></a>test</h3>
|
749
699
|
<p>inside column</p>
|
750
700
|
</div>
|
751
|
-
|
752
701
|
<h3><a id="h1-0-1"></a>next level</h3>
|
753
702
|
EOS
|
754
703
|
|
@@ -784,7 +733,6 @@ EOS
|
|
784
733
|
<h3 id="foo"><a id="column-1"></a>test</h3>
|
785
734
|
<p>inside column</p>
|
786
735
|
</div>
|
787
|
-
|
788
736
|
<h3><a id="h1-0-1"></a>next level</h3>
|
789
737
|
<p>this is コラム「test」.</p>
|
790
738
|
EOS
|
@@ -941,6 +889,70 @@ EOS
|
|
941
889
|
assert_equal expected, actual
|
942
890
|
end
|
943
891
|
|
892
|
+
def test_ul_in_note
|
893
|
+
src =<<-EOS
|
894
|
+
//note{
|
895
|
+
|
896
|
+
aaaa
|
897
|
+
bbb
|
898
|
+
|
899
|
+
* A
|
900
|
+
* B
|
901
|
+
//}
|
902
|
+
EOS
|
903
|
+
|
904
|
+
expected =<<-EOS
|
905
|
+
<div class=\"note\">
|
906
|
+
<p>aaaabbb</p>
|
907
|
+
<ul>
|
908
|
+
<li>A</li>
|
909
|
+
<li>B</li>
|
910
|
+
</ul>
|
911
|
+
</div>
|
912
|
+
EOS
|
913
|
+
actual = compile_block(src)
|
914
|
+
assert_equal expected, actual
|
915
|
+
end
|
916
|
+
|
917
|
+
def test_ul_in_note_and_emlist
|
918
|
+
src =<<-EOS
|
919
|
+
//note{
|
920
|
+
|
921
|
+
aaaa
|
922
|
+
bbb
|
923
|
+
|
924
|
+
//emlist{
|
925
|
+
abc
|
926
|
+
ddd
|
927
|
+
* A
|
928
|
+
* B
|
929
|
+
//}
|
930
|
+
|
931
|
+
* A
|
932
|
+
* B
|
933
|
+
//}
|
934
|
+
EOS
|
935
|
+
|
936
|
+
expected =<<-EOS
|
937
|
+
<div class=\"note\">
|
938
|
+
<p>aaaabbb</p>
|
939
|
+
<div class="emlist-code">
|
940
|
+
<pre class="emlist">abc
|
941
|
+
ddd
|
942
|
+
* A
|
943
|
+
* B
|
944
|
+
</pre>
|
945
|
+
</div>
|
946
|
+
<ul>
|
947
|
+
<li>A</li>
|
948
|
+
<li>B</li>
|
949
|
+
</ul>
|
950
|
+
</div>
|
951
|
+
EOS
|
952
|
+
actual = compile_block(src)
|
953
|
+
assert_equal expected, actual
|
954
|
+
end
|
955
|
+
|
944
956
|
def test_ol
|
945
957
|
src =<<-EOS
|
946
958
|
3. AAA
|
@@ -1030,4 +1042,23 @@ EOS
|
|
1030
1042
|
EOS
|
1031
1043
|
assert_equal expected, actual
|
1032
1044
|
end
|
1045
|
+
|
1046
|
+
|
1047
|
+
## inline nesting tests
|
1048
|
+
def test_href_nest
|
1049
|
+
actual = compile_inline("@<href>{http://github.com,@<b>{G}itHub}")
|
1050
|
+
assert_equal %Q|<a href="http://github.com" class="link"><b>G</b>itHub</a>|, actual
|
1051
|
+
end
|
1052
|
+
|
1053
|
+
def test_inline_tti_nest
|
1054
|
+
actual = compile_inline("test @<tt>{aa@<i>{inline test}bb} test2")
|
1055
|
+
assert_equal %Q|test <tt>aa<i>inline test</i>bb</tt> test2|, actual
|
1056
|
+
end
|
1057
|
+
|
1058
|
+
def test_inline_ttib_nest
|
1059
|
+
actual = compile_inline("test @<tt>{aa@<i>{inline @<b>{te}st}bb} test2")
|
1060
|
+
assert_equal %Q|test <tt>aa<i>inline <b>te</b>st</i>bb</tt> test2|, actual
|
1061
|
+
end
|
1062
|
+
|
1063
|
+
|
1033
1064
|
end
|