review-peg 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (174) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +36 -0
  3. data/.rubocop.yml +47 -0
  4. data/.rubocop_todo.yml +605 -0
  5. data/.travis.yml +18 -0
  6. data/COPYING +515 -0
  7. data/ChangeLog +2449 -0
  8. data/Dockerfile +22 -0
  9. data/Gemfile +6 -0
  10. data/README.rdoc +81 -0
  11. data/Rakefile +51 -0
  12. data/bin/review-catalog-converter-peg +129 -0
  13. data/bin/review-check-peg +169 -0
  14. data/bin/review-checkdep-peg +63 -0
  15. data/bin/review-compile-peg +202 -0
  16. data/bin/review-epubmaker-legacy-peg +1024 -0
  17. data/bin/review-epubmaker-peg +44 -0
  18. data/bin/review-index-peg +110 -0
  19. data/bin/review-init-peg +151 -0
  20. data/bin/review-pdfmaker-peg +18 -0
  21. data/bin/review-preproc-peg +131 -0
  22. data/bin/review-validate-peg +51 -0
  23. data/bin/review-vol-peg +100 -0
  24. data/debian/README.Debian +12 -0
  25. data/debian/README.source +5 -0
  26. data/debian/changelog +5 -0
  27. data/debian/compat +1 -0
  28. data/debian/control +22 -0
  29. data/debian/copyright +62 -0
  30. data/debian/docs +6 -0
  31. data/debian/manpage.1.ex +59 -0
  32. data/debian/patches/path.diff +91 -0
  33. data/debian/patches/series +1 -0
  34. data/debian/review.install +13 -0
  35. data/debian/review.links +4 -0
  36. data/debian/rules +13 -0
  37. data/debian/source/format +1 -0
  38. data/doc/NEWS.ja.md +350 -0
  39. data/doc/NEWS.md +354 -0
  40. data/doc/catalog.ja.md +53 -0
  41. data/doc/catalog.md +52 -0
  42. data/doc/format.ja.md +734 -0
  43. data/doc/format.md +746 -0
  44. data/doc/format_idg.ja.md +203 -0
  45. data/doc/quickstart.ja.md +222 -0
  46. data/doc/quickstart.md +252 -0
  47. data/doc/ruby-uuid/README +11 -0
  48. data/doc/ruby-uuid/README.ja +34 -0
  49. data/doc/sample.css +108 -0
  50. data/doc/sample.yml +238 -0
  51. data/lib/epubmaker.rb +24 -0
  52. data/lib/epubmaker/content.rb +93 -0
  53. data/lib/epubmaker/epubcommon.rb +424 -0
  54. data/lib/epubmaker/epubv2.rb +139 -0
  55. data/lib/epubmaker/epubv3.rb +222 -0
  56. data/lib/epubmaker/producer.rb +330 -0
  57. data/lib/lineinput.rb +107 -0
  58. data/lib/review.rb +3 -0
  59. data/lib/review/book.rb +43 -0
  60. data/lib/review/book/base.rb +401 -0
  61. data/lib/review/book/chapter.rb +100 -0
  62. data/lib/review/book/compilable.rb +184 -0
  63. data/lib/review/book/image_finder.rb +71 -0
  64. data/lib/review/book/index.rb +413 -0
  65. data/lib/review/book/page_metric.rb +47 -0
  66. data/lib/review/book/part.rb +54 -0
  67. data/lib/review/book/volume.rb +67 -0
  68. data/lib/review/builder.rb +452 -0
  69. data/lib/review/catalog.rb +52 -0
  70. data/lib/review/compiler.rb +5183 -0
  71. data/lib/review/compiler/literals_1_9.kpeg +22 -0
  72. data/lib/review/compiler/literals_1_9.rb +435 -0
  73. data/lib/review/configure.rb +64 -0
  74. data/lib/review/epubbuilder.rb +18 -0
  75. data/lib/review/epubmaker.rb +480 -0
  76. data/lib/review/ewbbuilder.rb +381 -0
  77. data/lib/review/exception.rb +21 -0
  78. data/lib/review/extentions.rb +4 -0
  79. data/lib/review/extentions/array.rb +25 -0
  80. data/lib/review/extentions/object.rb +9 -0
  81. data/lib/review/extentions/string.rb +33 -0
  82. data/lib/review/htmlbuilder.rb +1166 -0
  83. data/lib/review/htmllayout.rb +41 -0
  84. data/lib/review/htmltoc.rb +45 -0
  85. data/lib/review/htmlutils.rb +90 -0
  86. data/lib/review/i18n.rb +96 -0
  87. data/lib/review/i18n.yml +169 -0
  88. data/lib/review/idgxmlbuilder.rb +1233 -0
  89. data/lib/review/inaobuilder.rb +357 -0
  90. data/lib/review/latexbuilder.rb +941 -0
  91. data/lib/review/latexindex.rb +35 -0
  92. data/lib/review/latexutils.rb +95 -0
  93. data/lib/review/layout.tex.erb +340 -0
  94. data/lib/review/lineinput.rb +17 -0
  95. data/lib/review/location.rb +24 -0
  96. data/lib/review/makerhelper.rb +67 -0
  97. data/lib/review/markdownbuilder.rb +339 -0
  98. data/lib/review/node.rb +288 -0
  99. data/lib/review/pdfmaker.rb +332 -0
  100. data/lib/review/preprocessor.rb +530 -0
  101. data/lib/review/review.kpeg +745 -0
  102. data/lib/review/sec_counter.rb +69 -0
  103. data/lib/review/template.rb +21 -0
  104. data/lib/review/textbuilder.rb +17 -0
  105. data/lib/review/textutils.rb +16 -0
  106. data/lib/review/tocparser.rb +348 -0
  107. data/lib/review/tocprinter.rb +205 -0
  108. data/lib/review/topbuilder.rb +796 -0
  109. data/lib/review/unfold.rb +138 -0
  110. data/lib/review/version.rb +3 -0
  111. data/lib/uuid.rb +312 -0
  112. data/review.gemspec +32 -0
  113. data/templates/html/layout-html5.html.erb +17 -0
  114. data/templates/html/layout-xhtml1.html.erb +20 -0
  115. data/templates/ncx/epubv2.ncx.erb +11 -0
  116. data/templates/opf/epubv2.opf.erb +21 -0
  117. data/templates/opf/epubv3.opf.erb +18 -0
  118. data/templates/xml/container.xml.erb +6 -0
  119. data/test/CHAPS +2 -0
  120. data/test/assets/test.xml.erb +3 -0
  121. data/test/assets/test_template.tex +255 -0
  122. data/test/assets/test_template_backmatter.tex +32 -0
  123. data/test/bib.re +13 -0
  124. data/test/book_test_helper.rb +35 -0
  125. data/test/sample-book/README.md +7 -0
  126. data/test/sample-book/src/Rakefile +58 -0
  127. data/test/sample-book/src/_cover.html +3 -0
  128. data/test/sample-book/src/catalog.yml +10 -0
  129. data/test/sample-book/src/ch01.re +71 -0
  130. data/test/sample-book/src/ch02.re +3 -0
  131. data/test/sample-book/src/config.yml +186 -0
  132. data/test/sample-book/src/images/ch01-imgsample.jpg +0 -0
  133. data/test/sample-book/src/images/cover.jpg +0 -0
  134. data/test/sample-book/src/preface.re +15 -0
  135. data/test/sample-book/src/sty/jumoline.sty +310 -0
  136. data/test/sample-book/src/sty/reviewmacro.sty +39 -0
  137. data/test/sample-book/src/style.css +251 -0
  138. data/test/sample-book/src/vendor/jumoline/README +29 -0
  139. data/test/sample-book/src/vendor/jumoline/jumoline.dtx +2988 -0
  140. data/test/sample-book/src/vendor/jumoline/jumoline.ins +6 -0
  141. data/test/test.re +43 -0
  142. data/test/test_book.rb +556 -0
  143. data/test/test_book_chapter.rb +280 -0
  144. data/test/test_book_part.rb +54 -0
  145. data/test/test_builder.rb +80 -0
  146. data/test/test_catalog.rb +119 -0
  147. data/test/test_catalog_converter_cmd.rb +73 -0
  148. data/test/test_compiler.rb +92 -0
  149. data/test/test_configure.rb +50 -0
  150. data/test/test_epub3maker.rb +529 -0
  151. data/test/test_epubmaker.rb +569 -0
  152. data/test/test_epubmaker_cmd.rb +40 -0
  153. data/test/test_helper.rb +92 -0
  154. data/test/test_htmlbuilder.rb +1114 -0
  155. data/test/test_htmltoc.rb +32 -0
  156. data/test/test_htmlutils.rb +50 -0
  157. data/test/test_i18n.rb +180 -0
  158. data/test/test_idgxmlbuilder.rb +608 -0
  159. data/test/test_image_finder.rb +82 -0
  160. data/test/test_inaobuilder.rb +245 -0
  161. data/test/test_index.rb +174 -0
  162. data/test/test_latexbuilder.rb +732 -0
  163. data/test/test_lineinput.rb +182 -0
  164. data/test/test_makerhelper.rb +66 -0
  165. data/test/test_markdownbuilder.rb +125 -0
  166. data/test/test_pdfmaker.rb +171 -0
  167. data/test/test_pdfmaker_cmd.rb +40 -0
  168. data/test/test_preprocessor.rb +23 -0
  169. data/test/test_review_ext.rb +31 -0
  170. data/test/test_template.rb +26 -0
  171. data/test/test_textutils.rb +32 -0
  172. data/test/test_topbuilder.rb +291 -0
  173. data/test/test_uuid.rb +157 -0
  174. metadata +357 -0
data/Dockerfile ADDED
@@ -0,0 +1,22 @@
1
+ # This file is a sample Dockerfile to build Re:VIEW documents.
2
+ #
3
+ # Build:
4
+ # $ docker build -t review .
5
+ #
6
+ # Usage:
7
+ # $ cd path/to/review/project
8
+ # $ docker run -it --rm -v `pwd`:/work review rake pdf
9
+ #
10
+ # cf. https://github.com/vvakame/docker-review/blob/master/Dockerfile
11
+
12
+ FROM debian:sid
13
+ MAINTAINER takahashim
14
+
15
+ RUN apt-get update \
16
+ && apt-get install -y --no-install-recommends git-core ruby locales zip \
17
+ && apt-get install -y --no-install-recommends texlive-lang-cjk texlive-lang-japanese texlive-fonts-recommended texlive-latex-extra ghostscript \
18
+ && rm -rf /var/lib/apt/lists/*
19
+ RUN gem install review rake bundler --no-rdoc --no-ri
20
+
21
+ VOLUME ["/work"]
22
+ WORKDIR /work
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in review.gemspec
4
+ gemspec
5
+
6
+ gem "json"
data/README.rdoc ADDED
@@ -0,0 +1,81 @@
1
+ = Re:VIEW
2
+
3
+ {<img src="https://secure.travis-ci.org/kmuto/review.png"/>}[http://travis-ci.org/kmuto/review]
4
+ {<img src="https://badge.fury.io/rb/review.png" alt="Gem Version" />}[http://badge.fury.io/rb/review]
5
+
6
+ home :: https://github.com/kmuto/review
7
+ gems :: https://rubygems.org/gems/review
8
+ wiki :: https://github.com/kmuto/review/wiki
9
+ bugs :: https://github.com/kmuto/review/issues
10
+
11
+ Re:VIEW is an easy-to-use digital publishing system for books and ebooks.
12
+
13
+ == Format
14
+
15
+ Re:VIEW uses its original format('Re:VIEW format') as source files. See doc/format.rdoc (in Japanese).
16
+
17
+ Output formats Re:VIEW supports are:
18
+
19
+ * EPUB
20
+ * LaTeX(ptexlive)
21
+ * InDesign(IDGXML)
22
+ * plain text(TOPBuilder Text Markup Language)
23
+ * Inao(gihyo.jp original markup)
24
+
25
+ == Commands
26
+
27
+ There are two commands generate files directly.
28
+
29
+ * review-epubmaker: generate EPUB file.
30
+ * review-pdfmaker: generate PDF file using LaTeX(ptexlive).
31
+
32
+ And some useful commands.
33
+
34
+ * review-compile: compile Re:VIEW fomat files.
35
+ * review-vol: figure out size of Re:VIEW files.
36
+ * review-index: generate index with various format.
37
+ * review-preproc: preprocessor.
38
+
39
+ == Installation
40
+
41
+ Install gem yourself as:
42
+
43
+ $ gem install review
44
+
45
+ Or build from source:
46
+
47
+ $ git clone https://github.com/kmuto/review.git
48
+ $ cd review
49
+ $ rake install
50
+
51
+ Or add the `./bin` directory to your $PATH:
52
+
53
+ $ echo "export PATH=PATH_OF_REVIEW/bin:$PATH" >> ~/.profile
54
+
55
+ == Resources
56
+ === Documents
57
+
58
+ * Wiki pages: https://github.com/kmuto/review/wiki
59
+ * doc/* files (in Japanese)
60
+
61
+ === Issues tracker
62
+
63
+ * GitHub: https://github.com/kmuto/review
64
+
65
+ == Note on Patches/Pull Requests
66
+
67
+ * Fork the project.
68
+ * Make your feature addition or bug fix.
69
+ * Add tests for it. This is important so I don't break it in a
70
+ future version unintentionally.
71
+ * Commit, do not mess with rakefile, version, or history.
72
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
73
+ * Send me a pull request. Bonus points for topic branches.
74
+
75
+ == License
76
+
77
+ LGPL. See COPYING file.
78
+
79
+ == Copyright
80
+
81
+ Copyright (c) 2006-2015 Minero Aoki, Kenshi Muto, Masayoshi Takahashi, Masanori Kado.
data/Rakefile ADDED
@@ -0,0 +1,51 @@
1
+ require 'fileutils'
2
+
3
+ begin
4
+ require 'bundler'
5
+ Bundler::GemHelper.install_tasks
6
+ rescue LoadError
7
+ # ignore if bundler does not exist
8
+ end
9
+
10
+ require 'rubygems'
11
+ require 'rake/testtask'
12
+ require 'rake/clean'
13
+
14
+ task :default => [:test]
15
+
16
+ task :kpeg do
17
+ FileUtils.rm_f "lib/review/compiler.rb"
18
+ FileUtils.rm_f "lib/review/compiler/literals_1_9.rb"
19
+ sh "kpeg -s lib/review/compiler/literals_1_9.kpeg -o lib/review/compiler/literals_1_9.rb"
20
+ sh "kpeg -s lib/review/review.kpeg -o lib/review/compiler.rb"
21
+ end
22
+
23
+ Rake::TestTask.new("test") do |t|
24
+ t.libs << "test"
25
+ t.test_files = Dir.glob("test/**/test_*.rb")
26
+ t.verbose = true
27
+ end
28
+
29
+ begin
30
+ require 'rcov/rcovtask'
31
+ Rcov::RcovTask.new do |t|
32
+ t.rcov_opts << '-x /gems/'
33
+ t.rcov_opts << '-x /tmp/'
34
+ t.libs << 'test'
35
+ t.pattern = 'test/test_*.rb'
36
+ t.verbose = true
37
+ end
38
+ rescue LoadError
39
+ end
40
+
41
+ begin
42
+ require 'rdoc/task'
43
+ Rake::RDocTask.new do |rdoc|
44
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "review #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
50
+ rescue LoadError
51
+ end
@@ -0,0 +1,129 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+ #
4
+ # Copyright (c) 2014 Masanori Kado
5
+ #
6
+ # This program is free software.
7
+ # You can distribute or modify this program under the terms of
8
+ # the GNU LGPL, Lesser General Public License version 2.1.
9
+ # For details of the GNU LGPL, see the file "COPYING".
10
+ #
11
+ # Convert old PREDEF/CHAPS/PART/POSTDEF files into catalog.yml.
12
+
13
+ require 'pathname'
14
+ require 'optparse'
15
+ bindir = Pathname.new(__FILE__).realpath.dirname
16
+ $LOAD_PATH.unshift((bindir + '../lib').realpath)
17
+ require 'review/version'
18
+ require 'review/extentions'
19
+
20
+ def main
21
+ opts = OptionParser.new
22
+ opts.version = ReVIEW::VERSION
23
+ opts.banner = "Usage: #{File.basename($0)} dirname"
24
+ opts.on('-h', '--help', 'print this message and quit.') do
25
+ puts opts.help
26
+ exit 0
27
+ end
28
+
29
+ begin
30
+ opts.parse!
31
+ rescue OptionParser::ParseError => err
32
+ $stderr.puts err.message
33
+ $stderr.puts opts.help
34
+ exit 1
35
+ end
36
+
37
+ dir = Dir.pwd
38
+
39
+ # confirmation
40
+ if File.exist?("#{dir}/catalog.yml")
41
+ while true
42
+ print "The catalog.yml already exists. Do you want to overwrite it? [y/n]"
43
+ case gets
44
+ when /^[yY]/
45
+ puts "Start writing..."
46
+ break
47
+ when /^[nN]/, /^$/
48
+ puts "bye."
49
+ exit
50
+ end
51
+ end
52
+ end
53
+
54
+ File.open("#{dir}/catalog.yml", "w") do |catalog|
55
+ # predef
56
+ if File.exist?("#{dir}/PREDEF")
57
+ catalog << parse_predef(File.open("#{dir}/PREDEF").read)
58
+ end
59
+ # chaps and parts
60
+ if File.exist?("#{dir}/CHAPS")
61
+ if File.exist?("#{dir}/PART")
62
+ catalog << parse_parts(File.open("#{dir}/PART").read,
63
+ File.open("#{dir}/CHAPS").read)
64
+ else
65
+ catalog << parse_chaps(File.open("#{dir}/CHAPS").read)
66
+ end
67
+ end
68
+ # postdef
69
+ if File.exist?("#{dir}/POSTDEF")
70
+ postdef = File.open("#{dir}/POSTDEF").read
71
+ while true
72
+ print "Do you want to convert POSTDEF into APPENDIX? [y/n]"
73
+ case gets
74
+ when /^[yY]/
75
+ catalog << parse_postdef(postdef, true)
76
+ break
77
+ when /^[nN]/, /^$/
78
+ catalog << parse_postdef(postdef)
79
+ break
80
+ end
81
+ end
82
+ end
83
+ end
84
+
85
+ puts File.open("#{dir}/catalog.yml").read
86
+ end
87
+
88
+ def _parse(str, header)
89
+ if str.present?
90
+ header + str.split("\n").map{|i| " - #{i}\n" }.join
91
+ else
92
+ header
93
+ end
94
+ end
95
+
96
+ def parse_predef(str)
97
+ header = "PREDEF:\n"
98
+ _parse(str, header) + "\n"
99
+ end
100
+
101
+ def parse_chaps(str)
102
+ header = "CHAPS:\n"
103
+ _parse(str, header) + "\n"
104
+ end
105
+
106
+ def parse_postdef(str, to_appendix = false)
107
+ if to_appendix
108
+ header = "APPENDIX:\n"
109
+ else
110
+ header = "POSTDEF:\n"
111
+ end
112
+ _parse(str, header) + "\n"
113
+ end
114
+
115
+ def parse_parts(parts_str, chaps_str)
116
+ if parts_str.blank? or chaps_str.blank?
117
+ return "CHAPS:\n\n"
118
+ end
119
+
120
+ parts = parts_str.split("\n")
121
+ chaps = chaps_str.split("\n\n")
122
+ "CHAPS:\n" + parts.zip(chaps).map{|k, vs|
123
+ " - #{k}:\n" + vs.split("\n").map{|i| " - #{i}\n"}.join
124
+ }.join + "\n"
125
+ end
126
+
127
+ if File.basename($0) == File.basename(__FILE__)
128
+ main()
129
+ end
@@ -0,0 +1,169 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ #
4
+ # Copyright (c) 1999-2007 Minero Aoki
5
+ # Copyright (c) 2010-2014 Kenshi Muto, 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'
19
+ require 'optparse'
20
+
21
+ include ReVIEW::TextUtils
22
+
23
+ def sigmain
24
+ Signal.trap(:INT) { exit 1 }
25
+ if RUBY_PLATFORM !~ /mswin(?!ce)|mingw|cygwin|bccwin/
26
+ Signal.trap(:PIPE, 'IGNORE')
27
+ end
28
+ main
29
+ rescue Errno::EPIPE
30
+ exit 0
31
+ end
32
+
33
+ def main
34
+ @config = ReVIEW::Configure.values
35
+ @book = ReVIEW::Book::Base.load
36
+ @book.config = @config
37
+
38
+ modes = nil
39
+ files = ARGV unless ARGV.empty?
40
+ opts = OptionParser.new
41
+ opts.version = ReVIEW::VERSION
42
+ opts.on('-a', '--all-chapters', 'Check all chapters.') {
43
+ files = @book.chapters.map {|ent| ent.path }
44
+ }
45
+ opts.on('-s', '--section N', 'Check section N. (deprecated)') {|n|
46
+ ents = @book.parts[Integer(n) - 1] or
47
+ raise ReVIEW::ApplicationError, "section #{n} not exist"
48
+ files = ents.map {|ent| ent.path }
49
+ }
50
+ opts.on('--text', 'Check text.') {
51
+ (modes ||= []).push :text
52
+ }
53
+ opts.on('--help', 'print this message and quit.') {
54
+ puts opts.help
55
+ exit 0
56
+ }
57
+ begin
58
+ opts.parse!
59
+ rescue OptionParser::ParseError => err
60
+ $stderr.puts err.message
61
+ $stderr.puts opts.help
62
+ exit 1
63
+ end
64
+ unless files
65
+ $stderr.puts "no input"
66
+ exit 1
67
+ end
68
+ modes ||= [:text]
69
+
70
+ modes.each do |mode|
71
+ case mode
72
+ when :text
73
+ check_text files
74
+ else
75
+ raise 'must not happen'
76
+ end
77
+ end
78
+ end
79
+
80
+ def check_text(files)
81
+ re, neg = words_re("#{@book.basedir}/#{@book.reject_file}")
82
+ files.each do |path|
83
+ File.open(path) {|f|
84
+ each_paragraph(f) do |para, lineno|
85
+ s = para.join('')
86
+ if m = re.match(s)
87
+ next if m[0] == @review_utils_word_ok
88
+ next if neg and neg =~ s
89
+ str, offset = find_line(para, re)
90
+ out = sprintf("%s:%d: %s\n", path, lineno + offset, str)
91
+ print out
92
+ end
93
+ end
94
+ }
95
+ end
96
+ end
97
+
98
+ def find_line(lines, re)
99
+ # single line?
100
+ lines.each_with_index do |line, idx|
101
+ return line.gsub(re, '<<<\&>>>'), idx if re =~ line
102
+ end
103
+
104
+ # multiple lines?
105
+ i = 0
106
+ while i < lines.size - 1
107
+ str = lines[i] + lines[i+1]
108
+ return str.gsub(re, '<<<\&>>>'), i if re =~ str
109
+ i += 1
110
+ end
111
+
112
+ raise 'must not happen'
113
+ end
114
+
115
+ def words_re(rc)
116
+ words = []
117
+ nega = []
118
+ File.foreach(rc) do |line|
119
+ next if line[0,1] == '#'
120
+ if / !/ =~ line
121
+ line, n = *line.split(/!/, 2)
122
+ nega.push n.strip
123
+ end
124
+ words.push line.strip
125
+ end
126
+ return Regexp.compile(words.join('|')),
127
+ nega.empty?() ? nil : Regexp.compile(nega.join('|'))
128
+ end
129
+
130
+ def each_paragraph(f)
131
+ @review_utils_word_ok = nil
132
+ while line = f.gets
133
+ case line
134
+ when /\A\#@ok\((.*)\)/
135
+ @review_utils_word_ok = $1
136
+ when /\A\#@/
137
+ ;
138
+ when %r[\A//caption\{(.*?)//\}]
139
+ yield [$1], f.filename, f.lineno
140
+ when %r<\A//\w.*\{\s*\z>
141
+ while line = f.gets
142
+ break if %r<//\}> === line
143
+ end
144
+ when /\A=/
145
+ yield [line.slice(/\A=+(?:\[.*?\])?\s+(.*)/, 1).strip], f.lineno
146
+ when /\A\s*\z/
147
+ # skip
148
+ else
149
+ buf = [line.strip]
150
+ lineno = f.lineno
151
+ while line = f.gets
152
+ break if line.strip.empty?
153
+ break if %r<\A(?:=|//[\w\}])> =~ line
154
+ next if %r<\A\#@> =~ line
155
+ buf.push line.strip
156
+ end
157
+ yield buf, lineno
158
+ @review_utils_word_ok = nil
159
+ end
160
+ end
161
+ end
162
+
163
+ def each_paragraph_line(f, &block)
164
+ each_paragraph(f) do |para, *|
165
+ para.each(&block)
166
+ end
167
+ end
168
+
169
+ sigmain