review 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/COPYING +515 -0
- data/ChangeLog +1278 -0
- data/README.rdoc +21 -0
- data/Rakefile +42 -0
- data/VERSION +1 -0
- data/bin/review-check +190 -0
- data/bin/review-checkdep +63 -0
- data/bin/review-compile +165 -0
- data/bin/review-epubmaker +525 -0
- data/bin/review-index +108 -0
- data/bin/review-preproc +140 -0
- data/bin/review-validate +51 -0
- data/bin/review-vol +106 -0
- data/doc/format.re +486 -0
- data/doc/format.txt +434 -0
- data/doc/format_idg.txt +194 -0
- data/doc/format_sjis.txt +313 -0
- data/doc/sample.css +91 -0
- data/doc/sample.yaml +46 -0
- data/lib/lineinput.rb +155 -0
- data/lib/review/book.rb +580 -0
- data/lib/review/builder.rb +274 -0
- data/lib/review/compat.rb +22 -0
- data/lib/review/compiler.rb +483 -0
- data/lib/review/epubbuilder.rb +692 -0
- data/lib/review/ewbbuilder.rb +382 -0
- data/lib/review/exception.rb +21 -0
- data/lib/review/htmlbuilder.rb +370 -0
- data/lib/review/htmllayout.rb +19 -0
- data/lib/review/htmlutils.rb +27 -0
- data/lib/review/idgxmlbuilder.rb +1078 -0
- data/lib/review/index.rb +224 -0
- data/lib/review/latexbuilder.rb +420 -0
- data/lib/review/latexindex.rb +35 -0
- data/lib/review/latexutils.rb +52 -0
- data/lib/review/preprocessor.rb +520 -0
- data/lib/review/textutils.rb +19 -0
- data/lib/review/tocparser.rb +333 -0
- data/lib/review/tocprinter.rb +220 -0
- data/lib/review/topbuilder.rb +572 -0
- data/lib/review/unfold.rb +138 -0
- data/lib/review/volume.rb +66 -0
- data/lib/review.rb +4 -0
- data/review.gemspec +93 -0
- data/setup.rb +1587 -0
- data/test/test_epubbuilder.rb +73 -0
- data/test/test_helper.rb +2 -0
- data/test/test_htmlbuilder.rb +42 -0
- data/test/test_latexbuilder.rb +74 -0
- metadata +122 -0
data/bin/review-index
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
#
|
4
|
+
# Copyright (c) 1999-2007 Minero Aoki
|
5
|
+
# 2008-2010 Minero Aoki, Kenshi Muto
|
6
|
+
#
|
7
|
+
# This program is free software.
|
8
|
+
# You can distribute or modify this program under the terms of
|
9
|
+
# the GNU LGPL, Lesser General Public License version 2.1.
|
10
|
+
# For details of the GNU LGPL, see the file "COPYING".
|
11
|
+
#
|
12
|
+
|
13
|
+
require 'pathname'
|
14
|
+
|
15
|
+
bindir = Pathname.new(__FILE__).realpath.dirname
|
16
|
+
$LOAD_PATH.unshift((bindir + '../lib').realpath)
|
17
|
+
|
18
|
+
require 'review/book'
|
19
|
+
require 'review/tocparser'
|
20
|
+
require 'review/tocprinter'
|
21
|
+
require 'optparse'
|
22
|
+
|
23
|
+
def main
|
24
|
+
Signal.trap(:INT) { exit 1 }
|
25
|
+
Signal.trap(:PIPE, 'IGNORE')
|
26
|
+
_main
|
27
|
+
rescue Errno::EPIPE
|
28
|
+
exit 0
|
29
|
+
end
|
30
|
+
|
31
|
+
def _main
|
32
|
+
$KCODE = 'UTF-8' unless defined?(Encoding)
|
33
|
+
|
34
|
+
printer_class = ReVIEW::TextTOCPrinter
|
35
|
+
source = nil
|
36
|
+
upper = ReVIEW::TOCPrinter.default_upper_level
|
37
|
+
param = {
|
38
|
+
"inencoding" => "UTF-8",
|
39
|
+
"outencoding" => "UTF-8"
|
40
|
+
}
|
41
|
+
|
42
|
+
parser = OptionParser.new
|
43
|
+
parser.on('--inencoding=ENCODING', 'Set input encoding. (UTF-8, EUC, JIS, and SJIS)') {|enc|
|
44
|
+
param["inencoding"] = enc
|
45
|
+
}
|
46
|
+
parser.on('--outencoding=ENCODING', 'Set output encoding. (UTF-8[default], EUC, JIS, and SJIS)') {|enc|
|
47
|
+
param["outencoding"] = enc
|
48
|
+
}
|
49
|
+
parser.on('-a', '--all', 'print all chapters.') {
|
50
|
+
begin
|
51
|
+
source = ReVIEW.book
|
52
|
+
rescue ReVIEW::Error => err
|
53
|
+
error_exit err.message
|
54
|
+
end
|
55
|
+
}
|
56
|
+
parser.on('-p', '--part N', 'list only part N.') {|n|
|
57
|
+
source = ReVIEW.book.part(Integer(n)) or
|
58
|
+
error_exit "part #{n} does not exist in this book"
|
59
|
+
}
|
60
|
+
parser.on('-l', '--level N', 'list upto N level (1..4, default=4)') {|n|
|
61
|
+
upper = Integer(n)
|
62
|
+
unless (0..4).include?(upper) # 0 is hidden option
|
63
|
+
$stderr.puts "-l/--level option accepts only 1..4"
|
64
|
+
exit 1
|
65
|
+
end
|
66
|
+
}
|
67
|
+
parser.on('--text', 'output in plain text (default)') {
|
68
|
+
printer_class = ReVIEW::TextTOCPrinter
|
69
|
+
}
|
70
|
+
parser.on('--html', 'output in HTML') {
|
71
|
+
printer_class = ReVIEW::HTMLTOCPrinter
|
72
|
+
}
|
73
|
+
parser.on('--idg', 'output in InDesign XML') {
|
74
|
+
printer_class = ReVIEW::IDGTOCPrinter
|
75
|
+
}
|
76
|
+
parser.on('--help', 'print this message and quit.') {
|
77
|
+
puts parser.help
|
78
|
+
exit 0
|
79
|
+
}
|
80
|
+
begin
|
81
|
+
parser.parse!
|
82
|
+
rescue OptionParser::ParseError => err
|
83
|
+
$stderr.puts err.message
|
84
|
+
$stderr.puts parser.help
|
85
|
+
exit 1
|
86
|
+
end
|
87
|
+
if source
|
88
|
+
unless ARGV.empty?
|
89
|
+
error_exit '-a/-s option and file arguments are exclusive'
|
90
|
+
end
|
91
|
+
else
|
92
|
+
source = ReVIEW::ChapterSet.for_argv
|
93
|
+
end
|
94
|
+
|
95
|
+
begin
|
96
|
+
printer_class.new(upper, param).print_book source
|
97
|
+
rescue ReVIEW::Error, Errno::ENOENT => err
|
98
|
+
raise if $DEBUG
|
99
|
+
error_exit err.message
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def error_exit(msg)
|
104
|
+
$stderr.puts "#{File.basename($0)}: #{msg}"
|
105
|
+
exit 1
|
106
|
+
end
|
107
|
+
|
108
|
+
main
|
data/bin/review-preproc
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# $Id: review-preproc 3761 2007-12-31 07:20:09Z aamine $
|
4
|
+
#
|
5
|
+
# Copyright (c) 2010 Minero Aoki, Kenshi Muto
|
6
|
+
# Copyright (c) 1999-2007 Minero Aoki
|
7
|
+
#
|
8
|
+
# This program is free software.
|
9
|
+
# You can distribute or modify this program under the terms of
|
10
|
+
# the GNU LGPL, Lesser General Public License version 2.1.
|
11
|
+
# For details of the GNU LGPL, see the file "COPYING".
|
12
|
+
#
|
13
|
+
|
14
|
+
require 'pathname'
|
15
|
+
|
16
|
+
bindir = Pathname.new(__FILE__).realpath.dirname
|
17
|
+
$LOAD_PATH.unshift((bindir + '../lib').realpath)
|
18
|
+
|
19
|
+
require 'review/preprocessor'
|
20
|
+
require 'review/unfold'
|
21
|
+
require 'lineinput'
|
22
|
+
require 'stringio'
|
23
|
+
require 'fileutils'
|
24
|
+
require 'optparse'
|
25
|
+
|
26
|
+
def sigmain
|
27
|
+
Signal.trap(:PIPE, 'IGNORE')
|
28
|
+
Signal.trap(:INT) { exit 1 }
|
29
|
+
main
|
30
|
+
rescue Errno::EPIPE
|
31
|
+
exit 0
|
32
|
+
end
|
33
|
+
|
34
|
+
def main
|
35
|
+
$KCODE = 'UTF-8' unless defined?(Encoding)
|
36
|
+
|
37
|
+
param = {
|
38
|
+
"inencoding" => "UTF-8",
|
39
|
+
"outencoding" => "UTF-8",
|
40
|
+
}
|
41
|
+
|
42
|
+
mode = :output
|
43
|
+
parser = OptionParser.new
|
44
|
+
parser.banner = "Usage: #{File.basename($0)} [-c|-d|-s|--replace] [<file>...]"
|
45
|
+
parser.on('--inencoding=ENCODING', 'Set input encoding. (UTF-8, EUC, JIS, and
|
46
|
+
SJIS)') {|enc|
|
47
|
+
param["inencoding"] = enc
|
48
|
+
}
|
49
|
+
parser.on('--outencoding=ENCODING', 'Set output encoding. (UTF-8[default], EUC
|
50
|
+
, JIS, and SJIS)') {|enc|
|
51
|
+
param["outencoding"] = enc
|
52
|
+
}
|
53
|
+
parser.on('-c', '--check', 'Check if preprocess is needed.') {
|
54
|
+
mode = :check
|
55
|
+
}
|
56
|
+
parser.on('-d', '--diff', 'Show diff from current file.') {
|
57
|
+
mode = :diff
|
58
|
+
}
|
59
|
+
parser.on('--replace', 'Replace file by preprocessed one.') {
|
60
|
+
mode = :replace
|
61
|
+
}
|
62
|
+
parser.on('-s', '--strip', 'Strip preprocessor tags.') {
|
63
|
+
mode = :strip
|
64
|
+
}
|
65
|
+
parser.on('--final', 'Unfold text and strip preprocessor tags.') {
|
66
|
+
mode = :final
|
67
|
+
}
|
68
|
+
parser.on('--help', 'Print this message and quit.') {
|
69
|
+
puts parser.help
|
70
|
+
exit 0
|
71
|
+
}
|
72
|
+
begin
|
73
|
+
parser.parse!
|
74
|
+
rescue OptionParser::ParseError => err
|
75
|
+
$stderr.puts err.message
|
76
|
+
$stderr.puts parser.help
|
77
|
+
exit 1
|
78
|
+
end
|
79
|
+
|
80
|
+
pp = ReVIEW::Preprocessor.new(ReVIEW::Repository.new)
|
81
|
+
pp.setParameter(param)
|
82
|
+
current_file = nil
|
83
|
+
ARGV.each do |path|
|
84
|
+
current_file = path
|
85
|
+
case mode
|
86
|
+
when :output
|
87
|
+
File.open(path) {|f|
|
88
|
+
pp.process f, $stdout
|
89
|
+
}
|
90
|
+
when :replace
|
91
|
+
File.write "#{path}.pptmp", preproc(pp, path)
|
92
|
+
File.rename "#{path}.pptmp", path
|
93
|
+
when :diff, :check
|
94
|
+
tmp = '/tmp/review.pptmp'
|
95
|
+
begin
|
96
|
+
File.write tmp, preproc(pp, path)
|
97
|
+
if mode == :check
|
98
|
+
system "diff -qu #{path} #{tmp} >/dev/null || echo #{path}"
|
99
|
+
else
|
100
|
+
system "diff -u #{path} #{tmp}"
|
101
|
+
end
|
102
|
+
ensure
|
103
|
+
FileUtils.rm_f tmp
|
104
|
+
end
|
105
|
+
when :strip
|
106
|
+
File.open(path) {|f|
|
107
|
+
ReVIEW::Preprocessor::Strip.new(f).each do |line|
|
108
|
+
puts line
|
109
|
+
end
|
110
|
+
}
|
111
|
+
when :final
|
112
|
+
u = ReVIEW::Unfold.new
|
113
|
+
File.open(path) {|f|
|
114
|
+
u.unfold ReVIEW::Preprocessor::Strip.new(f), $stdout
|
115
|
+
}
|
116
|
+
else
|
117
|
+
raise "must not happen: #{mode}"
|
118
|
+
end
|
119
|
+
end
|
120
|
+
rescue ReVIEW::Error => err
|
121
|
+
raise if $DEBUG
|
122
|
+
$stderr.puts err.message
|
123
|
+
exit 1
|
124
|
+
end
|
125
|
+
|
126
|
+
def preproc(pp, path)
|
127
|
+
buf = StringIO.new
|
128
|
+
File.open(path) {|f|
|
129
|
+
pp.process f, buf
|
130
|
+
}
|
131
|
+
buf.string
|
132
|
+
end
|
133
|
+
|
134
|
+
def File.write(path, str)
|
135
|
+
File.open(path, 'w') {|f|
|
136
|
+
f.write str
|
137
|
+
}
|
138
|
+
end
|
139
|
+
|
140
|
+
sigmain
|
data/bin/review-validate
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Copyright (c) 2010 Kenshi Muto
|
3
|
+
#
|
4
|
+
# This program is free software
|
5
|
+
# You can distribute or modify this program under the terms of
|
6
|
+
# the GNU LGPL, Lesser General Public License version 2.1.
|
7
|
+
# For details of the GNU LGPL, see the file "COPYING".
|
8
|
+
#
|
9
|
+
|
10
|
+
# simple validator for ReVIEW
|
11
|
+
|
12
|
+
block = nil
|
13
|
+
maxcolcount = 0
|
14
|
+
colcount = 0
|
15
|
+
ln = 0
|
16
|
+
|
17
|
+
ARGF.each {|line|
|
18
|
+
ln = ln + 1
|
19
|
+
if line =~ /\A\/\/([a-z]+).+\{/
|
20
|
+
# block
|
21
|
+
_block = $1
|
22
|
+
puts "#{ln}: block #{_block} started, but previous block #{block} didn't close yet." unless block.nil?
|
23
|
+
block = _block
|
24
|
+
elsif line =~ /\A\/\/\}/
|
25
|
+
puts "#{ln}: block seen ended, but not opened." if block.nil?
|
26
|
+
block = nil
|
27
|
+
maxcolcount = 0
|
28
|
+
colcount = 0
|
29
|
+
elsif line =~ /\A(\d+\.)\s+/
|
30
|
+
# number
|
31
|
+
unless ["list", "emlist", "listnum", "emlistnum", "cmd", "image", "table"].include?(block)
|
32
|
+
puts "#{ln}: found $1 without the head space. Is it correct?"
|
33
|
+
end
|
34
|
+
elsif line =~ /\A\*\s+/
|
35
|
+
# itemize
|
36
|
+
unless ["list", "emlist", "listnum", "emlistnum", "cmd", "image", "table"].include?(block)
|
37
|
+
puts "#{ln}: found '*' without the head space. Is it correct?"
|
38
|
+
end
|
39
|
+
elsif line =~ /\A\s+(\d+\.)\s+/ && line =~ /\A\s+\*\s+/
|
40
|
+
unless ["list", "emlist", "listnum", "emlistnum", "cmd", "image", "table"].include?(block)
|
41
|
+
puts "#{ln}: found itemized list or numbered list in #{block}. Is it correct?"
|
42
|
+
end
|
43
|
+
elsif block == "table"
|
44
|
+
if line !~ /\A\-\-\-\-\-/
|
45
|
+
# table
|
46
|
+
colcount = line.split("\t").size
|
47
|
+
maxcolcount = colcount if maxcolcount == 0
|
48
|
+
puts "#{ln}: the number of table columns seems mismatch. (#{maxcolcount} != #{colcount})" if colcount != maxcolcount
|
49
|
+
end
|
50
|
+
end
|
51
|
+
}
|
data/bin/review-vol
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# $Id: review-vol 3901 2008-02-11 20:04:59Z aamine $
|
4
|
+
#
|
5
|
+
# Copyright (c) 2003-2007 Minero Aoki
|
6
|
+
#
|
7
|
+
# This program is free software.
|
8
|
+
# You can distribute or modify this program under the terms of
|
9
|
+
# the GNU LGPL, Lesser General Public License version 2.1.
|
10
|
+
# For details of the GNU LGPL, see the file "COPYING".
|
11
|
+
#
|
12
|
+
|
13
|
+
require 'pathname'
|
14
|
+
|
15
|
+
bindir = Pathname.new(__FILE__).realpath.dirname
|
16
|
+
$LOAD_PATH.unshift((bindir + '../lib').realpath)
|
17
|
+
|
18
|
+
require 'review/book'
|
19
|
+
require 'review/exception'
|
20
|
+
require 'optparse'
|
21
|
+
require 'nkf'
|
22
|
+
|
23
|
+
def main
|
24
|
+
$KCODE = 'UTF-8' unless defined?(Encoding)
|
25
|
+
|
26
|
+
@param = {
|
27
|
+
"inencoding" => "UTF-8",
|
28
|
+
"outencoding" => "UTF-8"
|
29
|
+
}
|
30
|
+
|
31
|
+
part_sensitive = false
|
32
|
+
parser = OptionParser.new
|
33
|
+
parser.on('-P', '--part-sensitive', 'Prints volume of each parts.') {
|
34
|
+
part_sensitive = true
|
35
|
+
}
|
36
|
+
parser.on('--inencoding=ENCODING', 'Set input encoding. (UTF-8, EUC, JIS, and SJIS)') {|enc|
|
37
|
+
@param["inencoding"] = enc
|
38
|
+
}
|
39
|
+
parser.on('--outencoding=ENCODING', 'Set output encoding. (UTF-8[default], EUC, JIS, and SJIS)') {|enc|
|
40
|
+
@param["outencoding"] = enc
|
41
|
+
}
|
42
|
+
parser.on('--help', 'Print this message and quit') {
|
43
|
+
puts parser.help
|
44
|
+
exit 0
|
45
|
+
}
|
46
|
+
begin
|
47
|
+
parser.parse!
|
48
|
+
rescue OptionParser::ParseError => err
|
49
|
+
$stderr.puts err.message
|
50
|
+
$stderr.puts parser.help
|
51
|
+
exit 1
|
52
|
+
end
|
53
|
+
|
54
|
+
book = ReVIEW.book
|
55
|
+
book.setParameter(@param)
|
56
|
+
if part_sensitive
|
57
|
+
sep = ""
|
58
|
+
book.each_part do |part|
|
59
|
+
print sep; sep = "\n"
|
60
|
+
puts "Part #{part.number}" if part.number
|
61
|
+
part.each_chapter do |chap|
|
62
|
+
print_chapter_volume chap
|
63
|
+
end
|
64
|
+
puts ' --------------------'
|
65
|
+
print_volume part.volume
|
66
|
+
end
|
67
|
+
puts '============================='
|
68
|
+
print_volume book.volume #puts "Total #{book.volume}"
|
69
|
+
else
|
70
|
+
book.each_chapter do |chap|
|
71
|
+
chap.setParameter(@param)
|
72
|
+
print_chapter_volume chap
|
73
|
+
end
|
74
|
+
puts '============================='
|
75
|
+
print_volume book.volume #puts "Total #{book.volume}"
|
76
|
+
end
|
77
|
+
rescue ReVIEW::ApplicationError, Errno::ENOENT => err
|
78
|
+
raise if $DEBUG
|
79
|
+
$stderr.puts "#{File.basename($0)}: #{err.message}"
|
80
|
+
exit 1
|
81
|
+
end
|
82
|
+
|
83
|
+
def print_chapter_volume(chap)
|
84
|
+
vol = chap.volume
|
85
|
+
title = chap.title
|
86
|
+
if @param["outencoding"] =~ /^EUC$/i
|
87
|
+
title = NKF.nkf("-W -e", title)
|
88
|
+
elsif @param["outencoding"] =~ /^SJIS$/i
|
89
|
+
title = NKF.nkf("-W -s", title)
|
90
|
+
elsif @param["outencoding"] =~ /^JIS$/i
|
91
|
+
title = NKF.nkf("-W -j", title)
|
92
|
+
end
|
93
|
+
printf "%s %3dKB %6dC %5dL %3dP %s %-s\n",
|
94
|
+
chapnumstr(chap.number), vol.kbytes, vol.chars, vol.lines, vol.page,
|
95
|
+
"#{chap.name} ".ljust(25, '.'), title
|
96
|
+
end
|
97
|
+
|
98
|
+
def print_volume(vol)
|
99
|
+
printf " %3dKB %6dC %5dL %3dP\n", vol.kbytes, vol.chars, vol.lines, vol.page
|
100
|
+
end
|
101
|
+
|
102
|
+
def chapnumstr(n)
|
103
|
+
n ? sprintf('%2d.', n) : ' '
|
104
|
+
end
|
105
|
+
|
106
|
+
main
|
data/doc/format.re
ADDED
@@ -0,0 +1,486 @@
|
|
1
|
+
= ReVIEW フォーマット
|
2
|
+
|
3
|
+
ReVIEW フォーマットの文法について解説します。ReVIEW
|
4
|
+
フォーマットは ASCII の EWB を基本としながら、一部に
|
5
|
+
RD や各種 Wiki の文法をとりいれて簡素化しています。
|
6
|
+
|
7
|
+
== 段落
|
8
|
+
|
9
|
+
段落の間は英語の段落のように一行空けます。ただし、組版に
|
10
|
+
まわすときは前処理して 1 段落を 1 行に変更してあります。
|
11
|
+
|
12
|
+
=== [例]
|
13
|
+
|
14
|
+
//emlist{
|
15
|
+
だんらくだんらく〜〜〜
|
16
|
+
この行も同じ段落
|
17
|
+
|
18
|
+
次の段落〜〜〜
|
19
|
+
//}
|
20
|
+
|
21
|
+
== 章・節・項・段
|
22
|
+
|
23
|
+
章・節・項・段のキャプションは「=」「==」「===」「====」
|
24
|
+
です。5 レベル以上は使えません。
|
25
|
+
|
26
|
+
=== [例]
|
27
|
+
|
28
|
+
//emlist{
|
29
|
+
= 章のキャプション
|
30
|
+
|
31
|
+
== 節のキャプション
|
32
|
+
|
33
|
+
=== 項のキャプション
|
34
|
+
|
35
|
+
==== 段のキャプション
|
36
|
+
//}
|
37
|
+
|
38
|
+
== コラムなど
|
39
|
+
|
40
|
+
節や項の文法に [column] を追加するとコラムのキャプションに
|
41
|
+
なります。
|
42
|
+
|
43
|
+
=== [例]
|
44
|
+
|
45
|
+
//emlist{
|
46
|
+
===[column] コンパイラコンパイラ
|
47
|
+
//}
|
48
|
+
|
49
|
+
このとき、「=」と「[column]」は必ずくっつけて書かなければ
|
50
|
+
なりません。空白があってもいけません。
|
51
|
+
|
52
|
+
== 箇条書き
|
53
|
+
|
54
|
+
箇条書き (HTML で言う ul) は「*」で表現します。
|
55
|
+
ネストはしません。
|
56
|
+
|
57
|
+
=== [例]
|
58
|
+
|
59
|
+
//emlist{
|
60
|
+
* 第一の項目
|
61
|
+
* 第二の項目
|
62
|
+
* 第三の項目
|
63
|
+
//}
|
64
|
+
|
65
|
+
== 番号付き箇条書き
|
66
|
+
|
67
|
+
番号付きの箇条書き (HTML で言う ol) は「1. 〜」「2. 〜」
|
68
|
+
「3. 〜」で示します。ネストはしません。
|
69
|
+
|
70
|
+
=== [例]
|
71
|
+
|
72
|
+
//emlist{
|
73
|
+
1. 第一の条件
|
74
|
+
2. 第二の条件
|
75
|
+
3. 第三の条件
|
76
|
+
//}
|
77
|
+
|
78
|
+
== 用語リスト
|
79
|
+
|
80
|
+
用語リスト (HTML で言う dl) は「:」を使って示します。
|
81
|
+
|
82
|
+
=== [例]
|
83
|
+
|
84
|
+
//emlist{
|
85
|
+
: Alpha
|
86
|
+
DEC の作っていた RISC CPU。
|
87
|
+
浮動小数点数演算が速い。
|
88
|
+
: POWER
|
89
|
+
IBM とモトローラが共同製作した RISC CPU。
|
90
|
+
派生として POWER PC がある。
|
91
|
+
: SPARC
|
92
|
+
Sun が作っている RISC CPU。
|
93
|
+
CPU 数を増やすのが得意。
|
94
|
+
//}
|
95
|
+
|
96
|
+
頭の「:」それ自体はテキストではないので注意してください。
|
97
|
+
|
98
|
+
また、リスト内でも後述するインライン命令は有効です。
|
99
|
+
|
100
|
+
== ソースコードなどのリスト
|
101
|
+
|
102
|
+
ソースコードリストにはキャプションの付くリストとキャプ
|
103
|
+
ションの付かないリストがあります。キャプション付きリス
|
104
|
+
トは「//list[識別子][キャプション]{ 〜 //}」で、
|
105
|
+
キャプションなしリストは「//emlist{ 〜 //}」です。
|
106
|
+
|
107
|
+
=== [例1]
|
108
|
+
|
109
|
+
//emlist{
|
110
|
+
//list[main][main()]{ ←「main」が識別子で「main()」がキャプション
|
111
|
+
int
|
112
|
+
main(int argc, char **argv)
|
113
|
+
{
|
114
|
+
puts("OK");
|
115
|
+
return 0;
|
116
|
+
}
|
117
|
+
//}
|
118
|
+
//}
|
119
|
+
|
120
|
+
=== [例2]
|
121
|
+
|
122
|
+
//emlist{
|
123
|
+
//emlist{
|
124
|
+
printf("hello");
|
125
|
+
//}
|
126
|
+
//}
|
127
|
+
|
128
|
+
ブロック内でも後述するインライン命令は有効です。
|
129
|
+
|
130
|
+
また本文中で「リスト X を見てください」のようにリストを指定
|
131
|
+
する場合は、//list で指定した識別子を使って「@<raw>{@<list>{main\}}」
|
132
|
+
と表記します。
|
133
|
+
|
134
|
+
== ソースコードの引用
|
135
|
+
|
136
|
+
ソースコードを引用する場合、ファイル名が必要です。
|
137
|
+
|
138
|
+
=== [例]
|
139
|
+
|
140
|
+
//emlist{
|
141
|
+
//source[/hello/world.rb]{
|
142
|
+
puts "hello world!"
|
143
|
+
//}
|
144
|
+
//}
|
145
|
+
|
146
|
+
== 行番号付きキャプションありリスト
|
147
|
+
|
148
|
+
キャプションありのリスト(list)で自動的に行番号がつきます。
|
149
|
+
|
150
|
+
=== [例]
|
151
|
+
|
152
|
+
//emlist{
|
153
|
+
//listnum[hello][ハローワールド]{
|
154
|
+
puts "hello world!"
|
155
|
+
//}
|
156
|
+
//}
|
157
|
+
|
158
|
+
参照方法はlistと変わりません。
|
159
|
+
|
160
|
+
=== [例]
|
161
|
+
|
162
|
+
//emlist{
|
163
|
+
..は@<raw>{@<list>{hello\}}をみてください。
|
164
|
+
//}
|
165
|
+
|
166
|
+
== 行番号付きキャプションなしリスト
|
167
|
+
|
168
|
+
キャプション無しのリスト(emlist)で自動的に行番号がつきます。
|
169
|
+
|
170
|
+
=== [例]
|
171
|
+
|
172
|
+
//emlist{
|
173
|
+
//emlistnum{
|
174
|
+
puts "hello world!"
|
175
|
+
//}
|
176
|
+
//}
|
177
|
+
|
178
|
+
== 本文中でのソースコード引用
|
179
|
+
|
180
|
+
本文中でソースコードを引用して記述します。
|
181
|
+
|
182
|
+
=== [例]
|
183
|
+
|
184
|
+
//emlist{
|
185
|
+
@<raw>{@<code>{p = obj.ref_cnt\}}
|
186
|
+
//}
|
187
|
+
|
188
|
+
== コマンドラインのキャプチャ
|
189
|
+
|
190
|
+
コマンドラインの操作を示すときは //cmd{ 〜 //} を使います。
|
191
|
+
|
192
|
+
=== [例]
|
193
|
+
|
194
|
+
//emlist{
|
195
|
+
//cmd{
|
196
|
+
$ ls /
|
197
|
+
//}
|
198
|
+
//}
|
199
|
+
|
200
|
+
ブロック内でも後述するインライン命令は有効です。
|
201
|
+
|
202
|
+
== 図
|
203
|
+
|
204
|
+
図は //image{ 〜 //} で指定します。執筆中はアスキーアートで
|
205
|
+
代替しているため、ダミーのアスキーアートが入っていることがあり
|
206
|
+
ます。この部分は、組版時には単に無視してください。
|
207
|
+
|
208
|
+
=== [例]
|
209
|
+
|
210
|
+
//emlist{
|
211
|
+
//image[unixhistory][UNIX系OSの簡単な系譜]{
|
212
|
+
System V 系列
|
213
|
+
+----------- SVr4 --> 各種商用UNIX(Solaris, AIX, HP-UX, ...)
|
214
|
+
V1 --> V6 --|
|
215
|
+
+--------- 4.4BSD --> FreeBSD, NetBSD, OpenBSD, ...
|
216
|
+
BSD 系列
|
217
|
+
|
218
|
+
--------------> Linux
|
219
|
+
//}
|
220
|
+
//}
|
221
|
+
|
222
|
+
また本文中で「図 X を見てください」のように図を指定する場合は、
|
223
|
+
//image で指定した識別子を用いて「@<raw>{@<img>{unixhistory\}}」と
|
224
|
+
記述します。//image と @<raw>{@<img>} でつづりが違うので注意してください。
|
225
|
+
|
226
|
+
== 表
|
227
|
+
|
228
|
+
表は //table[識別子][キャプション]{ 〜 //} です。ヘッダと内容を
|
229
|
+
分ける罫線は「------」で書き込んであります。
|
230
|
+
|
231
|
+
カラム間は任意個数のタブで区切ります。また、カラム先頭の「.」は削
|
232
|
+
除されるので、カラムの先頭文字が「.」の場合は「.」をもう一つ余計に
|
233
|
+
付けてください。例えば「.」という内容のカラムは「..」と書きます。
|
234
|
+
また、空のカラムは「.」と書けます。
|
235
|
+
|
236
|
+
=== [例]
|
237
|
+
|
238
|
+
//emlist{
|
239
|
+
|
240
|
+
//table[envvars][重要な環境変数]{
|
241
|
+
名前 意味
|
242
|
+
-------------------------------------------------------------
|
243
|
+
PATH コマンドの存在するディレクトリ
|
244
|
+
TERM 使っている端末の種類。linux・kterm・vt100など
|
245
|
+
LANG ユーザのデフォルトロケール。日本語ならja_JP.eucJPやja_JP.utf8
|
246
|
+
LOGNAME ユーザのログイン名
|
247
|
+
TEMP 一時ファイルを置くディレクトリ。/tmpなど
|
248
|
+
PAGER manなどで起動するテキスト閲覧プログラム。lessなど
|
249
|
+
EDITOR デフォルトエディタ。viやemacsなど
|
250
|
+
MANPATH manのソースを置いているディレクトリ
|
251
|
+
DISPLAY X Window Systemのデフォルトディスプレイ
|
252
|
+
//}
|
253
|
+
//}
|
254
|
+
|
255
|
+
本文中で「表 X を見てください」のように表を指定する場合は
|
256
|
+
@<raw>{@<table>{envvars\}} という表記を使います。
|
257
|
+
|
258
|
+
表内でも後述するインライン命令は有効です。
|
259
|
+
|
260
|
+
== 引用
|
261
|
+
|
262
|
+
引用は「//quote{ 〜 //}」を使って記述します。
|
263
|
+
|
264
|
+
=== [例]
|
265
|
+
|
266
|
+
//emlist{
|
267
|
+
//quote{
|
268
|
+
百聞は一見に如かず。
|
269
|
+
//}
|
270
|
+
//}
|
271
|
+
|
272
|
+
引用内でも後述するインライン命令は有効です。
|
273
|
+
また、いまのところ引用内で別のブロック構文を使うことはできません。
|
274
|
+
|
275
|
+
== 脚注
|
276
|
+
|
277
|
+
脚注は「//footnote」を使って記述します。
|
278
|
+
|
279
|
+
=== [例]
|
280
|
+
|
281
|
+
//emlist{
|
282
|
+
パッケージは本書のサポートサイトから入手できます@<raw>{@<fn>{site\}}。
|
283
|
+
各自ダウンロードしてインストールしておいてください。
|
284
|
+
//footnote[site][本書のサポートサイト: http://i.loveruby.net/ja/stdcompiler ]
|
285
|
+
//}
|
286
|
+
|
287
|
+
本文中の「@<raw>{@<fn>{site\}}」は脚注番号に置換され、「本書のサポート
|
288
|
+
サイト……」という文は実際の脚注に変換されます。
|
289
|
+
|
290
|
+
== 参考文献の定義
|
291
|
+
|
292
|
+
参考文献は同一ディレクトリ内の bib.re に定義します。
|
293
|
+
//bibpaper[site][キャプション]{..コメント..}
|
294
|
+
コメントが無い場合も定義可能です。
|
295
|
+
//bibpaper[site][キャプション]
|
296
|
+
|
297
|
+
=== [例]
|
298
|
+
|
299
|
+
//emlist{
|
300
|
+
//bibpaper[lins][Lins, 1991]{
|
301
|
+
Refael D. Lins. A shared memory architecture for parallel study of
|
302
|
+
algorithums for cyclic reference_counting. Technical Report 92,
|
303
|
+
Computing Laboratory, The University of Kent at Canterbury , August
|
304
|
+
1991
|
305
|
+
//}
|
306
|
+
//}
|
307
|
+
|
308
|
+
本文中で参考文献を参照したい場合は次のようにしてください。
|
309
|
+
|
310
|
+
=== [例]
|
311
|
+
|
312
|
+
//emlist{
|
313
|
+
…という研究が知られています(@<raw>{@<bib>{lins\}})
|
314
|
+
//}
|
315
|
+
|
316
|
+
== リード文
|
317
|
+
|
318
|
+
リード文は //read{ 〜 //} で指定します。lead でなく read
|
319
|
+
なのは、ASCII の EWB が「read」を使っていたからです。
|
320
|
+
|
321
|
+
=== [例]
|
322
|
+
|
323
|
+
//emlist{
|
324
|
+
//read{
|
325
|
+
本章ではまずこの本の概要について話し、
|
326
|
+
次にLinuxでプログラムを作る方法を説明していきます。
|
327
|
+
//}
|
328
|
+
//}
|
329
|
+
|
330
|
+
== 空白制御
|
331
|
+
|
332
|
+
: //noindent
|
333
|
+
段落冒頭のインデントなし
|
334
|
+
|
335
|
+
: //linebreak
|
336
|
+
改行
|
337
|
+
|
338
|
+
: //pagebreak
|
339
|
+
改ページ
|
340
|
+
|
341
|
+
== コメント
|
342
|
+
|
343
|
+
正式なタグでは伝達できない情報を記述するために //comment を使います。
|
344
|
+
|
345
|
+
=== [例]
|
346
|
+
|
347
|
+
//emlist{
|
348
|
+
//comment[ここで 1 行あける]
|
349
|
+
//}
|
350
|
+
|
351
|
+
== その他の文法
|
352
|
+
|
353
|
+
ReVIEW は任意のブロックを追加可能なので、本によって専用ブロックを
|
354
|
+
使う場合があります。これまでに使った例を以下に示します。
|
355
|
+
|
356
|
+
: //prototype
|
357
|
+
関数プロトタイプ。『ふつうのLinuxプログラミング』で使用。
|
358
|
+
|
359
|
+
: //type
|
360
|
+
関数の型宣言。『ふつうのHaskellプログラミング』で使用。
|
361
|
+
|
362
|
+
== 段落中で使う文法 (インライン命令)
|
363
|
+
|
364
|
+
: @<raw>{@<list>{program\}}
|
365
|
+
「リスト1.5」のような文字列に置換される。
|
366
|
+
|
367
|
+
: @<raw>{@<img>{unixhistory\}}
|
368
|
+
「図1.3」のような文字列に置換される。
|
369
|
+
|
370
|
+
: @<raw>{@<table>{ascii\}}
|
371
|
+
「表1.2」のような文字列に置換される。
|
372
|
+
|
373
|
+
: @<raw>{@<fn>{site\}}
|
374
|
+
脚注番号に置換される。
|
375
|
+
|
376
|
+
: @<raw>{@<kw>{信任状, credential\}}
|
377
|
+
キーワード。太字などにして強調してください。
|
378
|
+
|
379
|
+
: @<raw>{@<chap>{advanced\}}
|
380
|
+
「第17章」のような、章番号を含むテキストに置換される。
|
381
|
+
|
382
|
+
: @<raw>{@<title>{advanced\}}
|
383
|
+
その章の章題に置換される。
|
384
|
+
|
385
|
+
: @<raw>{@<chapref>{advanced\}}
|
386
|
+
『第17章「さらに進んだ話題」』のように、章番号とタイトル
|
387
|
+
を含むテキストに置換される。
|
388
|
+
|
389
|
+
: @<raw>{@<bou>{ふさわしい\}}
|
390
|
+
傍点。
|
391
|
+
|
392
|
+
: @<raw>{@<ruby>{直截, ちょくせつ\}}
|
393
|
+
ルビ。
|
394
|
+
|
395
|
+
: @<raw>{@<ami>{重点ポイント\}}
|
396
|
+
文字に対するアミかけ。
|
397
|
+
|
398
|
+
: @<raw>{@<b>{どうしても\}}
|
399
|
+
太字。
|
400
|
+
|
401
|
+
== 著者用タグ (プリプロセッサ命令)
|
402
|
+
|
403
|
+
これまでに説明したタグはすべて最終段階まで残り、見ために
|
404
|
+
影響を与えます。それに対して以下のタグは著者が使うための
|
405
|
+
専用タグであり、最終段階ではすべて消されてしまいます。
|
406
|
+
|
407
|
+
: #@#
|
408
|
+
コメント。この行には何を書いても無視される。
|
409
|
+
|
410
|
+
: #@warn(...)
|
411
|
+
警告メッセージ。プリプロセス時にメッセージが出力される。
|
412
|
+
|
413
|
+
: #@require, #@provide
|
414
|
+
キーワードの依存関係を宣言する。
|
415
|
+
|
416
|
+
: #@mapfile(ファイル名) 〜 #@end
|
417
|
+
ファイルの内容をその場に展開する。
|
418
|
+
|
419
|
+
: #@maprange(ファイル名, 範囲名) 〜 #@end
|
420
|
+
ファイル内の範囲をその場に展開する。
|
421
|
+
|
422
|
+
: #@mapoutput(コマンド) 〜 #@end
|
423
|
+
コマンドを実行して、その出力結果を展開する。
|
424
|
+
|
425
|
+
== HTMLのレイアウト機能
|
426
|
+
|
427
|
+
CHAPSファイルが置かれているディレクトリに layouts/layout.erb
|
428
|
+
を置くとその html を ERB で評価します。
|
429
|
+
|
430
|
+
=== [例1]
|
431
|
+
|
432
|
+
//emlist{
|
433
|
+
<html>
|
434
|
+
<head>
|
435
|
+
<title><%= title %></title>
|
436
|
+
</head>
|
437
|
+
//}
|
438
|
+
|
439
|
+
=== [例2]
|
440
|
+
|
441
|
+
//emlist{
|
442
|
+
<html>
|
443
|
+
<head>
|
444
|
+
<title><%= title %></title>
|
445
|
+
</head>
|
446
|
+
<body>
|
447
|
+
<%= body %>
|
448
|
+
<hr/>
|
449
|
+
</body>
|
450
|
+
</html>
|
451
|
+
//}
|
452
|
+
|
453
|
+
== 部タイトル取得(目次生成機能)
|
454
|
+
|
455
|
+
PART ファイルに定義してください。
|
456
|
+
PART ファイルは CHAPS の部わけと対応しています。
|
457
|
+
|
458
|
+
=== [例]
|
459
|
+
|
460
|
+
//emlist{
|
461
|
+
CHAPS:
|
462
|
+
intro.re
|
463
|
+
start.re
|
464
|
+
end.re
|
465
|
+
|
466
|
+
PART:
|
467
|
+
(序章なので空行)
|
468
|
+
はじまりの部
|
469
|
+
おわりの部
|
470
|
+
//}
|
471
|
+
|
472
|
+
== リンク
|
473
|
+
|
474
|
+
Web ハイパーリンクを記述するには、リンクに @<raw>{@<href>}、アンカーに //label
|
475
|
+
を使います。リンクの書式は @<raw>{@<href>{URL, 文字表現\}} で、「, 文字表現」を
|
476
|
+
省略すると URL がそのまま使われます。URL 中に , を使いたいときには、\,
|
477
|
+
と表記してください。
|
478
|
+
|
479
|
+
[例]
|
480
|
+
//emlist{
|
481
|
+
@<raw>{@<href>{http://github.com/, GitHub\}}
|
482
|
+
@<raw>{@<href>{http://www.google.com/\}}
|
483
|
+
@<raw>{@<href>{#point1, ドキュメント内ポイント\}}
|
484
|
+
@<raw>{@<href>{chap1.html#point1, ドキュメント内ポイント\}}
|
485
|
+
//label[point1]
|
486
|
+
//}
|