review 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,32 @@
1
+
2
+
3
+
4
+
5
+
6
+ %%% profile
7
+
8
+ \thispagestyle{empty}\chapter*{Profile}
9
+ some profile
10
+
11
+
12
+
13
+ %%% advfile
14
+
15
+ \thispagestyle{empty}\chapter*{Ad}
16
+ some ad content
17
+
18
+
19
+
20
+ %%% colophon
21
+
22
+
23
+ %%% backcover
24
+
25
+ \clearpage
26
+ \thispagestyle{empty}\AddToShipoutPictureBG{%
27
+ \AtPageLowerLeft{\includegraphics[width=\paperwidth,height=\paperheight]{images/backcover.png}}
28
+ }
29
+ \null
30
+
31
+
32
+ \end{document}
@@ -75,6 +75,9 @@ epubversion: 3
75
75
  # HTMLのバージョン (4か5。epubversionを3にしたときには5にする)
76
76
  # htmlversion: 5
77
77
 
78
+ # 目次を作成するか。省略した場合はnull(作成しない)
79
+ # toc: true
80
+
78
81
  # 目次として抽出する見出しレベル。省略した場合は2
79
82
  toclevel: 2
80
83
  # 本文でセクション番号を表示する見出しレベル。省略した場合は2
@@ -329,7 +329,9 @@ EOT
329
329
  end
330
330
 
331
331
  def test_stage3_flat
332
- @producer.merge_params({"flattoc" => true, "flattocindent" => false})
332
+ @producer.merge_params({"epubmaker" =>
333
+ {"flattoc" => true, "flattocindent" => false}
334
+ })
333
335
  stage3
334
336
  @producer.mytoc(@output)
335
337
  expect = <<EOT
data/test/test_helper.rb CHANGED
@@ -6,6 +6,10 @@ def touch_file(path)
6
6
  path
7
7
  end
8
8
 
9
+ def assets_dir
10
+ File.join(File.dirname(__FILE__), "assets")
11
+ end
12
+
9
13
  def prepare_samplebook(srcdir)
10
14
  samplebook_dir = File.expand_path("sample-book/src/", File.dirname(__FILE__))
11
15
  FileUtils.cp_r(Dir.glob(samplebook_dir + "/*"), srcdir)
@@ -39,7 +39,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
39
39
 
40
40
  def test_headline_level1
41
41
  actual = compile_block("={test} this is test.\n")
42
- assert_equal %Q|<h1 id="test"><a id="h1"></a>第1章 this is test.</h1>\n|, actual
42
+ assert_equal %Q|<h1 id="test"><a id="h1"></a><span class="secno">第1章 </span>this is test.</h1>\n|, actual
43
43
  end
44
44
 
45
45
  def test_headline_level1_postdef
@@ -49,7 +49,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
49
49
  end
50
50
  end
51
51
  actual = compile_block("={test} this is test.\n")
52
- assert_equal %Q|<h1 id="test"><a id="h1"></a>付録1 this is test.</h1>\n|, actual
52
+ assert_equal %Q|<h1 id="test"><a id="h1"></a><span class="secno">付録1 </span>this is test.</h1>\n|, actual
53
53
  end
54
54
 
55
55
  def test_headline_level2_postdef
@@ -59,7 +59,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
59
59
  end
60
60
  end
61
61
  actual = compile_block("=={test} this is test.\n")
62
- assert_equal %Q|\n<h2 id="test"><a id="h1-1"></a>1.1 this is test.</h2>\n|, actual
62
+ assert_equal %Q|\n<h2 id="test"><a id="h1-1"></a><span class="secno">1.1 </span>this is test.</h2>\n|, actual
63
63
  end
64
64
 
65
65
  def test_headline_level1_postdef_roman
@@ -70,7 +70,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
70
70
  end
71
71
  end
72
72
  actual = compile_block("={test} this is test.\n")
73
- assert_equal %Q|<h1 id="test"><a id="hI"></a>付録I this is test.</h1>\n|, actual
73
+ assert_equal %Q|<h1 id="test"><a id="hI"></a><span class="secno">付録I </span>this is test.</h1>\n|, actual
74
74
  end
75
75
 
76
76
  def test_headline_level2_postdef_roman
@@ -81,7 +81,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
81
81
  end
82
82
  end
83
83
  actual = compile_block("=={test} this is test.\n")
84
- assert_equal %Q|\n<h2 id="test"><a id="hI-1"></a>I.1 this is test.</h2>\n|, actual
84
+ assert_equal %Q|\n<h2 id="test"><a id="hI-1"></a><span class="secno">I.1 </span>this is test.</h2>\n|, actual
85
85
  end
86
86
 
87
87
  def test_headline_level1_postdef_alpha
@@ -92,7 +92,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
92
92
  end
93
93
  end
94
94
  actual = compile_block("={test} this is test.\n")
95
- assert_equal %Q|<h1 id="test"><a id="hA"></a>付録A this is test.</h1>\n|, actual
95
+ assert_equal %Q|<h1 id="test"><a id="hA"></a><span class="secno">付録A </span>this is test.</h1>\n|, actual
96
96
  end
97
97
 
98
98
  def test_headline_level2_postdef_alpha
@@ -103,7 +103,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
103
103
  end
104
104
  end
105
105
  actual = compile_block("=={test} this is test.\n")
106
- assert_equal %Q|\n<h2 id="test"><a id="hA-1"></a>A.1 this is test.</h2>\n|, actual
106
+ assert_equal %Q|\n<h2 id="test"><a id="hA-1"></a><span class="secno">A.1 </span>this is test.</h2>\n|, actual
107
107
  end
108
108
 
109
109
  def test_headline_level1_without_secno
@@ -114,17 +114,17 @@ class HTMLBuidlerTest < Test::Unit::TestCase
114
114
 
115
115
  def test_headline_level1_with_tricky_id
116
116
  actual = compile_block("={123 あ_;} this is test.\n")
117
- assert_equal %Q|<h1 id="id_123-_E3_81_82___3B"><a id="h1"></a>第1章 this is test.</h1>\n|, actual
117
+ assert_equal %Q|<h1 id="id_123-_E3_81_82___3B"><a id="h1"></a><span class="secno">第1章 </span>this is test.</h1>\n|, actual
118
118
  end
119
119
 
120
120
  def test_headline_level1_with_inlinetag
121
121
  actual = compile_block("={test} this @<b>{is} test.<&\">\n")
122
- assert_equal %Q|<h1 id="test"><a id="h1"></a>第1章 this <b>is</b> test.&lt;&amp;&quot;&gt;</h1>\n|, actual
122
+ assert_equal %Q|<h1 id="test"><a id="h1"></a><span class="secno">第1章 </span>this <b>is</b> test.&lt;&amp;&quot;&gt;</h1>\n|, actual
123
123
  end
124
124
 
125
125
  def test_headline_level2
126
126
  actual = compile_block("=={test} this is test.\n")
127
- assert_equal %Q|\n<h2 id="test"><a id="h1-1"></a>1.1 this is test.</h2>\n|, actual
127
+ assert_equal %Q|\n<h2 id="test"><a id="h1-1"></a><span class="secno">1.1 </span>this is test.</h2>\n|, actual
128
128
  end
129
129
 
130
130
  def test_headline_level3
@@ -135,7 +135,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
135
135
  def test_headline_level3_with_secno
136
136
  @book.config["secnolevel"] = 3
137
137
  actual = compile_block("==={test} this is test.\n")
138
- assert_equal %Q|\n<h3 id="test"><a id="h1-0-1"></a>1.0.1 this is test.</h3>\n|, actual
138
+ assert_equal %Q|\n<h3 id="test"><a id="h1-0-1"></a><span class="secno">1.0.1 </span>this is test.</h3>\n|, actual
139
139
  end
140
140
 
141
141
  def test_label
@@ -453,6 +453,12 @@ class HTMLBuidlerTest < Test::Unit::TestCase
453
453
  assert_equal %Q|<dl>\n<dt>foo[bar]</dt>\n<dd>foo.bar.</dd>\n</dl>\n|, actual
454
454
  end
455
455
 
456
+ def test_dlist_with_comment
457
+ source = ": title\n body\n\#@ comment\n\#@ comment\n: title2\n body2\n"
458
+ actual = compile_block(source)
459
+ assert_equal %Q|<dl>\n<dt>title</dt>\n<dd>body</dd>\n<dt>title2</dt>\n<dd>body2</dd>\n</dl>\n|, actual
460
+ end
461
+
456
462
  def test_list
457
463
  def @chapter.list(id)
458
464
  Book::ListIndex::Item.new("samplelist",1)
@@ -531,6 +537,25 @@ class HTMLBuidlerTest < Test::Unit::TestCase
531
537
  assert_equal "<div class=\"code\">\n<p class=\"caption\">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</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>\n</div>\n", actual
532
538
  end
533
539
 
540
+ def test_listnum_pygments_lang_without_lang
541
+ def @chapter.list(id)
542
+ Book::ListIndex::Item.new("samplelist",1)
543
+ end
544
+ begin
545
+ require 'pygments'
546
+ rescue LoadError
547
+ $stderr.puts "skip test_listnum_pygments_lang (cannot find pygments.rb)"
548
+ return true
549
+ end
550
+ @book.config["highlight"] = {}
551
+ @book.config["highlight"]["html"] = "pygments"
552
+ @book.config["highlight"]["lang"] = "ruby"
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")
554
+
555
+ assert_equal "<div class=\"code\">\n<p class=\"caption\">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</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>\n</div>\n", actual
556
+ end
557
+
558
+
534
559
  def test_emlist
535
560
  actual = compile_block("//emlist{\nlineA\nlineB\n//}\n")
536
561
  assert_equal %Q|<div class="emlist-code">\n<pre class="emlist">lineA\nlineB\n</pre>\n</div>\n|, actual
data/test/test_i18n.rb CHANGED
@@ -74,8 +74,10 @@ class I18nTest < Test::Unit::TestCase
74
74
  File.open(file, "w"){|f| f.write("ja:\n foo: \"bar\"\nen:\n foo: \"buz\"\n")}
75
75
  I18n.setup
76
76
  assert_equal "bar", I18n.t("foo")
77
+ assert_equal "図", I18n.t("image")
77
78
  I18n.setup("en")
78
79
  assert_equal "buz", I18n.t("foo")
80
+ assert_equal "Figure ", I18n.t("image")
79
81
  end
80
82
  end
81
83
  end
@@ -128,7 +130,7 @@ class I18nTest < Test::Unit::TestCase
128
130
  def test_htmlbuilder
129
131
  _setup_htmlbuilder
130
132
  actual = compile_block("={test} this is test.\n")
131
- assert_equal %Q|<h1 id="test"><a id="h1"></a>Chapter 1. this is test.</h1>\n|, actual
133
+ assert_equal %Q|<h1 id="test"><a id="h1"></a><span class="secno">Chapter 1. </span>this is test.</h1>\n|, actual
132
134
  end
133
135
 
134
136
  def _setup_htmlbuilder
data/test/test_index.rb CHANGED
@@ -155,5 +155,20 @@ class IndexTest < Test::Unit::TestCase
155
155
  end
156
156
  end
157
157
 
158
+ def test_HeadelineIndex8
159
+ src = <<-EOB
160
+ = chap1
161
+ == sec1
162
+ === sec1-1
163
+ ==== sec1-1-1
164
+
165
+ EOB
166
+ book = Book::Base.load
167
+ chap = Book::Chapter.new(book, 1, '-', nil)
168
+ index = Book::HeadlineIndex.parse(src, chap)
169
+ assert_equal "1.1.1", index.number('sec1-1')
170
+ end
171
+
172
+
158
173
  end
159
174
 
@@ -254,6 +254,15 @@ class LATEXBuidlerTest < Test::Unit::TestCase
254
254
  assert_equal %Q|\n\\vspace{-1.5em}\\begin{reviewemlistlst}[title={\\relax},language={sql}]\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n\\end{reviewemlistlst}\n|, actual
255
255
  end
256
256
 
257
+ def test_emlist_lst_without_lang
258
+ @book.config["highlight"] = {}
259
+ @book.config["highlight"]["latex"] = "listings"
260
+ @book.config["highlight"]["lang"] = "sql"
261
+ actual = compile_block("//emlist[]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
262
+ assert_equal %Q|\n\\vspace{-1.5em}\\begin{reviewemlistlst}[title={\\relax},language={sql}]\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n\\end{reviewemlistlst}\n|, actual
263
+ end
264
+
265
+
257
266
  def test_emlist_caption
258
267
  actual = compile_block("//emlist[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
259
268
  assert_equal %Q|\n\\reviewemlistcaption{cap1}\n\\begin{reviewemlist}\nfoo\nbar\n\nbuz\n\\end{reviewemlist}\n|, actual
@@ -63,12 +63,12 @@ class PDFMakerTest < Test::Unit::TestCase
63
63
  assert_equal yml, "hoge.yml"
64
64
  end
65
65
 
66
- def test_make_custom_titlepage
66
+ def test_make_custom_page
67
67
  Dir.mktmpdir do |dir|
68
68
  coverfile = "cover.html"
69
69
  content = "<html><body>test</body></html>"
70
70
  File.open(File.join(dir, "cover.tex"),"w"){|f| f.write(content) }
71
- page = @maker.make_custom_titlepage(File.join(dir, coverfile))
71
+ page = @maker.make_custom_page(File.join(dir, coverfile))
72
72
  assert_equal(content, page)
73
73
  end
74
74
  end
@@ -128,4 +128,41 @@ class PDFMakerTest < Test::Unit::TestCase
128
128
  end
129
129
  end
130
130
 
131
+ def test_gettemplate
132
+ Dir.mktmpdir do |dir|
133
+ tmpl = @maker.get_template(@config)
134
+ expect = File.read(File.join(assets_dir,"test_template.tex"))
135
+ assert_equal(expect, tmpl)
136
+ end
137
+ end
138
+
139
+ def test_gettemplate_with_backmatter
140
+ if RUBY_VERSION =~ /^1.8/
141
+ $stderr.puts "skip test_gettemplate_with_backmatter (for travis error)"
142
+ return
143
+ end
144
+ @config.merge!({
145
+ "backcover"=>"backcover.html",
146
+ "profile"=>"profile.html",
147
+ "advfile"=>"advfile.html",
148
+ })
149
+ Dir.mktmpdir do |dir|
150
+ Dir.chdir(dir) do
151
+ profile = "\\thispagestyle{empty}\\chapter*{Profile}\nsome profile\n"
152
+ File.open(File.join(dir, "profile.tex"),"w"){|f| f.write(profile) }
153
+ advfile = "\\thispagestyle{empty}\\chapter*{Ad}\nsome ad content\n"
154
+ File.open(File.join(dir, "advfile.tex"),"w"){|f| f.write(advfile) }
155
+ backcover = "\\clearpage\n\\thispagestyle{empty}\\AddToShipoutPictureBG{%\n\\AtPageLowerLeft{\\includegraphics[width=\\paperwidth,height=\\paperheight]{images/backcover.png}}\n}\n\\null"
156
+ File.open(File.join(dir, "backcover.tex"),"w"){|f| f.write(backcover) }
157
+
158
+ expect = File.read(File.join(assets_dir,"test_template_backmatter.tex"))
159
+
160
+ maker = ReVIEW::PDFMaker.new
161
+ tmpl = maker.get_template(@config)
162
+ tmpl.gsub!(/\A.*%% backmatter begins\n/m,"")
163
+ assert_equal(expect, tmpl)
164
+ end
165
+ end
166
+ end
167
+
131
168
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: review
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - kmuto
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-02-28 00:00:00.000000000 Z
12
+ date: 2015-06-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -108,6 +108,8 @@ files:
108
108
  - debian/review.links
109
109
  - debian/rules
110
110
  - debian/source/format
111
+ - doc/NEWS.ja.md
112
+ - doc/NEWS.md
111
113
  - doc/catalog.ja.md
112
114
  - doc/catalog.md
113
115
  - doc/format.ja.md
@@ -158,6 +160,7 @@ files:
158
160
  - lib/review/latexindex.rb
159
161
  - lib/review/latexutils.rb
160
162
  - lib/review/layout.tex.erb
163
+ - lib/review/lineinput.rb
161
164
  - lib/review/makerhelper.rb
162
165
  - lib/review/markdownbuilder.rb
163
166
  - lib/review/pdfmaker.rb
@@ -174,6 +177,8 @@ files:
174
177
  - review.gemspec
175
178
  - rubocop-todo.yml
176
179
  - test/CHAPS
180
+ - test/assets/test_template.tex
181
+ - test/assets/test_template_backmatter.tex
177
182
  - test/bib.re
178
183
  - test/book_test_helper.rb
179
184
  - test/sample-book/README.md
@@ -242,12 +247,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
242
247
  version: '0'
243
248
  requirements: []
244
249
  rubyforge_project:
245
- rubygems_version: 2.4.5
250
+ rubygems_version: 2.4.6
246
251
  signing_key:
247
252
  specification_version: 4
248
253
  summary: 'Re:VIEW: a easy-to-use digital publishing system'
249
254
  test_files:
250
255
  - test/CHAPS
256
+ - test/assets/test_template.tex
257
+ - test/assets/test_template_backmatter.tex
251
258
  - test/bib.re
252
259
  - test/book_test_helper.rb
253
260
  - test/sample-book/README.md
@@ -296,4 +303,3 @@ test_files:
296
303
  - test/test_textutils.rb
297
304
  - test/test_topbuilder.rb
298
305
  - test/test_uuid.rb
299
- has_rdoc: