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
@@ -0,0 +1,47 @@
|
|
1
|
+
# Supporting local rules of EPUB files
|
2
|
+
|
3
|
+
EPUB files that generated by Re:VIEW (review-epubmaker) should be valid in eubcheck in IDPF.
|
4
|
+
|
5
|
+
But some e-book stores have their own rules, so they reject EPUB files by Re:VIEW. To pass their rules, you can customize OPF file with config.yml.
|
6
|
+
|
7
|
+
## EBPAJ EPUB 3 File Creation Guide
|
8
|
+
|
9
|
+
* http://ebpaj.jp/counsel/guide
|
10
|
+
|
11
|
+
EBPAJ, the Electronic Book Publishers Association of Japan, releases the guide for publishers to create EPUB files that make nothing of trouble in major EPUB readers.
|
12
|
+
|
13
|
+
To pass their guide, you can add some settings into config.yml:
|
14
|
+
|
15
|
+
```yaml
|
16
|
+
opf_prefix: {ebpaj: "http://www.ebpaj.jp/"}
|
17
|
+
opf_meta: {"ebpaj:guide-version": "1.1.3"}
|
18
|
+
```
|
19
|
+
|
20
|
+
With this settings, Re:VIEW generates OPF files with epbaj attributes:
|
21
|
+
|
22
|
+
```xml
|
23
|
+
<package ... prefix="ebpaj: http://www.ebpaj.jp/">
|
24
|
+
...
|
25
|
+
<meta property="ebpaj:guide-version">1.1.3</meta>
|
26
|
+
```
|
27
|
+
|
28
|
+
But EPUB files that Re:VIEW generates are not the same of name and structure to EBPAJ guide.
|
29
|
+
|
30
|
+
|
31
|
+
## iBookStore
|
32
|
+
|
33
|
+
Without special setting, iBooks has a margin between right page and left page in double-page spread.
|
34
|
+
|
35
|
+
To remove it, you can add some settings in config.yml.
|
36
|
+
|
37
|
+
```yaml
|
38
|
+
opf_prefix: {ibooks: "http://vocabulary.itunes.apple.com/rdf/ibooks/vocabulary-extensions-1.0/"}
|
39
|
+
opf_meta: {"ibooks:binding": "false"}
|
40
|
+
```
|
41
|
+
|
42
|
+
If you have already some settings, merge them:
|
43
|
+
|
44
|
+
```yaml
|
45
|
+
opf_prefix: {ebpaj: "http://www.ebpaj.jp/", ibooks: "http://vocabulary.itunes.apple.com/rdf/ibooks/vocabulary-extensions-1.0/"}
|
46
|
+
opf_meta: {"ebpaj:guide-version": "1.1.3", "ibooks:binding": "false"}
|
47
|
+
```
|
data/doc/preproc.ja.md
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
# review-preproc ユーザガイド
|
2
|
+
|
3
|
+
Re:VIEWではソースコードなどを本文中に埋め込むことができます。
|
4
|
+
|
5
|
+
## `#@mapfile`
|
6
|
+
|
7
|
+
以下は`scripts/hello.rb`のソースを本文内に埋め込んでいます。
|
8
|
+
|
9
|
+
```review
|
10
|
+
//list[hello.rb][hello.rb]{
|
11
|
+
#@mapfile(scripts/hello.rb)
|
12
|
+
#!/usr/bin/env ruby
|
13
|
+
|
14
|
+
class Hello
|
15
|
+
def hello(name)
|
16
|
+
print "hello, #{name}!\n"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
if __FILE__ == $0
|
21
|
+
Hello.new.hello("world")
|
22
|
+
end
|
23
|
+
#@end
|
24
|
+
//}
|
25
|
+
```
|
26
|
+
「`#@mapfile(ファイル名)`」から「`#@end`」は、指定したファイル名のファイル全体を本文中に埋め込むための記法です。埋め込む際には、`review-preproc`コマンドを実行します。
|
27
|
+
|
28
|
+
まず、以下のように、引用したい部分に「`#@mapfile()`」と「`#@end`」だけを書きます。ここでは`//list`ブロック内にこの2行だけを記述しています。
|
29
|
+
|
30
|
+
```review
|
31
|
+
//list[hello.rb.1][hello.re]{
|
32
|
+
#@mapfile(scripts/hello.rb)
|
33
|
+
#@end
|
34
|
+
//}
|
35
|
+
```
|
36
|
+
このソースに対して、`review-preproc`コマンドを実行します。すると、変換結果の*.reファイルを標準出力に出力します。
|
37
|
+
|
38
|
+
```shell-session
|
39
|
+
$ review-preproc hello.re
|
40
|
+
```
|
41
|
+
`--replace`オプションをつければ、ファイルそのものを置き換えるようになります。
|
42
|
+
|
43
|
+
```shell-session
|
44
|
+
$ review-preproc --replace hello.re
|
45
|
+
```
|
46
|
+
|
47
|
+
なお、rakeを使ってビルドしている場合、Rakefileに以下のような記述を追加すると、このコマンドを実行するtaskが定義されます。
|
48
|
+
|
49
|
+
```rake
|
50
|
+
desc 'preproc all'
|
51
|
+
task :preproc do
|
52
|
+
Dir.glob("*.re").each do |file|
|
53
|
+
sh "review-preproc --replace #{file}"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
```
|
57
|
+
|
58
|
+
以下のように実行すれば、コマンドが実行されます。
|
59
|
+
|
60
|
+
```shell-session
|
61
|
+
$ rake preproc
|
62
|
+
```
|
63
|
+
|
64
|
+
## `#@maprange`
|
65
|
+
|
66
|
+
対象ファイルの一部だけ抜粋することもできます。こちらは「`#@maprange`」という記法を使います。
|
67
|
+
|
68
|
+
対象ファイルの抜粋したい部分の前後に、「`#@range_begin(ID)`」と「`#@range_end`」という記法を埋め込んでおきます。`#@range_begin`の引数には、その断片を抽出する際に使用するIDを指定します。以下の例では「sample」というIDにしています。
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
#!/usr/bin/env ruby
|
72
|
+
|
73
|
+
class Hello
|
74
|
+
#@range_begin(sample)
|
75
|
+
def hello(name)
|
76
|
+
print "hello, #{name}!\n"
|
77
|
+
end
|
78
|
+
#@range_end(sample)
|
79
|
+
end
|
80
|
+
|
81
|
+
if __FILE__ == $0
|
82
|
+
Hello.new.hello("world")
|
83
|
+
end
|
84
|
+
```
|
85
|
+
*.reファイルの方には、「`#@mapfile(ファイル名)`」ではなく「`#@maprange(ファイル名,ID)`」を記述します。
|
86
|
+
|
87
|
+
```review
|
88
|
+
//list[range.rb][range.rb(抜粋)]{
|
89
|
+
#@maprange(scripts/range.rb,sample)
|
90
|
+
#@end
|
91
|
+
//}
|
92
|
+
```
|
93
|
+
|
94
|
+
あとは、先ほど同様、`review-preproc`コマンドか`rake preproc`コマンドを実行します。そうすると、`scripts/range.rb`の一部が抽出されて埋め込まれます。
|
95
|
+
|
96
|
+
```review
|
97
|
+
//list[range.rb][range.rb(抜粋)]{
|
98
|
+
#@maprange(scripts/range.rb,sample)
|
99
|
+
def hello(name)
|
100
|
+
print "hello, #{name}!\n"
|
101
|
+
end
|
102
|
+
#@end
|
103
|
+
//}
|
104
|
+
```
|
105
|
+
|
106
|
+
## `#@@maprange`
|
107
|
+
|
108
|
+
もっとも、Ruby以外では「`#@range_begin`」などがコメントと解釈されないこともあります。そのような場合、その言語のコメントの中に「`#@@range_begin`」と「`#@@range_end`」とを記述します。
|
109
|
+
|
110
|
+
Cのソースを例にします。対象となるrange.cは以下です。
|
111
|
+
|
112
|
+
```c
|
113
|
+
#include <stdio.h>
|
114
|
+
|
115
|
+
/* #@@range_begin(sample) */
|
116
|
+
void
|
117
|
+
put_hello(char *name)
|
118
|
+
{
|
119
|
+
printf("hello, %s!\n", name);
|
120
|
+
}
|
121
|
+
/* #@@range_end(sample) */
|
122
|
+
|
123
|
+
int main()
|
124
|
+
{
|
125
|
+
put_hello("world");
|
126
|
+
}
|
127
|
+
```
|
128
|
+
|
129
|
+
put_hello関数の定義の前後で「`#@@range_begin`」と「`#@@range_end`」が使われています。
|
130
|
+
|
131
|
+
これに対し、*.reファイルでは`#@maprange(scripts/range.c,sample)`と`#@end`を記述します。
|
132
|
+
|
133
|
+
```
|
134
|
+
//list[range.c][range.c(抜粋)]{
|
135
|
+
#@maprange(scripts/range.c,sample)
|
136
|
+
#@end
|
137
|
+
//}
|
138
|
+
```
|
139
|
+
|
140
|
+
変換した結果、以下のようになります。
|
141
|
+
|
142
|
+
```
|
143
|
+
//list[range.c][range.c(抜粋)]{
|
144
|
+
#@maprange(scripts/range.c,sample)
|
145
|
+
void
|
146
|
+
put_hello(char *name)
|
147
|
+
{
|
148
|
+
printf("hello, %s!\n", name);
|
149
|
+
}
|
150
|
+
#@end
|
151
|
+
//}
|
152
|
+
```
|
153
|
+
このようにすると、Cなどの言語のファイルに対しても、ソースの一部を抽出して埋め込むことができます。
|
data/doc/preproc.md
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
# `review-preproc` User Guide
|
2
|
+
|
3
|
+
Re:VIEW has a preprocessor, `review-preproc`. It can embed a (part of) file into *.re files.
|
4
|
+
|
5
|
+
## `#@mapfile`
|
6
|
+
|
7
|
+
The code below is a sample of embedding code from `scripts/hello.rb`.
|
8
|
+
|
9
|
+
```review
|
10
|
+
//list[hello.rb][hello.rb]{
|
11
|
+
#@mapfile(scripts/hello.rb)
|
12
|
+
#!/usr/bin/env ruby
|
13
|
+
|
14
|
+
class Hello
|
15
|
+
def hello(name)
|
16
|
+
print "hello, #{name}!\n"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
if __FILE__ == $0
|
21
|
+
Hello.new.hello("world")
|
22
|
+
end
|
23
|
+
#@end
|
24
|
+
//}
|
25
|
+
```
|
26
|
+
|
27
|
+
`#@mapfile(filename)` and `#@end` are markers for preprocessor. You can embed and update the content of the file `filename` into Re:VIEW file with `review-preproc` command.
|
28
|
+
|
29
|
+
First, add `#@mapfile()` and `#@end` on the document.
|
30
|
+
|
31
|
+
```review
|
32
|
+
//list[hello.rb.1][hello.re]{
|
33
|
+
#@mapfile(scripts/hello.rb)
|
34
|
+
#@end
|
35
|
+
//}
|
36
|
+
```
|
37
|
+
|
38
|
+
Then execute `review-preproc` command. The command display the result on stdout.
|
39
|
+
|
40
|
+
```shell-session
|
41
|
+
$ review-preproc hello.re
|
42
|
+
```
|
43
|
+
|
44
|
+
With `--replace` option, `review-preproc` replaces the Re:VIEW file.
|
45
|
+
|
46
|
+
```shell-session
|
47
|
+
$ review-preproc --replace hello.re
|
48
|
+
```
|
49
|
+
|
50
|
+
If you use `rake` to build Re:VIEW document, you can add the code to Rakefile to define a task of `review-preproc`.
|
51
|
+
|
52
|
+
```rake
|
53
|
+
desc 'preproc all'
|
54
|
+
task :preproc do
|
55
|
+
Dir.glob("*.re").each do |file|
|
56
|
+
sh "review-preproc --replace #{file}"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
```
|
60
|
+
|
61
|
+
Then, you can execute preprocessor with `rake`.
|
62
|
+
|
63
|
+
```shell-session
|
64
|
+
$ rake preproc
|
65
|
+
```
|
66
|
+
|
67
|
+
## `#@maprange`
|
68
|
+
|
69
|
+
You also can embed a part of the target file with `#@maprange` marker.
|
70
|
+
|
71
|
+
Add `#@range_begin(ID)` and `#@range_end` in the target file you want to embed.
|
72
|
+
In `#@range_begin(ID)`, you must add ID as parameger to identify the part.
|
73
|
+
|
74
|
+
In the code below, `sample` is the ID of the range to embed.
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
#!/usr/bin/env ruby
|
78
|
+
|
79
|
+
class Hello
|
80
|
+
#@range_begin(sample)
|
81
|
+
def hello(name)
|
82
|
+
print "hello, #{name}!\n"
|
83
|
+
end
|
84
|
+
#@range_end(sample)
|
85
|
+
end
|
86
|
+
|
87
|
+
if __FILE__ == $0
|
88
|
+
Hello.new.hello("world")
|
89
|
+
end
|
90
|
+
```
|
91
|
+
|
92
|
+
In *.re file, add `#@maprange(filename,ID)`, instead of `#@mapfile(filename)`, and `#@end`.
|
93
|
+
|
94
|
+
```review
|
95
|
+
//list[range.rb][range.rb(partial)]{
|
96
|
+
#@maprange(scripts/range.rb,sample)
|
97
|
+
#@end
|
98
|
+
//}
|
99
|
+
```
|
100
|
+
|
101
|
+
After that, execute `review-preproc` or `rake preproc`, and you get the *.re files embedded the `hello` method in `scripts/range.rb`.
|
102
|
+
|
103
|
+
```review
|
104
|
+
//list[range.rb][range.rb(partial)]{
|
105
|
+
#@maprange(scripts/range.rb,sample)
|
106
|
+
def hello(name)
|
107
|
+
print "hello, #{name}!\n"
|
108
|
+
end
|
109
|
+
#@end
|
110
|
+
//}
|
111
|
+
```
|
112
|
+
|
113
|
+
## `#@@maprange`
|
114
|
+
|
115
|
+
But in some language, a line `#@range_begin` is not a comment. If you want to embed some code of such languages, you can use new markers `#@@range_begin` and `#@@range_end` into a comment in the target document.
|
116
|
+
|
117
|
+
Let's explain how to do. A target file `range.c` is below:
|
118
|
+
|
119
|
+
```c
|
120
|
+
#include <stdio.h>
|
121
|
+
|
122
|
+
/* #@@range_begin(sample) */
|
123
|
+
void
|
124
|
+
put_hello(char *name)
|
125
|
+
{
|
126
|
+
printf("hello, %s!\n", name);
|
127
|
+
}
|
128
|
+
/* #@@range_end(sample) */
|
129
|
+
|
130
|
+
int main()
|
131
|
+
{
|
132
|
+
put_hello("world");
|
133
|
+
}
|
134
|
+
```
|
135
|
+
|
136
|
+
There are markers `#@@range_begin` and `#@@range_end` around `put_hello` method.
|
137
|
+
|
138
|
+
In `*.re`, add `#@maprange(scripts/range.c,sample)` and `#@end`.
|
139
|
+
|
140
|
+
|
141
|
+
```
|
142
|
+
//list[range.c][range.c(抜粋)]{
|
143
|
+
#@maprange(scripts/range.c,sample)
|
144
|
+
#@end
|
145
|
+
//}
|
146
|
+
```
|
147
|
+
|
148
|
+
With `review-preproc`, we get the result of conversion like below:
|
149
|
+
|
150
|
+
```
|
151
|
+
//list[range.c][range.c(抜粋)]{
|
152
|
+
#@maprange(scripts/range.c,sample)
|
153
|
+
void
|
154
|
+
put_hello(char *name)
|
155
|
+
{
|
156
|
+
printf("hello, %s!\n", name);
|
157
|
+
}
|
158
|
+
#@end
|
159
|
+
//}
|
160
|
+
```
|
data/lib/epubmaker/producer.rb
CHANGED
@@ -11,7 +11,6 @@
|
|
11
11
|
require 'tmpdir'
|
12
12
|
require 'fileutils'
|
13
13
|
require 'review/yamlloader'
|
14
|
-
require 'securerandom'
|
15
14
|
require 'epubmaker/content'
|
16
15
|
require 'epubmaker/epubv2'
|
17
16
|
require 'epubmaker/epubv3'
|
@@ -215,7 +214,6 @@ module EPUBMaker
|
|
215
214
|
"language" => "ja",
|
216
215
|
"date" => Time.now.strftime("%Y-%m-%d"),
|
217
216
|
"modified" => Time.now.strftime("%Y-%02m-%02dT%02H:%02M:%02SZ"),
|
218
|
-
"urnid" => "urn:uid:#{SecureRandom.uuid}",
|
219
217
|
"isbn" => nil,
|
220
218
|
"toclevel" => 2,
|
221
219
|
"stylesheet" => [],
|
@@ -297,7 +295,12 @@ module EPUBMaker
|
|
297
295
|
raise "Key #{k} must have a value. Abort." unless @params[k]
|
298
296
|
end
|
299
297
|
# array
|
300
|
-
%w[subject aut
|
298
|
+
%w[subject aut
|
299
|
+
a-adp a-ann a-arr a-art a-asn a-aqt a-aft a-aui a-ant a-bkp a-clb a-cmm a-dsr a-edt
|
300
|
+
a-ill a-lyr a-mdc a-mus a-nrt a-oth a-pht a-prt a-red a-rev a-spn a-ths a-trc a-trl
|
301
|
+
adp ann arr art asn aut aqt aft aui ant bkp clb cmm dsr edt
|
302
|
+
ill lyr mdc mus nrt oth pht pbl prt red rev spn ths trc trl
|
303
|
+
stylesheet rights].each do |item|
|
301
304
|
next unless @params[item]
|
302
305
|
@params[item] = [@params[item]] if @params[item].kind_of?(String)
|
303
306
|
end
|
data/lib/lineinput.rb
CHANGED
@@ -34,7 +34,7 @@ class LineInput
|
|
34
34
|
@lineno += 1
|
35
35
|
return @buf.pop
|
36
36
|
end
|
37
|
-
return nil if @eof_p
|
37
|
+
return nil if @eof_p # to avoid ARGF blocking.
|
38
38
|
line = @input.gets
|
39
39
|
@eof_p = true unless line
|
40
40
|
@lineno += 1
|
@@ -113,7 +113,7 @@ class LineInput
|
|
113
113
|
buf
|
114
114
|
end
|
115
115
|
|
116
|
-
alias_method :span, :getlines_while
|
116
|
+
alias_method :span, :getlines_while # from Haskell
|
117
117
|
|
118
118
|
def until_match(re)
|
119
119
|
while line = gets()
|
@@ -134,11 +134,11 @@ class LineInput
|
|
134
134
|
buf
|
135
135
|
end
|
136
136
|
|
137
|
-
alias_method :break, :getlines_until
|
137
|
+
alias_method :break, :getlines_until # from Haskell
|
138
138
|
|
139
139
|
def until_terminator(re)
|
140
140
|
while line = gets()
|
141
|
-
return if re =~ line
|
141
|
+
return if re =~ line # discard terminal line
|
142
142
|
yield line
|
143
143
|
end
|
144
144
|
nil
|
data/lib/review/book/base.rb
CHANGED
@@ -109,9 +109,9 @@ module ReVIEW
|
|
109
109
|
end
|
110
110
|
|
111
111
|
def image(id)
|
112
|
-
return image_index()[id] if image_index().
|
113
|
-
return icon_index()[id] if icon_index().
|
114
|
-
return numberless_image_index()[id] if numberless_image_index().
|
112
|
+
return image_index()[id] if image_index().key?(id)
|
113
|
+
return icon_index()[id] if icon_index().key?(id)
|
114
|
+
return numberless_image_index()[id] if numberless_image_index().key?(id)
|
115
115
|
indepimage_index()[id]
|
116
116
|
end
|
117
117
|
|