review 1.7.2 → 2.0.0.beta1

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.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -43
  3. data/.travis.yml +0 -9
  4. data/ChangeLog +0 -16
  5. data/Gemfile +1 -0
  6. data/README.rdoc +1 -1
  7. data/Rakefile +12 -1
  8. data/bin/review-check +21 -8
  9. data/bin/review-compile +15 -9
  10. data/bin/review-epubmaker-legacy +6 -6
  11. data/bin/review-index +13 -2
  12. data/bin/review-init +18 -12
  13. data/bin/review-preproc +14 -1
  14. data/bin/review-validate +1 -1
  15. data/bin/review-vol +13 -1
  16. data/doc/quickstart.ja.md +1 -1
  17. data/doc/quickstart.md +1 -1
  18. data/lib/epubmaker/content.rb +3 -3
  19. data/lib/epubmaker/epubcommon.rb +108 -91
  20. data/lib/epubmaker/epubv2.rb +67 -14
  21. data/lib/epubmaker/epubv3.rb +59 -25
  22. data/lib/epubmaker/producer.rb +1 -13
  23. data/lib/lineinput.rb +0 -48
  24. data/lib/review/book/base.rb +4 -12
  25. data/lib/review/book/compilable.rb +3 -1
  26. data/lib/review/book/index.rb +4 -4
  27. data/lib/review/builder.rb +54 -47
  28. data/lib/review/compiler.rb +4662 -326
  29. data/lib/review/compiler/literals_1_8.kpeg +19 -0
  30. data/lib/review/compiler/literals_1_8.rb +432 -0
  31. data/lib/review/compiler/literals_1_9.kpeg +22 -0
  32. data/lib/review/compiler/literals_1_9.rb +435 -0
  33. data/lib/review/configure.rb +8 -20
  34. data/lib/review/epubbuilder.rb +1 -1
  35. data/lib/review/epubmaker.rb +122 -52
  36. data/lib/review/ewbbuilder.rb +4 -4
  37. data/lib/review/exception.rb +1 -1
  38. data/lib/review/extentions.rb +1 -0
  39. data/lib/review/extentions/array.rb +25 -0
  40. data/lib/review/htmlbuilder.rb +286 -275
  41. data/lib/review/htmllayout.rb +0 -2
  42. data/lib/review/htmlutils.rb +4 -4
  43. data/lib/review/i18n.rb +2 -6
  44. data/lib/review/i18n.yml +1 -1
  45. data/lib/review/idgxmlbuilder.rb +239 -204
  46. data/lib/review/inaobuilder.rb +75 -73
  47. data/lib/review/latexbuilder.rb +265 -219
  48. data/lib/review/latexutils.rb +6 -6
  49. data/lib/review/layout.tex.erb +1 -1
  50. data/lib/review/location.rb +24 -0
  51. data/lib/review/markdownbuilder.rb +124 -79
  52. data/lib/review/node.rb +267 -0
  53. data/lib/review/pdfmaker.rb +92 -92
  54. data/lib/review/preprocessor.rb +51 -14
  55. data/lib/review/review.kpeg +724 -0
  56. data/lib/review/textbuilder.rb +1 -1
  57. data/lib/review/textutils.rb +24 -18
  58. data/lib/review/tocparser.rb +3 -3
  59. data/lib/review/tocprinter.rb +31 -8
  60. data/lib/review/topbuilder.rb +119 -111
  61. data/lib/review/unfold.rb +2 -2
  62. data/lib/review/version.rb +1 -1
  63. data/review.gemspec +2 -2
  64. data/rubocop-todo.yml +456 -0
  65. data/test/assets/test_template.tex +1 -1
  66. data/test/sample-book/src/config.yml +0 -1
  67. data/test/test.re +1 -1
  68. data/test/test_book.rb +4 -4
  69. data/test/test_book_chapter.rb +70 -0
  70. data/test/test_book_part.rb +1 -1
  71. data/test/test_builder.rb +6 -28
  72. data/test/test_compiler.rb +59 -14
  73. data/test/test_helper.rb +47 -4
  74. data/test/test_htmlbuilder.rb +104 -73
  75. data/test/test_i18n.rb +5 -3
  76. data/test/test_idgxmlbuilder.rb +5 -2
  77. data/test/test_inaobuilder.rb +4 -2
  78. data/test/test_latexbuilder.rb +18 -37
  79. data/test/test_lineinput.rb +25 -4
  80. data/test/test_markdownbuilder.rb +4 -22
  81. data/test/test_pdfmaker.rb +12 -11
  82. data/test/test_textutils.rb +0 -36
  83. data/test/test_topbuilder.rb +2 -0
  84. metadata +14 -28
  85. data/.rubocop_todo.yml +0 -605
  86. data/Dockerfile +0 -22
  87. data/doc/NEWS.ja.md +0 -362
  88. data/doc/NEWS.md +0 -366
  89. data/lib/review/htmltoc.rb +0 -45
  90. data/lib/review/template.rb +0 -21
  91. data/templates/html/layout-html5.html.erb +0 -17
  92. data/templates/html/layout-xhtml1.html.erb +0 -20
  93. data/templates/ncx/epubv2.ncx.erb +0 -11
  94. data/templates/opf/epubv2.opf.erb +0 -21
  95. data/templates/opf/epubv3.opf.erb +0 -18
  96. data/templates/xml/container.xml.erb +0 -6
  97. data/test/assets/test.xml.erb +0 -3
  98. data/test/sample-book/src/config-epub2.yml +0 -186
  99. data/test/test_configure.rb +0 -50
  100. data/test/test_htmltoc.rb +0 -32
  101. data/test/test_template.rb +0 -26
@@ -17,18 +17,18 @@ module ReVIEW
17
17
  module LaTeXUtils
18
18
 
19
19
  METACHARS = {
20
- '#' => '\#',
21
- "$" => '\textdollar{}',
20
+ '#' => '\#',
21
+ "$" => '\textdollar{}',
22
22
  '%' => '\%',
23
23
  '&' => '\&',
24
24
  '{' => '\{',
25
25
  '}' => '\}',
26
- '_' => '\textunderscore{}',
26
+ '_' => '\textunderscore{}',
27
27
  '^' => '\textasciicircum{}',
28
28
  '~' => '\textasciitilde{}',
29
29
  '|' => '\textbar{}',
30
- '<' => '\textless{}',
31
- '>' => '\textgreater{}',
30
+ '<' => '\textless{}',
31
+ '>' => '\textgreater{}',
32
32
  "\\" => '\reviewbackslash{}',
33
33
  "-" => '{-}',
34
34
 
@@ -70,7 +70,7 @@ module ReVIEW
70
70
  alias_method :escape, :escape_latex
71
71
 
72
72
  def unescape_latex(str)
73
- metachars_invert_re = Regexp.new(METACHARS_INVERT.keys.collect{|key| Regexp.escape(key)}.join('|'))
73
+ metachars_invert_re = Regexp.new(METACHARS_INVERT.keys.collect{|key| Regexp.escape(key)}.join('|'))
74
74
  str.gsub(metachars_invert_re) {|s|
75
75
  METACHARS_INVERT[s] or raise "unknown trans char: #{s}"
76
76
  }
@@ -250,7 +250,7 @@
250
250
  <%= authors %>
251
251
  \end{tabular}\par}%
252
252
  \vfill
253
- {\large <%= values["date"] %> <%= I18n.t("edition")%>\hspace{2zw}<%= I18n.t("published_by", values["prt"])%>\par}%
253
+ {\large <%= values["date"] %> <%= I18n.t("version")%>\hspace{2zw}<%= I18n.t("published_by", values["prt"])%>\par}%
254
254
  \vskip4zw\mbox{}
255
255
  \end{center}%
256
256
  \end{titlepage}
@@ -0,0 +1,24 @@
1
+ module ReVIEW
2
+ class Location
3
+ def initialize(filename, compiler)
4
+ @filename = filename
5
+ @f = compiler
6
+ end
7
+
8
+ attr_reader :filename
9
+
10
+ def lineno
11
+ @f.current_line
12
+ end
13
+
14
+ def string
15
+ begin
16
+ "#{@filename}:#{self.lineno}"
17
+ rescue
18
+ "#{@filename}:nil"
19
+ end
20
+ end
21
+
22
+ alias to_s string
23
+ end
24
+ end
@@ -21,117 +21,136 @@ module ReVIEW
21
21
  end
22
22
  private :builder_init_file
23
23
 
24
- def puts(str)
24
+ def blank_reset
25
25
  @blank_seen = false
26
- super
27
26
  end
28
27
 
28
+ # def puts(str)
29
+ # @blank_seen = false
30
+ # "#{str}\n"
31
+ # end
32
+
29
33
  def blank
30
- @output.puts unless @blank_seen
34
+ buf = ""
35
+ unless @blank_seen
36
+ buf = "\n"
37
+ end
31
38
  @blank_seen = true
39
+ buf
32
40
  end
33
41
 
34
42
  def headline(level, label, caption)
35
- blank
43
+ buf = ""
44
+ buf << blank
36
45
  prefix = "#" * level
37
- puts "#{prefix} #{caption}"
38
- blank
46
+ buf << "#{prefix} #{caption}\n"
47
+ blank_reset
48
+ buf << "\n"
49
+ buf
39
50
  end
40
51
 
41
52
  def quote(lines)
42
- blank
43
- puts split_paragraph(lines).map{|line| "> #{line}"}.join("\n> \n")
44
- blank
53
+ buf = ""
54
+ buf << blank
55
+ buf << lines.map{|line| line.chomp!;line.chomp!;"> #{line}"}.join("\n") << "\n"
56
+ blank_reset
57
+ buf << "\n"
58
+ buf
45
59
  end
46
60
 
47
61
  def paragraph(lines)
48
- puts lines.join
49
- puts "\n"
62
+ buf = lines.join << "\n"
63
+ blank_reset
64
+ buf << "\n"
65
+ buf
50
66
  end
51
67
 
52
68
  def list_header(id, caption, lang)
69
+ lang ||= ""
53
70
  if get_chap.nil?
54
- print %Q[リスト#{@chapter.list(id).number} #{compile_inline(caption)}\n\n]
71
+ %Q[リスト#{@chapter.list(id).number} #{compile_inline(caption)}\n] + "```#{lang}\n"
55
72
  else
56
- print %Q[リスト#{get_chap}.#{@chapter.list(id).number} #{compile_inline(caption)}\n\n]
73
+ %Q[リスト#{get_chap}.#{@chapter.list(id).number} #{compile_inline(caption)}\n] + "```#{lang}\n"
57
74
  end
58
- lang ||= ""
59
- puts "```#{lang}"
60
75
  end
61
76
 
62
77
  def list_body(id, lines, lang)
78
+ buf = ""
63
79
  lines.each do |line|
64
- puts detab(line)
80
+ buf << detab(line) << "\n"
65
81
  end
66
- puts '```'
82
+ buf << '```' << "\n"
83
+ buf
67
84
  end
68
85
 
69
86
  def ul_begin
70
- blank if @ul_indent == 0
87
+ buf = ""
88
+ buf << blank if @ul_indent == 0
71
89
  @ul_indent += 1
90
+ buf
72
91
  end
73
92
 
74
93
  def ul_item(lines)
75
- puts " " * (@ul_indent - 1) + "* " + "#{lines.join}"
94
+ blank_reset
95
+ " " * (@ul_indent - 1) + "* " + "#{lines.join}" + "\n"
76
96
  end
77
97
 
78
98
  def ul_item_begin(lines)
79
- puts " " * (@ul_indent - 1) + "* " + "#{lines.join}"
99
+ blank_reset
100
+ " " * (@ul_indent - 1) + "* " + "#{lines.join}" + "\n"
80
101
  end
81
102
 
82
103
  def ul_item_end
104
+ ""
83
105
  end
84
106
 
85
107
  def ul_end
108
+ buf = ""
86
109
  @ul_indent -= 1
87
- blank if @ul_indent == 0
110
+ buf << blank if @ul_indent == 0
111
+ buf
88
112
  end
89
113
 
90
114
  def ol_begin
91
- blank
115
+ buf = ""
116
+ buf << blank
117
+ buf
92
118
  end
93
119
 
94
120
  def ol_item(lines, num)
95
- puts "#{num}. #{lines.join}"
121
+ buf = ""
122
+ buf << "#{num}. #{lines.join}" << "\n"
123
+ blank_reset
124
+ buf
96
125
  end
97
126
 
98
127
  def ol_end
99
- blank
100
- end
101
-
102
- def dl_begin
103
- puts '<dl>'
104
- end
105
-
106
- def dt(line)
107
- puts "<dt>#{line}</dt>"
108
- end
109
-
110
- def dd(lines)
111
- puts "<dd>#{lines.join}</dd>"
112
- end
113
-
114
- def dl_end
115
- puts '</dl>'
128
+ buf = ""
129
+ buf << blank
130
+ buf
116
131
  end
117
132
 
118
133
  def emlist(lines, caption = nil, lang = nil)
119
- blank
134
+ buf = ""
135
+ buf << blank
120
136
  if caption
121
- puts caption
122
- print "\n"
137
+ buf << caption << "\n"
123
138
  end
124
139
  lang ||= ""
125
- puts "```#{lang}"
140
+ buf << "```#{lang}\n"
141
+ blank_reset
126
142
  lines.each do |line|
127
- puts detab(line)
143
+ buf << detab(line) << "\n"
128
144
  end
129
- puts "```"
130
- blank
145
+ buf << "```\n"
146
+ buf << blank
147
+ buf
131
148
  end
132
149
 
133
150
  def hr
134
- puts "----"
151
+ buf << "----\n"
152
+ blank_reset
153
+ buf
135
154
  end
136
155
 
137
156
  def compile_href(url, label)
@@ -165,45 +184,60 @@ module ReVIEW
165
184
 
166
185
 
167
186
  def image_image(id, caption, metric)
168
- blank
169
- puts "![#{compile_inline(caption)}](#{@chapter.image(id).path.sub(/\A\.\//, "")})"
170
- blank
187
+ buf = ""
188
+ buf << blank
189
+ buf << "![#{compile_inline(caption)}](#{@chapter.image(id).path.sub(/\A\.\//, "")})" << "\n"
190
+ blank_reset
191
+ buf << blank
192
+ buf
171
193
  end
172
194
 
173
195
  def image_dummy(id, caption, lines)
174
- puts lines.join
196
+ buf = ""
197
+ buf << lines.join << "\n"
198
+ blank_reset
199
+ buf
175
200
  end
176
201
 
177
202
  def inline_img(id)
178
203
  "#{I18n.t("image")}#{@chapter.image(id).number}"
179
204
  rescue KeyError
180
205
  error "unknown image: #{id}"
181
- nofunc_text("[UnknownImage:#{id}]")
206
+ "[UnknownImage:#{id}]"
182
207
  end
183
208
 
184
209
  def indepimage(id, caption="", metric=nil)
185
- blank
186
- puts "![#{compile_inline(caption)}](#{@chapter.image(id).path.sub(/\A\.\//, "")})"
187
- blank
210
+ buf = ""
211
+ buf << blank
212
+ buf << "![#{compile_inline(caption)}](#{@chapter.image(id).path.sub(/\A\.\//, "")})" << "\n"
213
+ blank_reset
214
+ buf << blank
215
+ buf
188
216
  end
189
217
 
190
218
  def pagebreak
191
- puts "{pagebreak}"
219
+ buf = ""
220
+ buf << "{pagebreak}" << "\n"
221
+ buf
192
222
  end
193
223
 
194
224
  def image_ext
195
225
  "jpg"
196
226
  end
197
227
 
198
- def cmd(lines)
199
- puts "```shell-session"
228
+ def cmd(lines, caption = nil)
229
+ buf = ""
230
+ buf << "```shell-session" << "\n"
231
+ blank_reset
200
232
  lines.each do |line|
201
- puts detab(line)
233
+ buf << detab(line) << "\n"
202
234
  end
203
- puts "```"
235
+ buf << "```" << "\n"
236
+ buf
204
237
  end
205
238
 
206
239
  def table(lines, id = nil, caption = nil)
240
+ buf = ""
207
241
  rows = []
208
242
  sepidx = nil
209
243
  lines.each_with_index do |line, idx|
@@ -213,52 +247,58 @@ module ReVIEW
213
247
  sepidx ||= idx
214
248
  next
215
249
  end
216
- rows.push line.strip.split(/\t+/).map {|s| s.sub(/\A\./, '') }
250
+ rows.push line.strip.split(/\t+/).map{|s| s.sub(/\A\./, '') }
217
251
  end
218
252
  rows = adjust_n_cols(rows)
219
253
 
220
254
  begin
221
- table_header id, caption unless caption.nil?
255
+ buf << table_header(id, caption) unless caption.nil?
222
256
  rescue KeyError
223
257
  error "no such table: #{id}"
224
258
  end
225
- table_begin rows.first.size
226
- return if rows.empty?
259
+ buf << table_begin(rows.first.size)
260
+ return buf if rows.empty?
227
261
  if sepidx
228
262
  sepidx.times do
229
- tr rows.shift.map {|s| th(s) }
263
+ buf << tr(rows.shift.map{|s| th(s) })
230
264
  end
231
- table_border rows.first.size
265
+ buf << table_border(rows.first.size)
232
266
  rows.each do |cols|
233
- tr cols.map {|s| td(s) }
267
+ buf << tr(cols.map{|s| td(s) })
234
268
  end
235
269
  else
236
270
  rows.each do |cols|
237
271
  h, *cs = *cols
238
- tr [th(h)] + cs.map {|s| td(s) }
272
+ tr([th(h)] + cs.map {|s| td(s) })
239
273
  end
240
274
  end
241
- table_end
275
+ buf << table_end
276
+ buf
242
277
  end
243
278
 
244
279
  def table_header(id, caption)
280
+ buf = ""
245
281
  if get_chap.nil?
246
- puts %Q[#{I18n.t("table")}#{I18n.t("format_number_header_without_chapter", [@chapter.table(id).number])}#{I18n.t("caption_prefix")}#{compile_inline(caption)}]
282
+ buf << %Q[#{I18n.t("table")}#{I18n.t("format_number_header_without_chapter", [@chapter.table(id).number])}#{I18n.t("caption_prefix")}#{compile_inline(caption)}] << "\n"
247
283
  else
248
- puts %Q[#{I18n.t("table")}#{I18n.t("format_number_header", [get_chap, @chapter.table(id).number])}#{I18n.t("caption_prefix")}#{compile_inline(caption)}]
284
+ buf << %Q[#{I18n.t("table")}#{I18n.t("format_number_header", [get_chap, @chapter.table(id).number])}#{I18n.t("caption_prefix")}#{compile_inline(caption)}] << "\n"
249
285
  end
250
- blank
286
+ blank_reset
287
+ buf << blank
288
+ buf
251
289
  end
252
290
 
253
291
  def table_begin(ncols)
292
+ ""
254
293
  end
255
294
 
256
295
  def tr(rows)
257
- puts "|#{rows.join("|")}|"
296
+ "|#{rows.join("|")}|\n"
258
297
  end
259
298
 
260
299
  def table_border(ncols)
261
- puts (0..ncols).map{"|"}.join(":--")
300
+ blank_reset
301
+ (0..ncols).map{"|"}.join(":--") + "\n"
262
302
  end
263
303
 
264
304
  def th(str)
@@ -270,12 +310,17 @@ module ReVIEW
270
310
  end
271
311
 
272
312
  def table_end
273
- blank
313
+ buf = ""
314
+ buf << blank
315
+ buf
274
316
  end
275
317
 
276
318
  def footnote(id, str)
277
- puts "[^#{id}]: #{compile_inline(str)}"
278
- blank
319
+ buf = ""
320
+ buf << "[^#{id}]: #{compile_inline(str)}" << "\n"
321
+ blank_reset
322
+ buf << blank
323
+ buf
279
324
  end
280
325
 
281
326
  def inline_fn(id)
@@ -291,4 +336,4 @@ module ReVIEW
291
336
  end
292
337
  end
293
338
 
294
- end # module ReVIEW
339
+ end # module ReVIEW
@@ -0,0 +1,267 @@
1
+ require 'json'
2
+
3
+ module ReVIEW
4
+ class Node
5
+ attr_accessor :content
6
+
7
+ def to_raw
8
+ to_s_by(:to_raw)
9
+ end
10
+
11
+ def to_doc
12
+ to_s_by(:to_doc)
13
+ end
14
+
15
+ def to_s_by(meth)
16
+ if content.kind_of? String
17
+ @content
18
+ elsif content == nil
19
+ nil
20
+ elsif !content.kind_of? Array
21
+ @content.__send__(meth)
22
+ else
23
+ ##@content.map(&meth).join("")
24
+ @content.map{|o| o.__send__(meth)}.join("")
25
+ end
26
+ end
27
+
28
+ def to_json(*args)
29
+ if content.kind_of? String
30
+ val = '"'+@content.gsub(/\"/,'\\"').gsub(/\n/,'\\n')+'"'
31
+ elsif content == nil
32
+ val = "null"
33
+ elsif !content.kind_of? Array
34
+ val = @content.to_json
35
+ else
36
+ val = "["+@content.map(&:to_json).join(",")+"]"
37
+ end
38
+ '{"ruleName":"' + self.class.to_s.sub(/ReVIEW::/,"").sub(/Node$/,"") + '",' +
39
+ "\"offset\":#{position.pos},\"line\":#{position.line},\"column\":#{position.col}," +
40
+ '"childNodes":' + val +
41
+ '}'
42
+ end
43
+
44
+ def inspect
45
+ self.to_json
46
+ end
47
+
48
+ end
49
+
50
+ class HeadlineNode < Node
51
+
52
+ def to_doc
53
+ content_str = super
54
+ cmd = @cmd ? @cmd.to_doc : nil
55
+ label = @label
56
+ @compiler.compile_headline(@level, cmd, label, content_str)
57
+ end
58
+
59
+ def to_json
60
+ '{"ruleName":"' + self.class.to_s.sub(/ReVIEW::/,"").sub(/Node$/,"") + '",' +
61
+ %Q|"cmd":"#{@cmd.to_json}",|+
62
+ %Q|"label":"#{@label.to_json}",|+
63
+ "\"offset\":#{position.pos},\"line\":#{position.line},\"column\":#{position.col}," +
64
+ '"childNodes":' + @content.to_json + '}'
65
+ end
66
+ end
67
+
68
+ class ParagraphNode < Node
69
+
70
+ def to_doc
71
+ #content = @content.map(&:to_doc)
72
+ content = super.split(/\n/)
73
+ @compiler.compile_paragraph(content)
74
+ end
75
+ end
76
+
77
+ class BlockElementNode < Node
78
+
79
+ def to_doc
80
+ # content_str = super
81
+ args = @args.map(&:to_doc)
82
+ if @content
83
+ content_lines = @content.map(&:to_doc)
84
+ else
85
+ content_lines = nil
86
+ end
87
+ @compiler.compile_command(@name, @args, content_lines, self)
88
+ end
89
+
90
+ def parse_args(*patterns)
91
+ patterns.map.with_index do |pattern, i|
92
+ if @args[i]
93
+ @args[i].__send__("to_#{pattern}")
94
+ else
95
+ nil
96
+ end
97
+ end
98
+ end
99
+ end
100
+
101
+ class CodeBlockElementNode < Node
102
+
103
+ def to_doc
104
+ # content_str = super
105
+ args = @args.map(&:to_doc)
106
+ if @content
107
+ content_lines = raw_lines
108
+ else
109
+ content_lines = nil
110
+ end
111
+ @compiler.compile_command(@name, @args, content_lines, self)
112
+ end
113
+
114
+ def parse_args(*patterns)
115
+ patterns.map.with_index do |pattern, i|
116
+ if @args[i]
117
+ @args[i].__send__("to_#{pattern}")
118
+ else
119
+ nil
120
+ end
121
+ end
122
+ end
123
+
124
+ def raw_lines
125
+ self.content.to_doc.split(/\n/)
126
+ end
127
+ end
128
+
129
+
130
+ class InlineElementNode < Node
131
+
132
+ def to_raw
133
+ content_str = super
134
+ "@<#{@symbol.to_s}>{#{content_str}}"
135
+ end
136
+
137
+ def to_doc
138
+ #content_str = super
139
+ @compiler.compile_inline(@symbol, @content)
140
+ end
141
+
142
+ def to_json
143
+ '{"ruleName":"' + self.class.to_s.sub(/ReVIEW::/,"").sub(/Node$/,"") + '",' +
144
+ %Q|"symbol":"#{@symbol}",| +
145
+ "\"offset\":#{position.pos},\"line\":#{position.line},\"column\":#{position.col}," +
146
+ '"childNodes":[' + @content.map(&:to_json).join(",") + ']}'
147
+ end
148
+ end
149
+
150
+ class InlineElementContentNode < Node
151
+ end
152
+
153
+ class TextNode < Node
154
+
155
+ def to_raw
156
+ content_str = super
157
+ content_str.to_s
158
+ end
159
+
160
+ def to_doc
161
+ content_str = super
162
+ @compiler.compile_text(content_str)
163
+ end
164
+
165
+ def to_json(*args)
166
+ val = '"'+@content.gsub(/\"/,'\\"').gsub(/\n/,'\\n')+'"'
167
+ '{"ruleName":"' + self.class.to_s.sub(/ReVIEW::/,"").sub(/Node$/,"") + '",' +
168
+ "\"offset\":#{position.pos},\"line\":#{position.line},\"column\":#{position.col}," +
169
+ '"text":' + val + '}'
170
+ end
171
+ end
172
+
173
+ class NewLineNode < Node
174
+
175
+ def to_doc
176
+ ""
177
+ end
178
+ end
179
+
180
+ class RawNode < Node
181
+
182
+ def to_doc
183
+ @compiler.compile_raw(@builder, @content.join(""))
184
+ end
185
+ end
186
+
187
+ class BracketArgNode < Node
188
+ end
189
+
190
+ class BraceArgNode < Node
191
+ end
192
+
193
+ class SinglelineCommentNode < Node
194
+ def to_doc
195
+ ""
196
+ end
197
+ end
198
+
199
+ class SinglelineContentNode < Node
200
+ end
201
+
202
+ class UlistNode < Node
203
+ def to_doc
204
+ @compiler.compile_ulist(@content)
205
+ end
206
+ end
207
+
208
+ class UlistElementNode < Node
209
+ def level=(level)
210
+ @level = level
211
+ end
212
+
213
+ def to_doc
214
+ @content.map(&:to_doc).join("")
215
+ end
216
+
217
+ def concat(elem)
218
+ @content << elem
219
+ end
220
+ end
221
+
222
+ class OlistNode < Node
223
+ def to_doc
224
+ @compiler.compile_olist(@content)
225
+ end
226
+ end
227
+
228
+ class OlistElementNode < Node
229
+ def num=(num)
230
+ @num = num
231
+ end
232
+
233
+ def to_doc
234
+ @content.map(&:to_doc).join("")
235
+ end
236
+
237
+ def concat(elem)
238
+ @content << elem
239
+ end
240
+ end
241
+
242
+ class DlistNode < Node
243
+ def to_doc
244
+ @compiler.compile_dlist(@content)
245
+ end
246
+ end
247
+
248
+ class DlistElementNode < Node
249
+ def to_doc
250
+ @content.map(&:to_doc).join("")
251
+ end
252
+ end
253
+
254
+ class DocumentNode < Node
255
+ end
256
+
257
+ class ColumnNode < Node
258
+
259
+ def to_doc
260
+ level = @level
261
+ label = @label
262
+ caption = @caption ? @caption.to_doc : nil
263
+ @compiler.compile_column(level, label, caption, @content)
264
+ end
265
+ end
266
+
267
+ end