nora_mark 0.2beta3 → 0.2beta4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +5 -0
  3. data/Gemfile +2 -0
  4. data/README.md +17 -12
  5. data/example/nora-simple.css +52 -0
  6. data/example/noramark-reference-ja.nora +246 -0
  7. data/example/noramark-reference-ja_00001.xhtml +187 -0
  8. data/lib/nora_mark/html/{abstract_item_writer.rb → abstract_node_writer.rb} +3 -3
  9. data/lib/nora_mark/html/context.rb +3 -21
  10. data/lib/nora_mark/html/frontmatter_writer.rb +33 -0
  11. data/lib/nora_mark/html/generator.rb +122 -100
  12. data/lib/nora_mark/html/pages.rb +3 -9
  13. data/lib/nora_mark/html/paragraph_writer.rb +27 -23
  14. data/lib/nora_mark/html/tag_writer.rb +33 -34
  15. data/lib/nora_mark/html/writer_selector.rb +3 -3
  16. data/lib/nora_mark/node.rb +31 -0
  17. data/lib/nora_mark/parser.kpeg +133 -79
  18. data/lib/nora_mark/parser.kpeg.rb +1822 -1526
  19. data/lib/nora_mark/parser.rb +4 -23
  20. data/lib/nora_mark/version.rb +1 -1
  21. data/lib/nora_mark.rb +7 -2
  22. data/nora_mark.gemspec +1 -0
  23. data/spec/epub30-schemas/epub-nav-30.nvdl +16 -0
  24. data/spec/epub30-schemas/epub-nav-30.rnc +10 -0
  25. data/spec/epub30-schemas/epub-nav-30.sch +72 -0
  26. data/spec/epub30-schemas/epub-svg-30.nvdl +15 -0
  27. data/spec/epub30-schemas/epub-svg-30.rnc +15 -0
  28. data/spec/epub30-schemas/epub-svg-30.sch +10 -0
  29. data/spec/epub30-schemas/epub-xhtml-30.nvdl +15 -0
  30. data/spec/epub30-schemas/epub-xhtml-30.rnc +37 -0
  31. data/spec/epub30-schemas/epub-xhtml-30.sch +377 -0
  32. data/spec/epub30-schemas/epub30-catalog.xml +335 -0
  33. data/spec/epub30-schemas/media-overlay-30.nvdl +14 -0
  34. data/spec/epub30-schemas/media-overlay-30.rnc +46 -0
  35. data/spec/epub30-schemas/media-overlay-30.sch +9 -0
  36. data/spec/epub30-schemas/mod/datatypes.rnc +143 -0
  37. data/spec/epub30-schemas/mod/epub-mathml3-30.rnc +74 -0
  38. data/spec/epub30-schemas/mod/epub-prefix-attr.rnc +8 -0
  39. data/spec/epub30-schemas/mod/epub-ssml-attrs.rnc +11 -0
  40. data/spec/epub30-schemas/mod/epub-svg11-30.rnc +12 -0
  41. data/spec/epub30-schemas/mod/epub-svg11-re.sch +7 -0
  42. data/spec/epub30-schemas/mod/epub-switch.rnc +32 -0
  43. data/spec/epub30-schemas/mod/epub-trigger.rnc +17 -0
  44. data/spec/epub30-schemas/mod/epub-type-attr.rnc +7 -0
  45. data/spec/epub30-schemas/mod/epub-xhtml-mathml3-30.rnc +5 -0
  46. data/spec/epub30-schemas/mod/epub-xhtml-svg11-30.rnc +6 -0
  47. data/spec/epub30-schemas/mod/html5/LICENSE +23 -0
  48. data/spec/epub30-schemas/mod/html5/README +21 -0
  49. data/spec/epub30-schemas/mod/html5/html5-aria-30.rnc +105 -0
  50. data/spec/epub30-schemas/mod/html5/html5-attrib-30.rnc +44 -0
  51. data/spec/epub30-schemas/mod/html5/html5-document-30.rnc +44 -0
  52. data/spec/epub30-schemas/mod/html5/html5-edit-30.rnc +24 -0
  53. data/spec/epub30-schemas/mod/html5/html5-embed-30.rnc +155 -0
  54. data/spec/epub30-schemas/mod/html5/html5-forms-30.rnc +431 -0
  55. data/spec/epub30-schemas/mod/html5/html5-grouping-30.rnc +115 -0
  56. data/spec/epub30-schemas/mod/html5/html5-interactive-30.rnc +86 -0
  57. data/spec/epub30-schemas/mod/html5/html5-models-30.rnc +10 -0
  58. data/spec/epub30-schemas/mod/html5/html5-phrasing-30.rnc +134 -0
  59. data/spec/epub30-schemas/mod/html5/html5-script-30.rnc +164 -0
  60. data/spec/epub30-schemas/mod/html5/html5-sections-30.rnc +58 -0
  61. data/spec/epub30-schemas/mod/html5/html5-style-30.rnc +18 -0
  62. data/spec/epub30-schemas/mod/id-unique.sch +10 -0
  63. data/spec/epub30-schemas/mod/mathml/LICENSE +3 -0
  64. data/spec/epub30-schemas/mod/mathml/mathml3-common.rnc +84 -0
  65. data/spec/epub30-schemas/mod/mathml/mathml3-content.rnc +373 -0
  66. data/spec/epub30-schemas/mod/mathml/mathml3-presentation.rnc +536 -0
  67. data/spec/epub30-schemas/mod/mathml/mathml3-strict-content.rnc +60 -0
  68. data/spec/epub30-schemas/mod/security/LICENSE +4 -0
  69. data/spec/epub30-schemas/mod/security/Lenient-Encryption11-ghc.rnc +41 -0
  70. data/spec/epub30-schemas/mod/security/Lenient-Encryption11.rnc +39 -0
  71. data/spec/epub30-schemas/mod/security/Lenient-Signature-exclusiveC14N.rnc +25 -0
  72. data/spec/epub30-schemas/mod/security/Lenient-Signature11-properties-exclusiveC14N.rnc +32 -0
  73. data/spec/epub30-schemas/mod/security/Lenient-Signature11-properties.rnc +30 -0
  74. data/spec/epub30-schemas/mod/security/Lenient-Signature11.rnc +28 -0
  75. data/spec/epub30-schemas/mod/security/Strict-Encryption.rnc +27 -0
  76. data/spec/epub30-schemas/mod/security/Strict-Signature.rnc +22 -0
  77. data/spec/epub30-schemas/mod/security/exc-c14n.rnc +39 -0
  78. data/spec/epub30-schemas/mod/security/security_any.rnc +15 -0
  79. data/spec/epub30-schemas/mod/security/xenc-allowAnyForeign.rnc +25 -0
  80. data/spec/epub30-schemas/mod/security/xenc-schema-11.rnc +96 -0
  81. data/spec/epub30-schemas/mod/security/xenc-schema.rnc +145 -0
  82. data/spec/epub30-schemas/mod/security/xenc11-allowAnyForeign.rnc +19 -0
  83. data/spec/epub30-schemas/mod/security/xmldsig-allowAnyForeign.rnc +47 -0
  84. data/spec/epub30-schemas/mod/security/xmldsig-core-schema.rnc +276 -0
  85. data/spec/epub30-schemas/mod/security/xmldsig-filter2.rnc +16 -0
  86. data/spec/epub30-schemas/mod/security/xmldsig-properties-schema.rnc +34 -0
  87. data/spec/epub30-schemas/mod/security/xmldsig11-allowAnyForeign.rnc +18 -0
  88. data/spec/epub30-schemas/mod/security/xmldsig11-schema.rnc +133 -0
  89. data/spec/epub30-schemas/mod/security/xmlsec-ghc-allowAnyForeign.rnc +21 -0
  90. data/spec/epub30-schemas/mod/security/xmlsec-ghc-schema.rnc +42 -0
  91. data/spec/epub30-schemas/mod/svg11/LICENSE +1 -0
  92. data/spec/epub30-schemas/mod/svg11/README.txt +8 -0
  93. data/spec/epub30-schemas/mod/svg11/svg11-flat.rnc +3999 -0
  94. data/spec/epub30-schemas/ocf-container-30.rnc +16 -0
  95. data/spec/epub30-schemas/ocf-encryption-30.rnc +12 -0
  96. data/spec/epub30-schemas/ocf-signatures-30.rnc +8 -0
  97. data/spec/epub30-schemas/package-30.nvdl +14 -0
  98. data/spec/epub30-schemas/package-30.rnc +91 -0
  99. data/spec/epub30-schemas/package-30.sch +137 -0
  100. data/spec/jing-20091111/bin/jing.jar +0 -0
  101. data/spec/nora_mark_spec.rb +229 -68
  102. data/spec/spec_helper.rb +16 -0
  103. metadata +179 -6
  104. data/lib/nora_mark/html/header_writer.rb +0 -35
  105. data/spec/fixture/test_src_ja.nora +0 -50
@@ -3,18 +3,277 @@ require 'kpeg/compiled_parser'
3
3
  class NoraMark::Parser < KPeg::CompiledParser
4
4
  # :stopdoc:
5
5
 
6
- # eof = !.
7
- def _eof
6
+ module ::NoraMark
7
+ class Node; end
8
+ class Block < Node
9
+ def initialize(name, ids, classes, parameters, content)
10
+ @name = name
11
+ @ids = ids
12
+ @classes = classes
13
+ @parameters = parameters
14
+ @content = content
15
+ end
16
+ attr_reader :name
17
+ attr_reader :ids
18
+ attr_reader :classes
19
+ attr_reader :parameters
20
+ attr_reader :content
21
+ end
22
+ class Breakline < Node
23
+ def initialize()
24
+ end
25
+ end
26
+ class DefinitionList < Node
27
+ def initialize(ids, classes, parameters, content)
28
+ @ids = ids
29
+ @classes = classes
30
+ @parameters = parameters
31
+ @content = content
32
+ end
33
+ attr_reader :ids
34
+ attr_reader :classes
35
+ attr_reader :parameters
36
+ attr_reader :content
37
+ end
38
+ class DLItem < Node
39
+ def initialize(ids, classes, parameters, content)
40
+ @ids = ids
41
+ @classes = classes
42
+ @parameters = parameters
43
+ @content = content
44
+ end
45
+ attr_reader :ids
46
+ attr_reader :classes
47
+ attr_reader :parameters
48
+ attr_reader :content
49
+ end
50
+ class Frontmatter < Node
51
+ def initialize(content)
52
+ @content = content
53
+ end
54
+ attr_reader :content
55
+ end
56
+ class HeadedSection < Node
57
+ def initialize(level, heading, content)
58
+ @level = level
59
+ @heading = heading
60
+ @content = content
61
+ end
62
+ attr_reader :level
63
+ attr_reader :heading
64
+ attr_reader :content
65
+ end
66
+ class Inline < Node
67
+ def initialize(name, ids, classes, parameters, content)
68
+ @name = name
69
+ @ids = ids
70
+ @classes = classes
71
+ @parameters = parameters
72
+ @content = content
73
+ end
74
+ attr_reader :name
75
+ attr_reader :ids
76
+ attr_reader :classes
77
+ attr_reader :parameters
78
+ attr_reader :content
79
+ end
80
+ class LineCommand < Node
81
+ def initialize(name, ids, classes, parameters, content)
82
+ @name = name
83
+ @ids = ids
84
+ @classes = classes
85
+ @parameters = parameters
86
+ @content = content
87
+ end
88
+ attr_reader :name
89
+ attr_reader :ids
90
+ attr_reader :classes
91
+ attr_reader :parameters
92
+ attr_reader :content
93
+ end
94
+ class Newpage < Node
95
+ def initialize(ids, classes, parameters, content)
96
+ @ids = ids
97
+ @classes = classes
98
+ @parameters = parameters
99
+ @content = content
100
+ end
101
+ attr_reader :ids
102
+ attr_reader :classes
103
+ attr_reader :parameters
104
+ attr_reader :content
105
+ end
106
+ class OlItem < Node
107
+ def initialize(ids, classes, parameters, content)
108
+ @ids = ids
109
+ @classes = classes
110
+ @parameters = parameters
111
+ @content = content
112
+ end
113
+ attr_reader :ids
114
+ attr_reader :classes
115
+ attr_reader :parameters
116
+ attr_reader :content
117
+ end
118
+ class OrderedList < Node
119
+ def initialize(ids, classes, parameters, content)
120
+ @ids = ids
121
+ @classes = classes
122
+ @parameters = parameters
123
+ @content = content
124
+ end
125
+ attr_reader :ids
126
+ attr_reader :classes
127
+ attr_reader :parameters
128
+ attr_reader :content
129
+ end
130
+ class Page < Node
131
+ def initialize(content)
132
+ @content = content
133
+ end
134
+ attr_reader :content
135
+ end
136
+ class Paragraph < Node
137
+ def initialize(ids, classes, parameters, content)
138
+ @ids = ids
139
+ @classes = classes
140
+ @parameters = parameters
141
+ @content = content
142
+ end
143
+ attr_reader :ids
144
+ attr_reader :classes
145
+ attr_reader :parameters
146
+ attr_reader :content
147
+ end
148
+ class ParagraphGroup < Node
149
+ def initialize(ids, classes, parameters, content)
150
+ @ids = ids
151
+ @classes = classes
152
+ @parameters = parameters
153
+ @content = content
154
+ end
155
+ attr_reader :ids
156
+ attr_reader :classes
157
+ attr_reader :parameters
158
+ attr_reader :content
159
+ end
160
+ class PreformattedBlock < Node
161
+ def initialize(name, ids, classes, parameters, codelanguage, content)
162
+ @name = name
163
+ @ids = ids
164
+ @classes = classes
165
+ @parameters = parameters
166
+ @codelanguage = codelanguage
167
+ @content = content
168
+ end
169
+ attr_reader :name
170
+ attr_reader :ids
171
+ attr_reader :classes
172
+ attr_reader :parameters
173
+ attr_reader :codelanguage
174
+ attr_reader :content
175
+ end
176
+ class Text < Node
177
+ def initialize(content)
178
+ @content = content
179
+ end
180
+ attr_reader :content
181
+ end
182
+ class UlItem < Node
183
+ def initialize(ids, classes, parameters, content)
184
+ @ids = ids
185
+ @classes = classes
186
+ @parameters = parameters
187
+ @content = content
188
+ end
189
+ attr_reader :ids
190
+ attr_reader :classes
191
+ attr_reader :parameters
192
+ attr_reader :content
193
+ end
194
+ class UnorderedList < Node
195
+ def initialize(ids, classes, parameters, content)
196
+ @ids = ids
197
+ @classes = classes
198
+ @parameters = parameters
199
+ @content = content
200
+ end
201
+ attr_reader :ids
202
+ attr_reader :classes
203
+ attr_reader :parameters
204
+ attr_reader :content
205
+ end
206
+ end
207
+ module ::NoraMarkConstruction
208
+ def block(name, ids, classes, parameters, content)
209
+ ::NoraMark::Block.new(name, ids, classes, parameters, content)
210
+ end
211
+ def br()
212
+ ::NoraMark::Breakline.new()
213
+ end
214
+ def definition_list(ids, classes, parameters, content)
215
+ ::NoraMark::DefinitionList.new(ids, classes, parameters, content)
216
+ end
217
+ def dl_item(ids, classes, parameters, content)
218
+ ::NoraMark::DLItem.new(ids, classes, parameters, content)
219
+ end
220
+ def frontmatter(content)
221
+ ::NoraMark::Frontmatter.new(content)
222
+ end
223
+ def h_section(level, heading, content)
224
+ ::NoraMark::HeadedSection.new(level, heading, content)
225
+ end
226
+ def inline(name, ids, classes, parameters, content)
227
+ ::NoraMark::Inline.new(name, ids, classes, parameters, content)
228
+ end
229
+ def line_command(name, ids, classes, parameters, content)
230
+ ::NoraMark::LineCommand.new(name, ids, classes, parameters, content)
231
+ end
232
+ def newpage(ids, classes, parameters, content)
233
+ ::NoraMark::Newpage.new(ids, classes, parameters, content)
234
+ end
235
+ def ol_item(ids, classes, parameters, content)
236
+ ::NoraMark::OlItem.new(ids, classes, parameters, content)
237
+ end
238
+ def ordered_list(ids, classes, parameters, content)
239
+ ::NoraMark::OrderedList.new(ids, classes, parameters, content)
240
+ end
241
+ def page(content)
242
+ ::NoraMark::Page.new(content)
243
+ end
244
+ def paragraph(ids, classes, parameters, content)
245
+ ::NoraMark::Paragraph.new(ids, classes, parameters, content)
246
+ end
247
+ def paragraph_group(ids, classes, parameters, content)
248
+ ::NoraMark::ParagraphGroup.new(ids, classes, parameters, content)
249
+ end
250
+ def preformatted_block(name, ids, classes, parameters, codelanguage, content)
251
+ ::NoraMark::PreformattedBlock.new(name, ids, classes, parameters, codelanguage, content)
252
+ end
253
+ def text(content)
254
+ ::NoraMark::Text.new(content)
255
+ end
256
+ def ul_item(ids, classes, parameters, content)
257
+ ::NoraMark::UlItem.new(ids, classes, parameters, content)
258
+ end
259
+ def unordered_list(ids, classes, parameters, content)
260
+ ::NoraMark::UnorderedList.new(ids, classes, parameters, content)
261
+ end
262
+ end
263
+ include ::NoraMarkConstruction
264
+
265
+ # Eof = !.
266
+ def _Eof
8
267
  _save = self.pos
9
268
  _tmp = get_byte
10
269
  _tmp = _tmp ? nil : true
11
270
  self.pos = _save
12
- set_failed_rule :_eof unless _tmp
271
+ set_failed_rule :_Eof unless _tmp
13
272
  return _tmp
14
273
  end
15
274
 
16
- # space = (" " | "\\t")
17
- def _space
275
+ # Space = (" " | "\\t")
276
+ def _Space
18
277
 
19
278
  _save = self.pos
20
279
  while true # choice
@@ -27,22 +286,17 @@ class NoraMark::Parser < KPeg::CompiledParser
27
286
  break
28
287
  end # end choice
29
288
 
30
- set_failed_rule :_space unless _tmp
289
+ set_failed_rule :_Space unless _tmp
31
290
  return _tmp
32
291
  end
33
292
 
34
- # eof_comment = lh space* "#" (!eof .)*
35
- def _eof_comment
293
+ # EofComment = Space* "#" (!Eof .)*
294
+ def _EofComment
36
295
 
37
296
  _save = self.pos
38
297
  while true # sequence
39
- _tmp = apply(:_lh)
40
- unless _tmp
41
- self.pos = _save
42
- break
43
- end
44
298
  while true
45
- _tmp = apply(:_space)
299
+ _tmp = apply(:_Space)
46
300
  break unless _tmp
47
301
  end
48
302
  _tmp = true
@@ -60,7 +314,7 @@ class NoraMark::Parser < KPeg::CompiledParser
60
314
  _save3 = self.pos
61
315
  while true # sequence
62
316
  _save4 = self.pos
63
- _tmp = apply(:_eof)
317
+ _tmp = apply(:_Eof)
64
318
  _tmp = _tmp ? nil : true
65
319
  self.pos = _save4
66
320
  unless _tmp
@@ -83,22 +337,17 @@ class NoraMark::Parser < KPeg::CompiledParser
83
337
  break
84
338
  end # end sequence
85
339
 
86
- set_failed_rule :_eof_comment unless _tmp
340
+ set_failed_rule :_EofComment unless _tmp
87
341
  return _tmp
88
342
  end
89
343
 
90
- # comment = lh space* "#" (!nl .)* nl empty_line*
91
- def _comment
344
+ # Comment = Space* "#" (!Nl .)* Nl EmptyLine*
345
+ def _Comment
92
346
 
93
347
  _save = self.pos
94
348
  while true # sequence
95
- _tmp = apply(:_lh)
96
- unless _tmp
97
- self.pos = _save
98
- break
99
- end
100
349
  while true
101
- _tmp = apply(:_space)
350
+ _tmp = apply(:_Space)
102
351
  break unless _tmp
103
352
  end
104
353
  _tmp = true
@@ -116,7 +365,7 @@ class NoraMark::Parser < KPeg::CompiledParser
116
365
  _save3 = self.pos
117
366
  while true # sequence
118
367
  _save4 = self.pos
119
- _tmp = apply(:_nl)
368
+ _tmp = apply(:_Nl)
120
369
  _tmp = _tmp ? nil : true
121
370
  self.pos = _save4
122
371
  unless _tmp
@@ -137,13 +386,13 @@ class NoraMark::Parser < KPeg::CompiledParser
137
386
  self.pos = _save
138
387
  break
139
388
  end
140
- _tmp = apply(:_nl)
389
+ _tmp = apply(:_Nl)
141
390
  unless _tmp
142
391
  self.pos = _save
143
392
  break
144
393
  end
145
394
  while true
146
- _tmp = apply(:_empty_line)
395
+ _tmp = apply(:_EmptyLine)
147
396
  break unless _tmp
148
397
  end
149
398
  _tmp = true
@@ -153,25 +402,14 @@ class NoraMark::Parser < KPeg::CompiledParser
153
402
  break
154
403
  end # end sequence
155
404
 
156
- set_failed_rule :_comment unless _tmp
405
+ set_failed_rule :_Comment unless _tmp
157
406
  return _tmp
158
407
  end
159
408
 
160
- # - = (space | comment)*
409
+ # - = Space*
161
410
  def __hyphen_
162
411
  while true
163
-
164
- _save1 = self.pos
165
- while true # choice
166
- _tmp = apply(:_space)
167
- break if _tmp
168
- self.pos = _save1
169
- _tmp = apply(:_comment)
170
- break if _tmp
171
- self.pos = _save1
172
- break
173
- end # end choice
174
-
412
+ _tmp = apply(:_Space)
175
413
  break unless _tmp
176
414
  end
177
415
  _tmp = true
@@ -179,12 +417,12 @@ class NoraMark::Parser < KPeg::CompiledParser
179
417
  return _tmp
180
418
  end
181
419
 
182
- # empty_line = lh - nl
183
- def _empty_line
420
+ # EmptyLine = /^/ - (Nl | Comment | EofComment)
421
+ def _EmptyLine
184
422
 
185
423
  _save = self.pos
186
424
  while true # sequence
187
- _tmp = apply(:_lh)
425
+ _tmp = scan(/\A(?-mix:^)/)
188
426
  unless _tmp
189
427
  self.pos = _save
190
428
  break
@@ -194,51 +432,58 @@ class NoraMark::Parser < KPeg::CompiledParser
194
432
  self.pos = _save
195
433
  break
196
434
  end
197
- _tmp = apply(:_nl)
435
+
436
+ _save1 = self.pos
437
+ while true # choice
438
+ _tmp = apply(:_Nl)
439
+ break if _tmp
440
+ self.pos = _save1
441
+ _tmp = apply(:_Comment)
442
+ break if _tmp
443
+ self.pos = _save1
444
+ _tmp = apply(:_EofComment)
445
+ break if _tmp
446
+ self.pos = _save1
447
+ break
448
+ end # end choice
449
+
198
450
  unless _tmp
199
451
  self.pos = _save
200
452
  end
201
453
  break
202
454
  end # end sequence
203
455
 
204
- set_failed_rule :_empty_line unless _tmp
456
+ set_failed_rule :_EmptyLine unless _tmp
205
457
  return _tmp
206
458
  end
207
459
 
208
- # nl = /\r?\n/
209
- def _nl
460
+ # Nl = /\r?\n/
461
+ def _Nl
210
462
  _tmp = scan(/\A(?-mix:\r?\n)/)
211
- set_failed_rule :_nl unless _tmp
212
- return _tmp
213
- end
214
-
215
- # lh = /^/
216
- def _lh
217
- _tmp = scan(/\A(?-mix:^)/)
218
- set_failed_rule :_lh unless _tmp
463
+ set_failed_rule :_Nl unless _tmp
219
464
  return _tmp
220
465
  end
221
466
 
222
- # le = (nl | eof)
223
- def _le
467
+ # Le = (Nl | Eof)
468
+ def _Le
224
469
 
225
470
  _save = self.pos
226
471
  while true # choice
227
- _tmp = apply(:_nl)
472
+ _tmp = apply(:_Nl)
228
473
  break if _tmp
229
474
  self.pos = _save
230
- _tmp = apply(:_eof)
475
+ _tmp = apply(:_Eof)
231
476
  break if _tmp
232
477
  self.pos = _save
233
478
  break
234
479
  end # end choice
235
480
 
236
- set_failed_rule :_le unless _tmp
481
+ set_failed_rule :_Le unless _tmp
237
482
  return _tmp
238
483
  end
239
484
 
240
- # word = < /[\w0-9]/ ("-" | /[\w0-9]/)* > { text }
241
- def _word
485
+ # Word = < /[\w0-9]/ ("-" | /[\w0-9]/)* > { text }
486
+ def _Word
242
487
 
243
488
  _save = self.pos
244
489
  while true # sequence
@@ -288,12 +533,12 @@ class NoraMark::Parser < KPeg::CompiledParser
288
533
  break
289
534
  end # end sequence
290
535
 
291
- set_failed_rule :_word unless _tmp
536
+ set_failed_rule :_Word unless _tmp
292
537
  return _tmp
293
538
  end
294
539
 
295
- # num = < [0-9]+ > { text.to_i }
296
- def _num
540
+ # Num = < [0-9]+ > { text.to_i }
541
+ def _Num
297
542
 
298
543
  _save = self.pos
299
544
  while true # sequence
@@ -338,12 +583,12 @@ class NoraMark::Parser < KPeg::CompiledParser
338
583
  break
339
584
  end # end sequence
340
585
 
341
- set_failed_rule :_num unless _tmp
586
+ set_failed_rule :_Num unless _tmp
342
587
  return _tmp
343
588
  end
344
589
 
345
- # classname = "." word:classname { classname }
346
- def _classname
590
+ # ClassName = "." Word:classname { classname }
591
+ def _ClassName
347
592
 
348
593
  _save = self.pos
349
594
  while true # sequence
@@ -352,7 +597,7 @@ class NoraMark::Parser < KPeg::CompiledParser
352
597
  self.pos = _save
353
598
  break
354
599
  end
355
- _tmp = apply(:_word)
600
+ _tmp = apply(:_Word)
356
601
  classname = @result
357
602
  unless _tmp
358
603
  self.pos = _save
@@ -366,18 +611,18 @@ class NoraMark::Parser < KPeg::CompiledParser
366
611
  break
367
612
  end # end sequence
368
613
 
369
- set_failed_rule :_classname unless _tmp
614
+ set_failed_rule :_ClassName unless _tmp
370
615
  return _tmp
371
616
  end
372
617
 
373
- # classnames = classname*:classnames { classnames }
374
- def _classnames
618
+ # ClassNames = ClassName*:classnames { classnames }
619
+ def _ClassNames
375
620
 
376
621
  _save = self.pos
377
622
  while true # sequence
378
623
  _ary = []
379
624
  while true
380
- _tmp = apply(:_classname)
625
+ _tmp = apply(:_ClassName)
381
626
  _ary << @result if _tmp
382
627
  break unless _tmp
383
628
  end
@@ -396,12 +641,12 @@ class NoraMark::Parser < KPeg::CompiledParser
396
641
  break
397
642
  end # end sequence
398
643
 
399
- set_failed_rule :_classnames unless _tmp
644
+ set_failed_rule :_ClassNames unless _tmp
400
645
  return _tmp
401
646
  end
402
647
 
403
- # idname = "#" word:idname { idname }
404
- def _idname
648
+ # IdName = "#" Word:idname { idname }
649
+ def _IdName
405
650
 
406
651
  _save = self.pos
407
652
  while true # sequence
@@ -410,7 +655,7 @@ class NoraMark::Parser < KPeg::CompiledParser
410
655
  self.pos = _save
411
656
  break
412
657
  end
413
- _tmp = apply(:_word)
658
+ _tmp = apply(:_Word)
414
659
  idname = @result
415
660
  unless _tmp
416
661
  self.pos = _save
@@ -424,18 +669,18 @@ class NoraMark::Parser < KPeg::CompiledParser
424
669
  break
425
670
  end # end sequence
426
671
 
427
- set_failed_rule :_idname unless _tmp
672
+ set_failed_rule :_IdName unless _tmp
428
673
  return _tmp
429
674
  end
430
675
 
431
- # idnames = idname*:idnames { idnames }
432
- def _idnames
676
+ # IdNames = IdName*:idnames { idnames }
677
+ def _IdNames
433
678
 
434
679
  _save = self.pos
435
680
  while true # sequence
436
681
  _ary = []
437
682
  while true
438
- _tmp = apply(:_idname)
683
+ _tmp = apply(:_IdName)
439
684
  _ary << @result if _tmp
440
685
  break unless _tmp
441
686
  end
@@ -454,23 +699,23 @@ class NoraMark::Parser < KPeg::CompiledParser
454
699
  break
455
700
  end # end sequence
456
701
 
457
- set_failed_rule :_idnames unless _tmp
702
+ set_failed_rule :_IdNames unless _tmp
458
703
  return _tmp
459
704
  end
460
705
 
461
- # commandname = word:name idnames?:idnames classnames?:classes { {:name => name, :ids => idnames, :classes => classes} }
462
- def _commandname
706
+ # CommandName = Word:name IdNames?:idnames ClassNames?:classes { {name: name, ids: idnames, classes: classes} }
707
+ def _CommandName
463
708
 
464
709
  _save = self.pos
465
710
  while true # sequence
466
- _tmp = apply(:_word)
711
+ _tmp = apply(:_Word)
467
712
  name = @result
468
713
  unless _tmp
469
714
  self.pos = _save
470
715
  break
471
716
  end
472
717
  _save1 = self.pos
473
- _tmp = apply(:_idnames)
718
+ _tmp = apply(:_IdNames)
474
719
  @result = nil unless _tmp
475
720
  unless _tmp
476
721
  _tmp = true
@@ -482,7 +727,7 @@ class NoraMark::Parser < KPeg::CompiledParser
482
727
  break
483
728
  end
484
729
  _save2 = self.pos
485
- _tmp = apply(:_classnames)
730
+ _tmp = apply(:_ClassNames)
486
731
  @result = nil unless _tmp
487
732
  unless _tmp
488
733
  _tmp = true
@@ -493,7 +738,7 @@ class NoraMark::Parser < KPeg::CompiledParser
493
738
  self.pos = _save
494
739
  break
495
740
  end
496
- @result = begin; {:name => name, :ids => idnames, :classes => classes} ; end
741
+ @result = begin; {name: name, ids: idnames, classes: classes} ; end
497
742
  _tmp = true
498
743
  unless _tmp
499
744
  self.pos = _save
@@ -501,81 +746,21 @@ class NoraMark::Parser < KPeg::CompiledParser
501
746
  break
502
747
  end # end sequence
503
748
 
504
- set_failed_rule :_commandname unless _tmp
749
+ set_failed_rule :_CommandName unless _tmp
505
750
  return _tmp
506
751
  end
507
752
 
508
- # parameter = < (/[^,)]/* | "\"" /[^"]/* "\"" | "'" /[^']/* "'") > { text }
509
- def _parameter
753
+ # ParameterNormal = < /[^,)]/* > { text }
754
+ def _ParameterNormal
510
755
 
511
756
  _save = self.pos
512
757
  while true # sequence
513
758
  _text_start = self.pos
514
-
515
- _save1 = self.pos
516
- while true # choice
517
- while true
518
- _tmp = scan(/\A(?-mix:[^,)])/)
519
- break unless _tmp
520
- end
521
- _tmp = true
522
- break if _tmp
523
- self.pos = _save1
524
-
525
- _save3 = self.pos
526
- while true # sequence
527
- _tmp = match_string("\"")
528
- unless _tmp
529
- self.pos = _save3
530
- break
531
- end
532
- while true
533
- _tmp = scan(/\A(?-mix:[^"])/)
534
- break unless _tmp
535
- end
536
- _tmp = true
537
- unless _tmp
538
- self.pos = _save3
539
- break
540
- end
541
- _tmp = match_string("\"")
542
- unless _tmp
543
- self.pos = _save3
544
- end
545
- break
546
- end # end sequence
547
-
548
- break if _tmp
549
- self.pos = _save1
550
-
551
- _save5 = self.pos
552
- while true # sequence
553
- _tmp = match_string("'")
554
- unless _tmp
555
- self.pos = _save5
556
- break
557
- end
558
- while true
559
- _tmp = scan(/\A(?-mix:[^'])/)
560
- break unless _tmp
561
- end
562
- _tmp = true
563
- unless _tmp
564
- self.pos = _save5
565
- break
566
- end
567
- _tmp = match_string("'")
568
- unless _tmp
569
- self.pos = _save5
570
- end
571
- break
572
- end # end sequence
573
-
574
- break if _tmp
575
- self.pos = _save1
576
- break
577
- end # end choice
578
-
759
+ while true
760
+ _tmp = scan(/\A(?-mix:[^,)])/)
761
+ break unless _tmp
762
+ end
763
+ _tmp = true
579
764
  if _tmp
580
765
  text = get_text(_text_start)
581
766
  end
@@ -591,49 +776,26 @@ class NoraMark::Parser < KPeg::CompiledParser
591
776
  break
592
777
  end # end sequence
593
778
 
594
- set_failed_rule :_parameter unless _tmp
779
+ set_failed_rule :_ParameterNormal unless _tmp
595
780
  return _tmp
596
781
  end
597
782
 
598
- # parameters = < parameter ("," parameter)* > { text }
599
- def _parameters
783
+ # ParameterQuoted = "\"" < /[^"]/* > "\"" - &/[,)]/ { text }
784
+ def _ParameterQuoted
600
785
 
601
786
  _save = self.pos
602
787
  while true # sequence
603
- _text_start = self.pos
604
-
605
- _save1 = self.pos
606
- while true # sequence
607
- _tmp = apply(:_parameter)
608
- unless _tmp
609
- self.pos = _save1
610
- break
611
- end
612
- while true
613
-
614
- _save3 = self.pos
615
- while true # sequence
616
- _tmp = match_string(",")
617
- unless _tmp
618
- self.pos = _save3
619
- break
620
- end
621
- _tmp = apply(:_parameter)
622
- unless _tmp
623
- self.pos = _save3
624
- end
625
- break
626
- end # end sequence
627
-
628
- break unless _tmp
629
- end
630
- _tmp = true
631
- unless _tmp
632
- self.pos = _save1
633
- end
788
+ _tmp = match_string("\"")
789
+ unless _tmp
790
+ self.pos = _save
634
791
  break
635
- end # end sequence
636
-
792
+ end
793
+ _text_start = self.pos
794
+ while true
795
+ _tmp = scan(/\A(?-mix:[^"])/)
796
+ break unless _tmp
797
+ end
798
+ _tmp = true
637
799
  if _tmp
638
800
  text = get_text(_text_start)
639
801
  end
@@ -641,6 +803,23 @@ class NoraMark::Parser < KPeg::CompiledParser
641
803
  self.pos = _save
642
804
  break
643
805
  end
806
+ _tmp = match_string("\"")
807
+ unless _tmp
808
+ self.pos = _save
809
+ break
810
+ end
811
+ _tmp = apply(:__hyphen_)
812
+ unless _tmp
813
+ self.pos = _save
814
+ break
815
+ end
816
+ _save2 = self.pos
817
+ _tmp = scan(/\A(?-mix:[,)])/)
818
+ self.pos = _save2
819
+ unless _tmp
820
+ self.pos = _save
821
+ break
822
+ end
644
823
  @result = begin; text ; end
645
824
  _tmp = true
646
825
  unless _tmp
@@ -649,62 +828,51 @@ class NoraMark::Parser < KPeg::CompiledParser
649
828
  break
650
829
  end # end sequence
651
830
 
652
- set_failed_rule :_parameters unless _tmp
831
+ set_failed_rule :_ParameterQuoted unless _tmp
653
832
  return _tmp
654
833
  end
655
834
 
656
- # command = commandname:cn ("(" - parameters:arg - ")")? { arg ||= ''; cn.merge({ :args => arg.split(',') }) }
657
- def _command
835
+ # ParameterSingleQuoted = "'" < /[^']/* > "'" - &/[,)]/ { text }
836
+ def _ParameterSingleQuoted
658
837
 
659
838
  _save = self.pos
660
839
  while true # sequence
661
- _tmp = apply(:_commandname)
662
- cn = @result
840
+ _tmp = match_string("'")
663
841
  unless _tmp
664
842
  self.pos = _save
665
843
  break
666
844
  end
667
- _save1 = self.pos
668
-
669
- _save2 = self.pos
670
- while true # sequence
671
- _tmp = match_string("(")
672
- unless _tmp
673
- self.pos = _save2
674
- break
675
- end
676
- _tmp = apply(:__hyphen_)
677
- unless _tmp
678
- self.pos = _save2
679
- break
680
- end
681
- _tmp = apply(:_parameters)
682
- arg = @result
683
- unless _tmp
684
- self.pos = _save2
685
- break
686
- end
687
- _tmp = apply(:__hyphen_)
688
- unless _tmp
689
- self.pos = _save2
690
- break
691
- end
692
- _tmp = match_string(")")
693
- unless _tmp
694
- self.pos = _save2
695
- end
845
+ _text_start = self.pos
846
+ while true
847
+ _tmp = scan(/\A(?-mix:[^'])/)
848
+ break unless _tmp
849
+ end
850
+ _tmp = true
851
+ if _tmp
852
+ text = get_text(_text_start)
853
+ end
854
+ unless _tmp
855
+ self.pos = _save
696
856
  break
697
- end # end sequence
698
-
857
+ end
858
+ _tmp = match_string("'")
699
859
  unless _tmp
700
- _tmp = true
701
- self.pos = _save1
860
+ self.pos = _save
861
+ break
862
+ end
863
+ _tmp = apply(:__hyphen_)
864
+ unless _tmp
865
+ self.pos = _save
866
+ break
702
867
  end
868
+ _save2 = self.pos
869
+ _tmp = scan(/\A(?-mix:[,)])/)
870
+ self.pos = _save2
703
871
  unless _tmp
704
872
  self.pos = _save
705
873
  break
706
874
  end
707
- @result = begin; arg ||= ''; cn.merge({ :args => arg.split(',') }) ; end
875
+ @result = begin; text ; end
708
876
  _tmp = true
709
877
  unless _tmp
710
878
  self.pos = _save
@@ -712,53 +880,218 @@ class NoraMark::Parser < KPeg::CompiledParser
712
880
  break
713
881
  end # end sequence
714
882
 
715
- set_failed_rule :_command unless _tmp
883
+ set_failed_rule :_ParameterSingleQuoted unless _tmp
716
884
  return _tmp
717
885
  end
718
886
 
719
- # implicit_paragraph = < !paragraph_delimiter - documentline:p - > { create_item(:paragraph, nil, p, raw: text) }
720
- def _implicit_paragraph
887
+ # Parameter = (ParameterQuoted | ParameterSingleQuoted | ParameterNormal):value { value }
888
+ def _Parameter
721
889
 
722
890
  _save = self.pos
723
891
  while true # sequence
724
- _text_start = self.pos
725
892
 
726
893
  _save1 = self.pos
727
- while true # sequence
728
- _save2 = self.pos
729
- _tmp = apply(:_paragraph_delimiter)
730
- _tmp = _tmp ? nil : true
731
- self.pos = _save2
732
- unless _tmp
733
- self.pos = _save1
734
- break
735
- end
736
- _tmp = apply(:__hyphen_)
737
- unless _tmp
738
- self.pos = _save1
739
- break
740
- end
741
- _tmp = apply(:_documentline)
742
- p = @result
743
- unless _tmp
744
- self.pos = _save1
894
+ while true # choice
895
+ _tmp = apply(:_ParameterQuoted)
896
+ break if _tmp
897
+ self.pos = _save1
898
+ _tmp = apply(:_ParameterSingleQuoted)
899
+ break if _tmp
900
+ self.pos = _save1
901
+ _tmp = apply(:_ParameterNormal)
902
+ break if _tmp
903
+ self.pos = _save1
904
+ break
905
+ end # end choice
906
+
907
+ value = @result
908
+ unless _tmp
909
+ self.pos = _save
910
+ break
911
+ end
912
+ @result = begin; value ; end
913
+ _tmp = true
914
+ unless _tmp
915
+ self.pos = _save
916
+ end
917
+ break
918
+ end # end sequence
919
+
920
+ set_failed_rule :_Parameter unless _tmp
921
+ return _tmp
922
+ end
923
+
924
+ # Parameters = Parameter:parameter ("," - Parameter)*:rest_parameters { [parameter] + rest_parameters }
925
+ def _Parameters
926
+
927
+ _save = self.pos
928
+ while true # sequence
929
+ _tmp = apply(:_Parameter)
930
+ parameter = @result
931
+ unless _tmp
932
+ self.pos = _save
933
+ break
934
+ end
935
+ _ary = []
936
+ while true
937
+
938
+ _save2 = self.pos
939
+ while true # sequence
940
+ _tmp = match_string(",")
941
+ unless _tmp
942
+ self.pos = _save2
943
+ break
944
+ end
945
+ _tmp = apply(:__hyphen_)
946
+ unless _tmp
947
+ self.pos = _save2
948
+ break
949
+ end
950
+ _tmp = apply(:_Parameter)
951
+ unless _tmp
952
+ self.pos = _save2
953
+ end
954
+ break
955
+ end # end sequence
956
+
957
+ _ary << @result if _tmp
958
+ break unless _tmp
959
+ end
960
+ _tmp = true
961
+ @result = _ary
962
+ rest_parameters = @result
963
+ unless _tmp
964
+ self.pos = _save
965
+ break
966
+ end
967
+ @result = begin; [parameter] + rest_parameters ; end
968
+ _tmp = true
969
+ unless _tmp
970
+ self.pos = _save
971
+ end
972
+ break
973
+ end # end sequence
974
+
975
+ set_failed_rule :_Parameters unless _tmp
976
+ return _tmp
977
+ end
978
+
979
+ # Command = CommandName:cn ("(" - Parameters:args - ")")? { args ||= []; cn.merge({ args: args }) }
980
+ def _Command
981
+
982
+ _save = self.pos
983
+ while true # sequence
984
+ _tmp = apply(:_CommandName)
985
+ cn = @result
986
+ unless _tmp
987
+ self.pos = _save
988
+ break
989
+ end
990
+ _save1 = self.pos
991
+
992
+ _save2 = self.pos
993
+ while true # sequence
994
+ _tmp = match_string("(")
995
+ unless _tmp
996
+ self.pos = _save2
745
997
  break
746
998
  end
747
999
  _tmp = apply(:__hyphen_)
748
1000
  unless _tmp
749
- self.pos = _save1
1001
+ self.pos = _save2
1002
+ break
1003
+ end
1004
+ _tmp = apply(:_Parameters)
1005
+ args = @result
1006
+ unless _tmp
1007
+ self.pos = _save2
1008
+ break
1009
+ end
1010
+ _tmp = apply(:__hyphen_)
1011
+ unless _tmp
1012
+ self.pos = _save2
1013
+ break
1014
+ end
1015
+ _tmp = match_string(")")
1016
+ unless _tmp
1017
+ self.pos = _save2
750
1018
  end
751
1019
  break
752
1020
  end # end sequence
753
1021
 
754
- if _tmp
755
- text = get_text(_text_start)
1022
+ unless _tmp
1023
+ _tmp = true
1024
+ self.pos = _save1
1025
+ end
1026
+ unless _tmp
1027
+ self.pos = _save
1028
+ break
1029
+ end
1030
+ @result = begin; args ||= []; cn.merge({ args: args }) ; end
1031
+ _tmp = true
1032
+ unless _tmp
1033
+ self.pos = _save
1034
+ end
1035
+ break
1036
+ end # end sequence
1037
+
1038
+ set_failed_rule :_Command unless _tmp
1039
+ return _tmp
1040
+ end
1041
+
1042
+ # ImplicitParagraph = - !ParagraphDelimiter Comment* DocumentLine:content Comment* EofComment? {paragraph([],[], [], content)}
1043
+ def _ImplicitParagraph
1044
+
1045
+ _save = self.pos
1046
+ while true # sequence
1047
+ _tmp = apply(:__hyphen_)
1048
+ unless _tmp
1049
+ self.pos = _save
1050
+ break
1051
+ end
1052
+ _save1 = self.pos
1053
+ _tmp = apply(:_ParagraphDelimiter)
1054
+ _tmp = _tmp ? nil : true
1055
+ self.pos = _save1
1056
+ unless _tmp
1057
+ self.pos = _save
1058
+ break
1059
+ end
1060
+ while true
1061
+ _tmp = apply(:_Comment)
1062
+ break unless _tmp
1063
+ end
1064
+ _tmp = true
1065
+ unless _tmp
1066
+ self.pos = _save
1067
+ break
1068
+ end
1069
+ _tmp = apply(:_DocumentLine)
1070
+ content = @result
1071
+ unless _tmp
1072
+ self.pos = _save
1073
+ break
1074
+ end
1075
+ while true
1076
+ _tmp = apply(:_Comment)
1077
+ break unless _tmp
1078
+ end
1079
+ _tmp = true
1080
+ unless _tmp
1081
+ self.pos = _save
1082
+ break
1083
+ end
1084
+ _save4 = self.pos
1085
+ _tmp = apply(:_EofComment)
1086
+ unless _tmp
1087
+ _tmp = true
1088
+ self.pos = _save4
756
1089
  end
757
1090
  unless _tmp
758
1091
  self.pos = _save
759
1092
  break
760
1093
  end
761
- @result = begin; create_item(:paragraph, nil, p, raw: text) ; end
1094
+ @result = begin; paragraph([],[], [], content); end
762
1095
  _tmp = true
763
1096
  unless _tmp
764
1097
  self.pos = _save
@@ -766,76 +1099,63 @@ class NoraMark::Parser < KPeg::CompiledParser
766
1099
  break
767
1100
  end # end sequence
768
1101
 
769
- set_failed_rule :_implicit_paragraph unless _tmp
1102
+ set_failed_rule :_ImplicitParagraph unless _tmp
770
1103
  return _tmp
771
1104
  end
772
1105
 
773
- # paragraph = (explicit_paragraph | implicit_paragraph)
774
- def _paragraph
1106
+ # Paragraph = (ExplicitParagraph | ImplicitParagraph)
1107
+ def _Paragraph
775
1108
 
776
1109
  _save = self.pos
777
1110
  while true # choice
778
- _tmp = apply(:_explicit_paragraph)
1111
+ _tmp = apply(:_ExplicitParagraph)
779
1112
  break if _tmp
780
1113
  self.pos = _save
781
- _tmp = apply(:_implicit_paragraph)
1114
+ _tmp = apply(:_ImplicitParagraph)
782
1115
  break if _tmp
783
1116
  self.pos = _save
784
1117
  break
785
1118
  end # end choice
786
1119
 
787
- set_failed_rule :_paragraph unless _tmp
1120
+ set_failed_rule :_Paragraph unless _tmp
788
1121
  return _tmp
789
1122
  end
790
1123
 
791
- # paragraph_group = < paragraph+:p empty_line* > { create_item(:paragraph_group, nil, p, raw: text) }
792
- def _paragraph_group
1124
+ # ParagraphGroup = Paragraph+:p EmptyLine* {paragraph_group([],[],[],p)}
1125
+ def _ParagraphGroup
793
1126
 
794
1127
  _save = self.pos
795
1128
  while true # sequence
796
- _text_start = self.pos
797
-
798
1129
  _save1 = self.pos
799
- while true # sequence
800
- _save2 = self.pos
801
- _ary = []
802
- _tmp = apply(:_paragraph)
803
- if _tmp
804
- _ary << @result
805
- while true
806
- _tmp = apply(:_paragraph)
807
- _ary << @result if _tmp
808
- break unless _tmp
809
- end
810
- _tmp = true
811
- @result = _ary
812
- else
813
- self.pos = _save2
814
- end
815
- p = @result
816
- unless _tmp
817
- self.pos = _save1
818
- break
819
- end
1130
+ _ary = []
1131
+ _tmp = apply(:_Paragraph)
1132
+ if _tmp
1133
+ _ary << @result
820
1134
  while true
821
- _tmp = apply(:_empty_line)
1135
+ _tmp = apply(:_Paragraph)
1136
+ _ary << @result if _tmp
822
1137
  break unless _tmp
823
1138
  end
824
1139
  _tmp = true
825
- unless _tmp
826
- self.pos = _save1
827
- end
1140
+ @result = _ary
1141
+ else
1142
+ self.pos = _save1
1143
+ end
1144
+ p = @result
1145
+ unless _tmp
1146
+ self.pos = _save
828
1147
  break
829
- end # end sequence
830
-
831
- if _tmp
832
- text = get_text(_text_start)
833
1148
  end
1149
+ while true
1150
+ _tmp = apply(:_EmptyLine)
1151
+ break unless _tmp
1152
+ end
1153
+ _tmp = true
834
1154
  unless _tmp
835
1155
  self.pos = _save
836
1156
  break
837
1157
  end
838
- @result = begin; create_item(:paragraph_group, nil, p, raw: text) ; end
1158
+ @result = begin; paragraph_group([],[],[],p); end
839
1159
  _tmp = true
840
1160
  unless _tmp
841
1161
  self.pos = _save
@@ -843,26 +1163,21 @@ class NoraMark::Parser < KPeg::CompiledParser
843
1163
  break
844
1164
  end # end sequence
845
1165
 
846
- set_failed_rule :_paragraph_group unless _tmp
1166
+ set_failed_rule :_ParagraphGroup unless _tmp
847
1167
  return _tmp
848
1168
  end
849
1169
 
850
- # blockhead = lh - command:command - "{" - nl empty_line* { command }
851
- def _blockhead
1170
+ # BlockHead = - Command:command - "{" - Nl EmptyLine* { command }
1171
+ def _BlockHead
852
1172
 
853
1173
  _save = self.pos
854
1174
  while true # sequence
855
- _tmp = apply(:_lh)
856
- unless _tmp
857
- self.pos = _save
858
- break
859
- end
860
1175
  _tmp = apply(:__hyphen_)
861
1176
  unless _tmp
862
1177
  self.pos = _save
863
1178
  break
864
1179
  end
865
- _tmp = apply(:_command)
1180
+ _tmp = apply(:_Command)
866
1181
  command = @result
867
1182
  unless _tmp
868
1183
  self.pos = _save
@@ -883,13 +1198,13 @@ class NoraMark::Parser < KPeg::CompiledParser
883
1198
  self.pos = _save
884
1199
  break
885
1200
  end
886
- _tmp = apply(:_nl)
1201
+ _tmp = apply(:_Nl)
887
1202
  unless _tmp
888
1203
  self.pos = _save
889
1204
  break
890
1205
  end
891
1206
  while true
892
- _tmp = apply(:_empty_line)
1207
+ _tmp = apply(:_EmptyLine)
893
1208
  break unless _tmp
894
1209
  end
895
1210
  _tmp = true
@@ -905,20 +1220,15 @@ class NoraMark::Parser < KPeg::CompiledParser
905
1220
  break
906
1221
  end # end sequence
907
1222
 
908
- set_failed_rule :_blockhead unless _tmp
1223
+ set_failed_rule :_BlockHead unless _tmp
909
1224
  return _tmp
910
1225
  end
911
1226
 
912
- # blockend = lh - "}" - le empty_line*
913
- def _blockend
1227
+ # BlockEnd = - "}" - Le EmptyLine*
1228
+ def _BlockEnd
914
1229
 
915
1230
  _save = self.pos
916
1231
  while true # sequence
917
- _tmp = apply(:_lh)
918
- unless _tmp
919
- self.pos = _save
920
- break
921
- end
922
1232
  _tmp = apply(:__hyphen_)
923
1233
  unless _tmp
924
1234
  self.pos = _save
@@ -934,13 +1244,13 @@ class NoraMark::Parser < KPeg::CompiledParser
934
1244
  self.pos = _save
935
1245
  break
936
1246
  end
937
- _tmp = apply(:_le)
1247
+ _tmp = apply(:_Le)
938
1248
  unless _tmp
939
1249
  self.pos = _save
940
1250
  break
941
1251
  end
942
1252
  while true
943
- _tmp = apply(:_empty_line)
1253
+ _tmp = apply(:_EmptyLine)
944
1254
  break unless _tmp
945
1255
  end
946
1256
  _tmp = true
@@ -950,12 +1260,12 @@ class NoraMark::Parser < KPeg::CompiledParser
950
1260
  break
951
1261
  end # end sequence
952
1262
 
953
- set_failed_rule :_blockend unless _tmp
1263
+ set_failed_rule :_BlockEnd unless _tmp
954
1264
  return _tmp
955
1265
  end
956
1266
 
957
- # blockbody = (!blockend block)+:body { body }
958
- def _blockbody
1267
+ # BlockBody = (!BlockEnd Block)+:body { body }
1268
+ def _BlockBody
959
1269
 
960
1270
  _save = self.pos
961
1271
  while true # sequence
@@ -965,14 +1275,14 @@ class NoraMark::Parser < KPeg::CompiledParser
965
1275
  _save2 = self.pos
966
1276
  while true # sequence
967
1277
  _save3 = self.pos
968
- _tmp = apply(:_blockend)
1278
+ _tmp = apply(:_BlockEnd)
969
1279
  _tmp = _tmp ? nil : true
970
1280
  self.pos = _save3
971
1281
  unless _tmp
972
1282
  self.pos = _save2
973
1283
  break
974
1284
  end
975
- _tmp = apply(:_block)
1285
+ _tmp = apply(:_Block)
976
1286
  unless _tmp
977
1287
  self.pos = _save2
978
1288
  end
@@ -986,14 +1296,14 @@ class NoraMark::Parser < KPeg::CompiledParser
986
1296
  _save4 = self.pos
987
1297
  while true # sequence
988
1298
  _save5 = self.pos
989
- _tmp = apply(:_blockend)
1299
+ _tmp = apply(:_BlockEnd)
990
1300
  _tmp = _tmp ? nil : true
991
1301
  self.pos = _save5
992
1302
  unless _tmp
993
1303
  self.pos = _save4
994
1304
  break
995
1305
  end
996
- _tmp = apply(:_block)
1306
+ _tmp = apply(:_Block)
997
1307
  unless _tmp
998
1308
  self.pos = _save4
999
1309
  end
@@ -1021,56 +1331,43 @@ class NoraMark::Parser < KPeg::CompiledParser
1021
1331
  break
1022
1332
  end # end sequence
1023
1333
 
1024
- set_failed_rule :_blockbody unless _tmp
1334
+ set_failed_rule :_BlockBody unless _tmp
1025
1335
  return _tmp
1026
1336
  end
1027
1337
 
1028
- # explicit_block = < blockhead:head - blockbody:body - blockend > { create_item(:block, head, body, raw: text) }
1029
- def _explicit_block
1338
+ # ExplicitBlock = BlockHead:c - BlockBody:content - BlockEnd {block(c[:name], c[:ids], c[:classes], c[:args], content)}
1339
+ def _ExplicitBlock
1030
1340
 
1031
1341
  _save = self.pos
1032
1342
  while true # sequence
1033
- _text_start = self.pos
1034
-
1035
- _save1 = self.pos
1036
- while true # sequence
1037
- _tmp = apply(:_blockhead)
1038
- head = @result
1039
- unless _tmp
1040
- self.pos = _save1
1041
- break
1042
- end
1043
- _tmp = apply(:__hyphen_)
1044
- unless _tmp
1045
- self.pos = _save1
1046
- break
1047
- end
1048
- _tmp = apply(:_blockbody)
1049
- body = @result
1050
- unless _tmp
1051
- self.pos = _save1
1052
- break
1053
- end
1054
- _tmp = apply(:__hyphen_)
1055
- unless _tmp
1056
- self.pos = _save1
1057
- break
1058
- end
1059
- _tmp = apply(:_blockend)
1060
- unless _tmp
1061
- self.pos = _save1
1062
- end
1343
+ _tmp = apply(:_BlockHead)
1344
+ c = @result
1345
+ unless _tmp
1346
+ self.pos = _save
1347
+ break
1348
+ end
1349
+ _tmp = apply(:__hyphen_)
1350
+ unless _tmp
1351
+ self.pos = _save
1063
1352
  break
1064
- end # end sequence
1065
-
1066
- if _tmp
1067
- text = get_text(_text_start)
1068
1353
  end
1354
+ _tmp = apply(:_BlockBody)
1355
+ content = @result
1356
+ unless _tmp
1357
+ self.pos = _save
1358
+ break
1359
+ end
1360
+ _tmp = apply(:__hyphen_)
1361
+ unless _tmp
1362
+ self.pos = _save
1363
+ break
1364
+ end
1365
+ _tmp = apply(:_BlockEnd)
1069
1366
  unless _tmp
1070
1367
  self.pos = _save
1071
1368
  break
1072
1369
  end
1073
- @result = begin; create_item(:block, head, body, raw: text) ; end
1370
+ @result = begin; block(c[:name], c[:ids], c[:classes], c[:args], content); end
1074
1371
  _tmp = true
1075
1372
  unless _tmp
1076
1373
  self.pos = _save
@@ -1078,23 +1375,23 @@ class NoraMark::Parser < KPeg::CompiledParser
1078
1375
  break
1079
1376
  end # end sequence
1080
1377
 
1081
- set_failed_rule :_explicit_block unless _tmp
1378
+ set_failed_rule :_ExplicitBlock unless _tmp
1082
1379
  return _tmp
1083
1380
  end
1084
1381
 
1085
- # preformatted_command = command:command &{ ['pre', 'precode'].include? command[:name] }
1086
- def _preformatted_command
1382
+ # PreformattedCommand = Command:command &{ ['pre', 'code'].include? command[:name] }
1383
+ def _PreformattedCommand
1087
1384
 
1088
1385
  _save = self.pos
1089
1386
  while true # sequence
1090
- _tmp = apply(:_command)
1387
+ _tmp = apply(:_Command)
1091
1388
  command = @result
1092
1389
  unless _tmp
1093
1390
  self.pos = _save
1094
1391
  break
1095
1392
  end
1096
1393
  _save1 = self.pos
1097
- _tmp = begin; ['pre', 'precode'].include? command[:name] ; end
1394
+ _tmp = begin; ['pre', 'code'].include? command[:name] ; end
1098
1395
  self.pos = _save1
1099
1396
  unless _tmp
1100
1397
  self.pos = _save
@@ -1102,26 +1399,21 @@ class NoraMark::Parser < KPeg::CompiledParser
1102
1399
  break
1103
1400
  end # end sequence
1104
1401
 
1105
- set_failed_rule :_preformatted_command unless _tmp
1402
+ set_failed_rule :_PreformattedCommand unless _tmp
1106
1403
  return _tmp
1107
1404
  end
1108
1405
 
1109
- # preformatted_command_head = lh - preformatted_command:command - "<<" &/[\w0-9]/ { command }
1110
- def _preformatted_command_head
1406
+ # PreformattedCommandHeadSimple = - PreformattedCommand:command - "{" - Nl { command }
1407
+ def _PreformattedCommandHeadSimple
1111
1408
 
1112
1409
  _save = self.pos
1113
1410
  while true # sequence
1114
- _tmp = apply(:_lh)
1115
- unless _tmp
1116
- self.pos = _save
1117
- break
1118
- end
1119
1411
  _tmp = apply(:__hyphen_)
1120
1412
  unless _tmp
1121
1413
  self.pos = _save
1122
1414
  break
1123
1415
  end
1124
- _tmp = apply(:_preformatted_command)
1416
+ _tmp = apply(:_PreformattedCommand)
1125
1417
  command = @result
1126
1418
  unless _tmp
1127
1419
  self.pos = _save
@@ -1132,14 +1424,17 @@ class NoraMark::Parser < KPeg::CompiledParser
1132
1424
  self.pos = _save
1133
1425
  break
1134
1426
  end
1135
- _tmp = match_string("<<")
1427
+ _tmp = match_string("{")
1136
1428
  unless _tmp
1137
1429
  self.pos = _save
1138
1430
  break
1139
1431
  end
1140
- _save1 = self.pos
1141
- _tmp = scan(/\A(?-mix:[\w0-9])/)
1142
- self.pos = _save1
1432
+ _tmp = apply(:__hyphen_)
1433
+ unless _tmp
1434
+ self.pos = _save
1435
+ break
1436
+ end
1437
+ _tmp = apply(:_Nl)
1143
1438
  unless _tmp
1144
1439
  self.pos = _save
1145
1440
  break
@@ -1152,172 +1447,341 @@ class NoraMark::Parser < KPeg::CompiledParser
1152
1447
  break
1153
1448
  end # end sequence
1154
1449
 
1155
- set_failed_rule :_preformatted_command_head unless _tmp
1450
+ set_failed_rule :_PreformattedCommandHeadSimple unless _tmp
1156
1451
  return _tmp
1157
1452
  end
1158
1453
 
1159
- # preformat_end = lh word:delimiter &{ delimiter == start }
1160
- def _preformat_end(start)
1454
+ # PreformattedCommandHeadComplex = - PreformattedCommand:command - "{//" Word?:codelanguage - Nl { command.merge({codelanguage: codelanguage}) }
1455
+ def _PreformattedCommandHeadComplex
1161
1456
 
1162
1457
  _save = self.pos
1163
1458
  while true # sequence
1164
- _tmp = apply(:_lh)
1459
+ _tmp = apply(:__hyphen_)
1460
+ unless _tmp
1461
+ self.pos = _save
1462
+ break
1463
+ end
1464
+ _tmp = apply(:_PreformattedCommand)
1465
+ command = @result
1466
+ unless _tmp
1467
+ self.pos = _save
1468
+ break
1469
+ end
1470
+ _tmp = apply(:__hyphen_)
1165
1471
  unless _tmp
1166
1472
  self.pos = _save
1167
1473
  break
1168
1474
  end
1169
- _tmp = apply(:_word)
1170
- delimiter = @result
1475
+ _tmp = match_string("{//")
1171
1476
  unless _tmp
1172
1477
  self.pos = _save
1173
1478
  break
1174
1479
  end
1175
1480
  _save1 = self.pos
1176
- _tmp = begin; delimiter == start ; end
1177
- self.pos = _save1
1481
+ _tmp = apply(:_Word)
1482
+ @result = nil unless _tmp
1483
+ unless _tmp
1484
+ _tmp = true
1485
+ self.pos = _save1
1486
+ end
1487
+ codelanguage = @result
1488
+ unless _tmp
1489
+ self.pos = _save
1490
+ break
1491
+ end
1492
+ _tmp = apply(:__hyphen_)
1493
+ unless _tmp
1494
+ self.pos = _save
1495
+ break
1496
+ end
1497
+ _tmp = apply(:_Nl)
1498
+ unless _tmp
1499
+ self.pos = _save
1500
+ break
1501
+ end
1502
+ @result = begin; command.merge({codelanguage: codelanguage}) ; end
1503
+ _tmp = true
1178
1504
  unless _tmp
1179
1505
  self.pos = _save
1180
1506
  end
1181
1507
  break
1182
1508
  end # end sequence
1183
1509
 
1184
- set_failed_rule :_preformat_end unless _tmp
1510
+ set_failed_rule :_PreformattedCommandHeadComplex unless _tmp
1185
1511
  return _tmp
1186
1512
  end
1187
1513
 
1188
- # preformatted_block = < lh - preformatted_command_head:command !nl word:delimiter nl (!preformat_end(delimiter) lh charstring nl)+:content preformat_end(delimiter) > { create_item(:preformatted, command, content, raw: text) }
1189
- def _preformatted_block
1514
+ # PreformattedCommandHead = (PreformattedCommandHeadComplex | PreformattedCommandHeadSimple)
1515
+ def _PreformattedCommandHead
1516
+
1517
+ _save = self.pos
1518
+ while true # choice
1519
+ _tmp = apply(:_PreformattedCommandHeadComplex)
1520
+ break if _tmp
1521
+ self.pos = _save
1522
+ _tmp = apply(:_PreformattedCommandHeadSimple)
1523
+ break if _tmp
1524
+ self.pos = _save
1525
+ break
1526
+ end # end choice
1527
+
1528
+ set_failed_rule :_PreformattedCommandHead unless _tmp
1529
+ return _tmp
1530
+ end
1531
+
1532
+ # PreformatEndSimple = - "}" - Le EmptyLine*
1533
+ def _PreformatEndSimple
1190
1534
 
1191
1535
  _save = self.pos
1192
1536
  while true # sequence
1193
- _text_start = self.pos
1537
+ _tmp = apply(:__hyphen_)
1538
+ unless _tmp
1539
+ self.pos = _save
1540
+ break
1541
+ end
1542
+ _tmp = match_string("}")
1543
+ unless _tmp
1544
+ self.pos = _save
1545
+ break
1546
+ end
1547
+ _tmp = apply(:__hyphen_)
1548
+ unless _tmp
1549
+ self.pos = _save
1550
+ break
1551
+ end
1552
+ _tmp = apply(:_Le)
1553
+ unless _tmp
1554
+ self.pos = _save
1555
+ break
1556
+ end
1557
+ while true
1558
+ _tmp = apply(:_EmptyLine)
1559
+ break unless _tmp
1560
+ end
1561
+ _tmp = true
1562
+ unless _tmp
1563
+ self.pos = _save
1564
+ end
1565
+ break
1566
+ end # end sequence
1567
+
1568
+ set_failed_rule :_PreformatEndSimple unless _tmp
1569
+ return _tmp
1570
+ end
1571
+
1572
+ # PreformatEndComplex = - "//}" - Le EmptyLine*
1573
+ def _PreformatEndComplex
1574
+
1575
+ _save = self.pos
1576
+ while true # sequence
1577
+ _tmp = apply(:__hyphen_)
1578
+ unless _tmp
1579
+ self.pos = _save
1580
+ break
1581
+ end
1582
+ _tmp = match_string("//}")
1583
+ unless _tmp
1584
+ self.pos = _save
1585
+ break
1586
+ end
1587
+ _tmp = apply(:__hyphen_)
1588
+ unless _tmp
1589
+ self.pos = _save
1590
+ break
1591
+ end
1592
+ _tmp = apply(:_Le)
1593
+ unless _tmp
1594
+ self.pos = _save
1595
+ break
1596
+ end
1597
+ while true
1598
+ _tmp = apply(:_EmptyLine)
1599
+ break unless _tmp
1600
+ end
1601
+ _tmp = true
1602
+ unless _tmp
1603
+ self.pos = _save
1604
+ end
1605
+ break
1606
+ end # end sequence
1194
1607
 
1608
+ set_failed_rule :_PreformatEndComplex unless _tmp
1609
+ return _tmp
1610
+ end
1611
+
1612
+ # PreformattedBlockSimple = PreformattedCommandHeadSimple:c (!PreformatEndSimple CharString Nl)+:content PreformatEndSimple {preformatted_block(c[:name], c[:ids], c[:classes], c[:args], c[:codelanguage], content)}
1613
+ def _PreformattedBlockSimple
1614
+
1615
+ _save = self.pos
1616
+ while true # sequence
1617
+ _tmp = apply(:_PreformattedCommandHeadSimple)
1618
+ c = @result
1619
+ unless _tmp
1620
+ self.pos = _save
1621
+ break
1622
+ end
1195
1623
  _save1 = self.pos
1624
+ _ary = []
1625
+
1626
+ _save2 = self.pos
1196
1627
  while true # sequence
1197
- _tmp = apply(:_lh)
1198
- unless _tmp
1199
- self.pos = _save1
1200
- break
1201
- end
1202
- _tmp = apply(:__hyphen_)
1203
- unless _tmp
1204
- self.pos = _save1
1205
- break
1206
- end
1207
- _tmp = apply(:_preformatted_command_head)
1208
- command = @result
1209
- unless _tmp
1210
- self.pos = _save1
1211
- break
1212
- end
1213
- _save2 = self.pos
1214
- _tmp = apply(:_nl)
1628
+ _save3 = self.pos
1629
+ _tmp = apply(:_PreformatEndSimple)
1215
1630
  _tmp = _tmp ? nil : true
1216
- self.pos = _save2
1631
+ self.pos = _save3
1217
1632
  unless _tmp
1218
- self.pos = _save1
1633
+ self.pos = _save2
1219
1634
  break
1220
1635
  end
1221
- _tmp = apply(:_word)
1222
- delimiter = @result
1636
+ _tmp = apply(:_CharString)
1223
1637
  unless _tmp
1224
- self.pos = _save1
1638
+ self.pos = _save2
1225
1639
  break
1226
1640
  end
1227
- _tmp = apply(:_nl)
1641
+ _tmp = apply(:_Nl)
1228
1642
  unless _tmp
1229
- self.pos = _save1
1230
- break
1643
+ self.pos = _save2
1231
1644
  end
1232
- _save3 = self.pos
1233
- _ary = []
1645
+ break
1646
+ end # end sequence
1234
1647
 
1235
- _save4 = self.pos
1236
- while true # sequence
1237
- _save5 = self.pos
1238
- _tmp = apply_with_args(:_preformat_end, delimiter)
1239
- _tmp = _tmp ? nil : true
1240
- self.pos = _save5
1241
- unless _tmp
1242
- self.pos = _save4
1243
- break
1244
- end
1245
- _tmp = apply(:_lh)
1246
- unless _tmp
1247
- self.pos = _save4
1248
- break
1249
- end
1250
- _tmp = apply(:_charstring)
1251
- unless _tmp
1252
- self.pos = _save4
1648
+ if _tmp
1649
+ _ary << @result
1650
+ while true
1651
+
1652
+ _save4 = self.pos
1653
+ while true # sequence
1654
+ _save5 = self.pos
1655
+ _tmp = apply(:_PreformatEndSimple)
1656
+ _tmp = _tmp ? nil : true
1657
+ self.pos = _save5
1658
+ unless _tmp
1659
+ self.pos = _save4
1660
+ break
1661
+ end
1662
+ _tmp = apply(:_CharString)
1663
+ unless _tmp
1664
+ self.pos = _save4
1665
+ break
1666
+ end
1667
+ _tmp = apply(:_Nl)
1668
+ unless _tmp
1669
+ self.pos = _save4
1670
+ end
1253
1671
  break
1254
- end
1255
- _tmp = apply(:_nl)
1256
- unless _tmp
1257
- self.pos = _save4
1258
- end
1259
- break
1260
- end # end sequence
1672
+ end # end sequence
1261
1673
 
1262
- if _tmp
1263
- _ary << @result
1264
- while true
1674
+ _ary << @result if _tmp
1675
+ break unless _tmp
1676
+ end
1677
+ _tmp = true
1678
+ @result = _ary
1679
+ else
1680
+ self.pos = _save1
1681
+ end
1682
+ content = @result
1683
+ unless _tmp
1684
+ self.pos = _save
1685
+ break
1686
+ end
1687
+ _tmp = apply(:_PreformatEndSimple)
1688
+ unless _tmp
1689
+ self.pos = _save
1690
+ break
1691
+ end
1692
+ @result = begin; preformatted_block(c[:name], c[:ids], c[:classes], c[:args], c[:codelanguage], content); end
1693
+ _tmp = true
1694
+ unless _tmp
1695
+ self.pos = _save
1696
+ end
1697
+ break
1698
+ end # end sequence
1265
1699
 
1266
- _save6 = self.pos
1267
- while true # sequence
1268
- _save7 = self.pos
1269
- _tmp = apply_with_args(:_preformat_end, delimiter)
1270
- _tmp = _tmp ? nil : true
1271
- self.pos = _save7
1272
- unless _tmp
1273
- self.pos = _save6
1274
- break
1275
- end
1276
- _tmp = apply(:_lh)
1277
- unless _tmp
1278
- self.pos = _save6
1279
- break
1280
- end
1281
- _tmp = apply(:_charstring)
1282
- unless _tmp
1283
- self.pos = _save6
1284
- break
1285
- end
1286
- _tmp = apply(:_nl)
1287
- unless _tmp
1288
- self.pos = _save6
1289
- end
1290
- break
1291
- end # end sequence
1700
+ set_failed_rule :_PreformattedBlockSimple unless _tmp
1701
+ return _tmp
1702
+ end
1292
1703
 
1293
- _ary << @result if _tmp
1294
- break unless _tmp
1295
- end
1296
- _tmp = true
1297
- @result = _ary
1298
- else
1299
- self.pos = _save3
1704
+ # PreformattedBlockComplex = PreformattedCommandHeadComplex:c (!PreformatEndComplex CharString Nl)+:content PreformatEndComplex {preformatted_block(c[:name], c[:ids], c[:classes], c[:args], c[:codelanguage], content)}
1705
+ def _PreformattedBlockComplex
1706
+
1707
+ _save = self.pos
1708
+ while true # sequence
1709
+ _tmp = apply(:_PreformattedCommandHeadComplex)
1710
+ c = @result
1711
+ unless _tmp
1712
+ self.pos = _save
1713
+ break
1714
+ end
1715
+ _save1 = self.pos
1716
+ _ary = []
1717
+
1718
+ _save2 = self.pos
1719
+ while true # sequence
1720
+ _save3 = self.pos
1721
+ _tmp = apply(:_PreformatEndComplex)
1722
+ _tmp = _tmp ? nil : true
1723
+ self.pos = _save3
1724
+ unless _tmp
1725
+ self.pos = _save2
1726
+ break
1300
1727
  end
1301
- content = @result
1728
+ _tmp = apply(:_CharString)
1302
1729
  unless _tmp
1303
- self.pos = _save1
1730
+ self.pos = _save2
1304
1731
  break
1305
1732
  end
1306
- _tmp = apply_with_args(:_preformat_end, delimiter)
1733
+ _tmp = apply(:_Nl)
1307
1734
  unless _tmp
1308
- self.pos = _save1
1735
+ self.pos = _save2
1309
1736
  end
1310
1737
  break
1311
1738
  end # end sequence
1312
1739
 
1313
1740
  if _tmp
1314
- text = get_text(_text_start)
1741
+ _ary << @result
1742
+ while true
1743
+
1744
+ _save4 = self.pos
1745
+ while true # sequence
1746
+ _save5 = self.pos
1747
+ _tmp = apply(:_PreformatEndComplex)
1748
+ _tmp = _tmp ? nil : true
1749
+ self.pos = _save5
1750
+ unless _tmp
1751
+ self.pos = _save4
1752
+ break
1753
+ end
1754
+ _tmp = apply(:_CharString)
1755
+ unless _tmp
1756
+ self.pos = _save4
1757
+ break
1758
+ end
1759
+ _tmp = apply(:_Nl)
1760
+ unless _tmp
1761
+ self.pos = _save4
1762
+ end
1763
+ break
1764
+ end # end sequence
1765
+
1766
+ _ary << @result if _tmp
1767
+ break unless _tmp
1768
+ end
1769
+ _tmp = true
1770
+ @result = _ary
1771
+ else
1772
+ self.pos = _save1
1315
1773
  end
1774
+ content = @result
1316
1775
  unless _tmp
1317
1776
  self.pos = _save
1318
1777
  break
1319
1778
  end
1320
- @result = begin; create_item(:preformatted, command, content, raw: text) ; end
1779
+ _tmp = apply(:_PreformatEndComplex)
1780
+ unless _tmp
1781
+ self.pos = _save
1782
+ break
1783
+ end
1784
+ @result = begin; preformatted_block(c[:name], c[:ids], c[:classes], c[:args], c[:codelanguage], content); end
1321
1785
  _tmp = true
1322
1786
  unless _tmp
1323
1787
  self.pos = _save
@@ -1325,79 +1789,89 @@ class NoraMark::Parser < KPeg::CompiledParser
1325
1789
  break
1326
1790
  end # end sequence
1327
1791
 
1328
- set_failed_rule :_preformatted_block unless _tmp
1792
+ set_failed_rule :_PreformattedBlockComplex unless _tmp
1329
1793
  return _tmp
1330
1794
  end
1331
1795
 
1332
- # inline = (img_inline | common_inline)
1333
- def _inline
1796
+ # PreformattedBlock = (PreformattedBlockComplex | PreformattedBlockSimple)
1797
+ def _PreformattedBlock
1334
1798
 
1335
1799
  _save = self.pos
1336
1800
  while true # choice
1337
- _tmp = apply(:_img_inline)
1801
+ _tmp = apply(:_PreformattedBlockComplex)
1338
1802
  break if _tmp
1339
1803
  self.pos = _save
1340
- _tmp = apply(:_common_inline)
1804
+ _tmp = apply(:_PreformattedBlockSimple)
1341
1805
  break if _tmp
1342
1806
  self.pos = _save
1343
1807
  break
1344
1808
  end # end choice
1345
1809
 
1346
- set_failed_rule :_inline unless _tmp
1810
+ set_failed_rule :_PreformattedBlock unless _tmp
1347
1811
  return _tmp
1348
1812
  end
1349
1813
 
1350
- # common_inline = < "[" command:c "{" documentcontent_except('}'):content "}" "]" > { create_item(:inline, c, content, raw: text) }
1351
- def _common_inline
1814
+ # Inline = (ImgInline | CommonInline)
1815
+ def _Inline
1352
1816
 
1353
1817
  _save = self.pos
1354
- while true # sequence
1355
- _text_start = self.pos
1818
+ while true # choice
1819
+ _tmp = apply(:_ImgInline)
1820
+ break if _tmp
1821
+ self.pos = _save
1822
+ _tmp = apply(:_CommonInline)
1823
+ break if _tmp
1824
+ self.pos = _save
1825
+ break
1826
+ end # end choice
1356
1827
 
1357
- _save1 = self.pos
1358
- while true # sequence
1359
- _tmp = match_string("[")
1360
- unless _tmp
1361
- self.pos = _save1
1362
- break
1363
- end
1364
- _tmp = apply(:_command)
1365
- c = @result
1366
- unless _tmp
1367
- self.pos = _save1
1368
- break
1369
- end
1370
- _tmp = match_string("{")
1371
- unless _tmp
1372
- self.pos = _save1
1373
- break
1374
- end
1375
- _tmp = apply_with_args(:_documentcontent_except, '}')
1376
- content = @result
1377
- unless _tmp
1378
- self.pos = _save1
1379
- break
1380
- end
1381
- _tmp = match_string("}")
1382
- unless _tmp
1383
- self.pos = _save1
1384
- break
1385
- end
1386
- _tmp = match_string("]")
1387
- unless _tmp
1388
- self.pos = _save1
1389
- end
1390
- break
1391
- end # end sequence
1828
+ set_failed_rule :_Inline unless _tmp
1829
+ return _tmp
1830
+ end
1392
1831
 
1393
- if _tmp
1394
- text = get_text(_text_start)
1832
+ # CommonInline = "[" Command:c "{" - DocumentContentExcept('}'):content "}" "]" {inline(c[:name], c[:ids], c[:classes], c[:args], content)}
1833
+ def _CommonInline
1834
+
1835
+ _save = self.pos
1836
+ while true # sequence
1837
+ _tmp = match_string("[")
1838
+ unless _tmp
1839
+ self.pos = _save
1840
+ break
1841
+ end
1842
+ _tmp = apply(:_Command)
1843
+ c = @result
1844
+ unless _tmp
1845
+ self.pos = _save
1846
+ break
1847
+ end
1848
+ _tmp = match_string("{")
1849
+ unless _tmp
1850
+ self.pos = _save
1851
+ break
1852
+ end
1853
+ _tmp = apply(:__hyphen_)
1854
+ unless _tmp
1855
+ self.pos = _save
1856
+ break
1857
+ end
1858
+ _tmp = apply_with_args(:_DocumentContentExcept, '}')
1859
+ content = @result
1860
+ unless _tmp
1861
+ self.pos = _save
1862
+ break
1863
+ end
1864
+ _tmp = match_string("}")
1865
+ unless _tmp
1866
+ self.pos = _save
1867
+ break
1395
1868
  end
1869
+ _tmp = match_string("]")
1396
1870
  unless _tmp
1397
1871
  self.pos = _save
1398
1872
  break
1399
1873
  end
1400
- @result = begin; create_item(:inline, c, content, raw: text) ; end
1874
+ @result = begin; inline(c[:name], c[:ids], c[:classes], c[:args], content); end
1401
1875
  _tmp = true
1402
1876
  unless _tmp
1403
1877
  self.pos = _save
@@ -1405,16 +1879,16 @@ class NoraMark::Parser < KPeg::CompiledParser
1405
1879
  break
1406
1880
  end # end sequence
1407
1881
 
1408
- set_failed_rule :_common_inline unless _tmp
1882
+ set_failed_rule :_CommonInline unless _tmp
1409
1883
  return _tmp
1410
1884
  end
1411
1885
 
1412
- # img_command = command:c &{ c[:name] == 'img' && c[:args].size == 2}
1413
- def _img_command
1886
+ # ImgCommand = Command:c &{ c[:name] == 'img' && c[:args].size == 2}
1887
+ def _ImgCommand
1414
1888
 
1415
1889
  _save = self.pos
1416
1890
  while true # sequence
1417
- _tmp = apply(:_command)
1891
+ _tmp = apply(:_Command)
1418
1892
  c = @result
1419
1893
  unless _tmp
1420
1894
  self.pos = _save
@@ -1429,45 +1903,32 @@ class NoraMark::Parser < KPeg::CompiledParser
1429
1903
  break
1430
1904
  end # end sequence
1431
1905
 
1432
- set_failed_rule :_img_command unless _tmp
1906
+ set_failed_rule :_ImgCommand unless _tmp
1433
1907
  return _tmp
1434
1908
  end
1435
1909
 
1436
- # img_inline = < "[" img_command:c "]" > { create_item(:inline, c, nil, raw: text) }
1437
- def _img_inline
1910
+ # ImgInline = "[" ImgCommand:c "]" {inline(c[:name], c[:ids], c[:classes], c[:args], nil)}
1911
+ def _ImgInline
1438
1912
 
1439
1913
  _save = self.pos
1440
1914
  while true # sequence
1441
- _text_start = self.pos
1442
-
1443
- _save1 = self.pos
1444
- while true # sequence
1445
- _tmp = match_string("[")
1446
- unless _tmp
1447
- self.pos = _save1
1448
- break
1449
- end
1450
- _tmp = apply(:_img_command)
1451
- c = @result
1452
- unless _tmp
1453
- self.pos = _save1
1454
- break
1455
- end
1456
- _tmp = match_string("]")
1457
- unless _tmp
1458
- self.pos = _save1
1459
- end
1915
+ _tmp = match_string("[")
1916
+ unless _tmp
1917
+ self.pos = _save
1460
1918
  break
1461
- end # end sequence
1462
-
1463
- if _tmp
1464
- text = get_text(_text_start)
1465
1919
  end
1920
+ _tmp = apply(:_ImgCommand)
1921
+ c = @result
1922
+ unless _tmp
1923
+ self.pos = _save
1924
+ break
1925
+ end
1926
+ _tmp = match_string("]")
1466
1927
  unless _tmp
1467
1928
  self.pos = _save
1468
1929
  break
1469
1930
  end
1470
- @result = begin; create_item(:inline, c, nil, raw: text) ; end
1931
+ @result = begin; inline(c[:name], c[:ids], c[:classes], c[:args], nil); end
1471
1932
  _tmp = true
1472
1933
  unless _tmp
1473
1934
  self.pos = _save
@@ -1475,34 +1936,34 @@ class NoraMark::Parser < KPeg::CompiledParser
1475
1936
  break
1476
1937
  end # end sequence
1477
1938
 
1478
- set_failed_rule :_img_inline unless _tmp
1939
+ set_failed_rule :_ImgInline unless _tmp
1479
1940
  return _tmp
1480
1941
  end
1481
1942
 
1482
- # commandname_for_special_line_command = (newpage_command | explicit_paragraph_command)
1483
- def _commandname_for_special_line_command
1943
+ # CommandNameForSpecialLineCommand = (NewpageCommand | ExplicitParagraphCommand)
1944
+ def _CommandNameForSpecialLineCommand
1484
1945
 
1485
1946
  _save = self.pos
1486
1947
  while true # choice
1487
- _tmp = apply(:_newpage_command)
1948
+ _tmp = apply(:_NewpageCommand)
1488
1949
  break if _tmp
1489
1950
  self.pos = _save
1490
- _tmp = apply(:_explicit_paragraph_command)
1951
+ _tmp = apply(:_ExplicitParagraphCommand)
1491
1952
  break if _tmp
1492
1953
  self.pos = _save
1493
1954
  break
1494
1955
  end # end choice
1495
1956
 
1496
- set_failed_rule :_commandname_for_special_line_command unless _tmp
1957
+ set_failed_rule :_CommandNameForSpecialLineCommand unless _tmp
1497
1958
  return _tmp
1498
1959
  end
1499
1960
 
1500
- # newpage_command = command:command &{ command[:name] == 'newpage' }
1501
- def _newpage_command
1961
+ # NewpageCommand = Command:command &{ command[:name] == 'newpage' }
1962
+ def _NewpageCommand
1502
1963
 
1503
1964
  _save = self.pos
1504
1965
  while true # sequence
1505
- _tmp = apply(:_command)
1966
+ _tmp = apply(:_Command)
1506
1967
  command = @result
1507
1968
  unless _tmp
1508
1969
  self.pos = _save
@@ -1517,72 +1978,59 @@ class NoraMark::Parser < KPeg::CompiledParser
1517
1978
  break
1518
1979
  end # end sequence
1519
1980
 
1520
- set_failed_rule :_newpage_command unless _tmp
1981
+ set_failed_rule :_NewpageCommand unless _tmp
1521
1982
  return _tmp
1522
1983
  end
1523
1984
 
1524
- # newpage = < lh - newpage_command:c ":" documentcontent?:content - nl > { create_item(:newpage, c, content, raw:text) }
1525
- def _newpage
1985
+ # Newpage = - NewpageCommand:c ":" - DocumentContent?:content - Nl {newpage(c[:ids],c[:classes],c[:args], content)}
1986
+ def _Newpage
1526
1987
 
1527
1988
  _save = self.pos
1528
1989
  while true # sequence
1529
- _text_start = self.pos
1530
-
1990
+ _tmp = apply(:__hyphen_)
1991
+ unless _tmp
1992
+ self.pos = _save
1993
+ break
1994
+ end
1995
+ _tmp = apply(:_NewpageCommand)
1996
+ c = @result
1997
+ unless _tmp
1998
+ self.pos = _save
1999
+ break
2000
+ end
2001
+ _tmp = match_string(":")
2002
+ unless _tmp
2003
+ self.pos = _save
2004
+ break
2005
+ end
2006
+ _tmp = apply(:__hyphen_)
2007
+ unless _tmp
2008
+ self.pos = _save
2009
+ break
2010
+ end
1531
2011
  _save1 = self.pos
1532
- while true # sequence
1533
- _tmp = apply(:_lh)
1534
- unless _tmp
1535
- self.pos = _save1
1536
- break
1537
- end
1538
- _tmp = apply(:__hyphen_)
1539
- unless _tmp
1540
- self.pos = _save1
1541
- break
1542
- end
1543
- _tmp = apply(:_newpage_command)
1544
- c = @result
1545
- unless _tmp
1546
- self.pos = _save1
1547
- break
1548
- end
1549
- _tmp = match_string(":")
1550
- unless _tmp
1551
- self.pos = _save1
1552
- break
1553
- end
1554
- _save2 = self.pos
1555
- _tmp = apply(:_documentcontent)
1556
- @result = nil unless _tmp
1557
- unless _tmp
1558
- _tmp = true
1559
- self.pos = _save2
1560
- end
1561
- content = @result
1562
- unless _tmp
1563
- self.pos = _save1
1564
- break
1565
- end
1566
- _tmp = apply(:__hyphen_)
1567
- unless _tmp
1568
- self.pos = _save1
1569
- break
1570
- end
1571
- _tmp = apply(:_nl)
1572
- unless _tmp
1573
- self.pos = _save1
1574
- end
2012
+ _tmp = apply(:_DocumentContent)
2013
+ @result = nil unless _tmp
2014
+ unless _tmp
2015
+ _tmp = true
2016
+ self.pos = _save1
2017
+ end
2018
+ content = @result
2019
+ unless _tmp
2020
+ self.pos = _save
2021
+ break
2022
+ end
2023
+ _tmp = apply(:__hyphen_)
2024
+ unless _tmp
2025
+ self.pos = _save
1575
2026
  break
1576
- end # end sequence
1577
-
1578
- if _tmp
1579
- text = get_text(_text_start)
1580
2027
  end
2028
+ _tmp = apply(:_Nl)
1581
2029
  unless _tmp
1582
2030
  self.pos = _save
1583
2031
  break
1584
2032
  end
1585
- @result = begin; create_item(:newpage, c, content, raw:text) ; end
2033
+ @result = begin; newpage(c[:ids],c[:classes],c[:args], content); end
1586
2034
  _tmp = true
1587
2035
  unless _tmp
1588
2036
  self.pos = _save
@@ -1590,16 +2038,16 @@ class NoraMark::Parser < KPeg::CompiledParser
1590
2038
  break
1591
2039
  end # end sequence
1592
2040
 
1593
- set_failed_rule :_newpage unless _tmp
2041
+ set_failed_rule :_Newpage unless _tmp
1594
2042
  return _tmp
1595
2043
  end
1596
2044
 
1597
- # explicit_paragraph_command = command:c &{ c[:name] == 'p' }
1598
- def _explicit_paragraph_command
2045
+ # ExplicitParagraphCommand = Command:c &{ c[:name] == 'p' }
2046
+ def _ExplicitParagraphCommand
1599
2047
 
1600
2048
  _save = self.pos
1601
2049
  while true # sequence
1602
- _tmp = apply(:_command)
2050
+ _tmp = apply(:_Command)
1603
2051
  c = @result
1604
2052
  unless _tmp
1605
2053
  self.pos = _save
@@ -1614,76 +2062,138 @@ class NoraMark::Parser < KPeg::CompiledParser
1614
2062
  break
1615
2063
  end # end sequence
1616
2064
 
1617
- set_failed_rule :_explicit_paragraph_command unless _tmp
2065
+ set_failed_rule :_ExplicitParagraphCommand unless _tmp
1618
2066
  return _tmp
1619
2067
  end
1620
2068
 
1621
- # explicit_paragraph = < lh - explicit_paragraph_command:c ":" documentcontent?:content le empty_line* > { create_item(:paragraph, c, content, raw:text) }
1622
- def _explicit_paragraph
2069
+ # ExplicitParagraph = - ExplicitParagraphCommand:c ":" - DocumentContent?:content Le EmptyLine* {paragraph(c[:ids], c[:classes], c[:args], content)}
2070
+ def _ExplicitParagraph
1623
2071
 
1624
2072
  _save = self.pos
1625
2073
  while true # sequence
1626
- _text_start = self.pos
2074
+ _tmp = apply(:__hyphen_)
2075
+ unless _tmp
2076
+ self.pos = _save
2077
+ break
2078
+ end
2079
+ _tmp = apply(:_ExplicitParagraphCommand)
2080
+ c = @result
2081
+ unless _tmp
2082
+ self.pos = _save
2083
+ break
2084
+ end
2085
+ _tmp = match_string(":")
2086
+ unless _tmp
2087
+ self.pos = _save
2088
+ break
2089
+ end
2090
+ _tmp = apply(:__hyphen_)
2091
+ unless _tmp
2092
+ self.pos = _save
2093
+ break
2094
+ end
2095
+ _save1 = self.pos
2096
+ _tmp = apply(:_DocumentContent)
2097
+ @result = nil unless _tmp
2098
+ unless _tmp
2099
+ _tmp = true
2100
+ self.pos = _save1
2101
+ end
2102
+ content = @result
2103
+ unless _tmp
2104
+ self.pos = _save
2105
+ break
2106
+ end
2107
+ _tmp = apply(:_Le)
2108
+ unless _tmp
2109
+ self.pos = _save
2110
+ break
2111
+ end
2112
+ while true
2113
+ _tmp = apply(:_EmptyLine)
2114
+ break unless _tmp
2115
+ end
2116
+ _tmp = true
2117
+ unless _tmp
2118
+ self.pos = _save
2119
+ break
2120
+ end
2121
+ @result = begin; paragraph(c[:ids], c[:classes], c[:args], content); end
2122
+ _tmp = true
2123
+ unless _tmp
2124
+ self.pos = _save
2125
+ end
2126
+ break
2127
+ end # end sequence
1627
2128
 
2129
+ set_failed_rule :_ExplicitParagraph unless _tmp
2130
+ return _tmp
2131
+ end
2132
+
2133
+ # UnorderedList = UnorderedItem+:items {unordered_list([],[],[], items)}
2134
+ def _UnorderedList
2135
+
2136
+ _save = self.pos
2137
+ while true # sequence
1628
2138
  _save1 = self.pos
1629
- while true # sequence
1630
- _tmp = apply(:_lh)
1631
- unless _tmp
1632
- self.pos = _save1
1633
- break
1634
- end
1635
- _tmp = apply(:__hyphen_)
1636
- unless _tmp
1637
- self.pos = _save1
1638
- break
1639
- end
1640
- _tmp = apply(:_explicit_paragraph_command)
1641
- c = @result
1642
- unless _tmp
1643
- self.pos = _save1
1644
- break
1645
- end
1646
- _tmp = match_string(":")
1647
- unless _tmp
1648
- self.pos = _save1
1649
- break
1650
- end
1651
- _save2 = self.pos
1652
- _tmp = apply(:_documentcontent)
1653
- @result = nil unless _tmp
1654
- unless _tmp
1655
- _tmp = true
1656
- self.pos = _save2
1657
- end
1658
- content = @result
1659
- unless _tmp
1660
- self.pos = _save1
1661
- break
1662
- end
1663
- _tmp = apply(:_le)
1664
- unless _tmp
1665
- self.pos = _save1
1666
- break
1667
- end
2139
+ _ary = []
2140
+ _tmp = apply(:_UnorderedItem)
2141
+ if _tmp
2142
+ _ary << @result
1668
2143
  while true
1669
- _tmp = apply(:_empty_line)
2144
+ _tmp = apply(:_UnorderedItem)
2145
+ _ary << @result if _tmp
1670
2146
  break unless _tmp
1671
2147
  end
1672
2148
  _tmp = true
1673
- unless _tmp
1674
- self.pos = _save1
1675
- end
2149
+ @result = _ary
2150
+ else
2151
+ self.pos = _save1
2152
+ end
2153
+ items = @result
2154
+ unless _tmp
2155
+ self.pos = _save
1676
2156
  break
1677
- end # end sequence
2157
+ end
2158
+ @result = begin; unordered_list([],[],[], items); end
2159
+ _tmp = true
2160
+ unless _tmp
2161
+ self.pos = _save
2162
+ end
2163
+ break
2164
+ end # end sequence
1678
2165
 
1679
- if _tmp
1680
- text = get_text(_text_start)
2166
+ set_failed_rule :_UnorderedList unless _tmp
2167
+ return _tmp
2168
+ end
2169
+
2170
+ # UnorderedItem = "*:" - DocumentContent:content Le {ul_item([], [], [], content)}
2171
+ def _UnorderedItem
2172
+
2173
+ _save = self.pos
2174
+ while true # sequence
2175
+ _tmp = match_string("*:")
2176
+ unless _tmp
2177
+ self.pos = _save
2178
+ break
2179
+ end
2180
+ _tmp = apply(:__hyphen_)
2181
+ unless _tmp
2182
+ self.pos = _save
2183
+ break
2184
+ end
2185
+ _tmp = apply(:_DocumentContent)
2186
+ content = @result
2187
+ unless _tmp
2188
+ self.pos = _save
2189
+ break
1681
2190
  end
2191
+ _tmp = apply(:_Le)
1682
2192
  unless _tmp
1683
2193
  self.pos = _save
1684
2194
  break
1685
2195
  end
1686
- @result = begin; create_item(:paragraph, c, content, raw:text) ; end
2196
+ @result = begin; ul_item([], [], [], content); end
1687
2197
  _tmp = true
1688
2198
  unless _tmp
1689
2199
  self.pos = _save
@@ -1691,23 +2201,22 @@ class NoraMark::Parser < KPeg::CompiledParser
1691
2201
  break
1692
2202
  end # end sequence
1693
2203
 
1694
- set_failed_rule :_explicit_paragraph unless _tmp
2204
+ set_failed_rule :_UnorderedItem unless _tmp
1695
2205
  return _tmp
1696
2206
  end
1697
2207
 
1698
- # unordered_list = < unordered_item+:items > { create_item(:ul, nil, items, raw: text) }
1699
- def _unordered_list
2208
+ # OrderedList = OrderedItem+:items {ordered_list([],[],[], items)}
2209
+ def _OrderedList
1700
2210
 
1701
2211
  _save = self.pos
1702
2212
  while true # sequence
1703
- _text_start = self.pos
1704
2213
  _save1 = self.pos
1705
2214
  _ary = []
1706
- _tmp = apply(:_unordered_item)
2215
+ _tmp = apply(:_OrderedItem)
1707
2216
  if _tmp
1708
2217
  _ary << @result
1709
2218
  while true
1710
- _tmp = apply(:_unordered_item)
2219
+ _tmp = apply(:_OrderedItem)
1711
2220
  _ary << @result if _tmp
1712
2221
  break unless _tmp
1713
2222
  end
@@ -1717,14 +2226,11 @@ class NoraMark::Parser < KPeg::CompiledParser
1717
2226
  self.pos = _save1
1718
2227
  end
1719
2228
  items = @result
1720
- if _tmp
1721
- text = get_text(_text_start)
1722
- end
1723
2229
  unless _tmp
1724
2230
  self.pos = _save
1725
2231
  break
1726
2232
  end
1727
- @result = begin; create_item(:ul, nil, items, raw: text) ; end
2233
+ @result = begin; ordered_list([],[],[], items); end
1728
2234
  _tmp = true
1729
2235
  unless _tmp
1730
2236
  self.pos = _save
@@ -1732,50 +2238,42 @@ class NoraMark::Parser < KPeg::CompiledParser
1732
2238
  break
1733
2239
  end # end sequence
1734
2240
 
1735
- set_failed_rule :_unordered_list unless _tmp
2241
+ set_failed_rule :_OrderedList unless _tmp
1736
2242
  return _tmp
1737
2243
  end
1738
2244
 
1739
- # unordered_item = < lh "*:" documentcontent:content le > { create_item(:li, nil, content, raw: text) }
1740
- def _unordered_item
2245
+ # OrderedItem = Num ":" - DocumentContent:content Le {ol_item([], [], [], content)}
2246
+ def _OrderedItem
1741
2247
 
1742
2248
  _save = self.pos
1743
2249
  while true # sequence
1744
- _text_start = self.pos
1745
-
1746
- _save1 = self.pos
1747
- while true # sequence
1748
- _tmp = apply(:_lh)
1749
- unless _tmp
1750
- self.pos = _save1
1751
- break
1752
- end
1753
- _tmp = match_string("*:")
1754
- unless _tmp
1755
- self.pos = _save1
1756
- break
1757
- end
1758
- _tmp = apply(:_documentcontent)
1759
- content = @result
1760
- unless _tmp
1761
- self.pos = _save1
1762
- break
1763
- end
1764
- _tmp = apply(:_le)
1765
- unless _tmp
1766
- self.pos = _save1
1767
- end
2250
+ _tmp = apply(:_Num)
2251
+ unless _tmp
2252
+ self.pos = _save
2253
+ break
2254
+ end
2255
+ _tmp = match_string(":")
2256
+ unless _tmp
2257
+ self.pos = _save
2258
+ break
2259
+ end
2260
+ _tmp = apply(:__hyphen_)
2261
+ unless _tmp
2262
+ self.pos = _save
2263
+ break
2264
+ end
2265
+ _tmp = apply(:_DocumentContent)
2266
+ content = @result
2267
+ unless _tmp
2268
+ self.pos = _save
1768
2269
  break
1769
- end # end sequence
1770
-
1771
- if _tmp
1772
- text = get_text(_text_start)
1773
2270
  end
2271
+ _tmp = apply(:_Le)
1774
2272
  unless _tmp
1775
2273
  self.pos = _save
1776
2274
  break
1777
2275
  end
1778
- @result = begin; create_item(:li, nil, content, raw: text) ; end
2276
+ @result = begin; ol_item([], [], [], content); end
1779
2277
  _tmp = true
1780
2278
  unless _tmp
1781
2279
  self.pos = _save
@@ -1783,23 +2281,22 @@ class NoraMark::Parser < KPeg::CompiledParser
1783
2281
  break
1784
2282
  end # end sequence
1785
2283
 
1786
- set_failed_rule :_unordered_item unless _tmp
2284
+ set_failed_rule :_OrderedItem unless _tmp
1787
2285
  return _tmp
1788
2286
  end
1789
2287
 
1790
- # ordered_list = < ordered_item+:items > { create_item(:ol, nil, items, raw: text) }
1791
- def _ordered_list
2288
+ # DefinitionList = DefinitionItem+:items {definition_list([], [], [], items)}
2289
+ def _DefinitionList
1792
2290
 
1793
2291
  _save = self.pos
1794
2292
  while true # sequence
1795
- _text_start = self.pos
1796
2293
  _save1 = self.pos
1797
2294
  _ary = []
1798
- _tmp = apply(:_ordered_item)
2295
+ _tmp = apply(:_DefinitionItem)
1799
2296
  if _tmp
1800
2297
  _ary << @result
1801
2298
  while true
1802
- _tmp = apply(:_ordered_item)
2299
+ _tmp = apply(:_DefinitionItem)
1803
2300
  _ary << @result if _tmp
1804
2301
  break unless _tmp
1805
2302
  end
@@ -1809,14 +2306,11 @@ class NoraMark::Parser < KPeg::CompiledParser
1809
2306
  self.pos = _save1
1810
2307
  end
1811
2308
  items = @result
1812
- if _tmp
1813
- text = get_text(_text_start)
1814
- end
1815
2309
  unless _tmp
1816
2310
  self.pos = _save
1817
2311
  break
1818
2312
  end
1819
- @result = begin; create_item(:ol, nil, items, raw: text) ; end
2313
+ @result = begin; definition_list([], [], [], items); end
1820
2314
  _tmp = true
1821
2315
  unless _tmp
1822
2316
  self.pos = _save
@@ -1824,55 +2318,58 @@ class NoraMark::Parser < KPeg::CompiledParser
1824
2318
  break
1825
2319
  end # end sequence
1826
2320
 
1827
- set_failed_rule :_ordered_list unless _tmp
2321
+ set_failed_rule :_DefinitionList unless _tmp
1828
2322
  return _tmp
1829
2323
  end
1830
2324
 
1831
- # ordered_item = < lh num ":" documentcontent:content le > { create_item(:li, nil, content, raw: text) }
1832
- def _ordered_item
2325
+ # DefinitionItem = - ";:" - DocumentContentExcept(':'):term ":" - DocumentContent:definition Le {dl_item([], [], [term], definition)}
2326
+ def _DefinitionItem
1833
2327
 
1834
2328
  _save = self.pos
1835
2329
  while true # sequence
1836
- _text_start = self.pos
1837
-
1838
- _save1 = self.pos
1839
- while true # sequence
1840
- _tmp = apply(:_lh)
1841
- unless _tmp
1842
- self.pos = _save1
1843
- break
1844
- end
1845
- _tmp = apply(:_num)
1846
- unless _tmp
1847
- self.pos = _save1
1848
- break
1849
- end
1850
- _tmp = match_string(":")
1851
- unless _tmp
1852
- self.pos = _save1
1853
- break
1854
- end
1855
- _tmp = apply(:_documentcontent)
1856
- content = @result
1857
- unless _tmp
1858
- self.pos = _save1
1859
- break
1860
- end
1861
- _tmp = apply(:_le)
1862
- unless _tmp
1863
- self.pos = _save1
1864
- end
2330
+ _tmp = apply(:__hyphen_)
2331
+ unless _tmp
2332
+ self.pos = _save
2333
+ break
2334
+ end
2335
+ _tmp = match_string(";:")
2336
+ unless _tmp
2337
+ self.pos = _save
2338
+ break
2339
+ end
2340
+ _tmp = apply(:__hyphen_)
2341
+ unless _tmp
2342
+ self.pos = _save
1865
2343
  break
1866
- end # end sequence
1867
-
1868
- if _tmp
1869
- text = get_text(_text_start)
1870
2344
  end
2345
+ _tmp = apply_with_args(:_DocumentContentExcept, ':')
2346
+ term = @result
1871
2347
  unless _tmp
1872
2348
  self.pos = _save
1873
2349
  break
1874
2350
  end
1875
- @result = begin; create_item(:li, nil, content, raw: text) ; end
2351
+ _tmp = match_string(":")
2352
+ unless _tmp
2353
+ self.pos = _save
2354
+ break
2355
+ end
2356
+ _tmp = apply(:__hyphen_)
2357
+ unless _tmp
2358
+ self.pos = _save
2359
+ break
2360
+ end
2361
+ _tmp = apply(:_DocumentContent)
2362
+ definition = @result
2363
+ unless _tmp
2364
+ self.pos = _save
2365
+ break
2366
+ end
2367
+ _tmp = apply(:_Le)
2368
+ unless _tmp
2369
+ self.pos = _save
2370
+ break
2371
+ end
2372
+ @result = begin; dl_item([], [], [term], definition); end
1876
2373
  _tmp = true
1877
2374
  unless _tmp
1878
2375
  self.pos = _save
@@ -1880,23 +2377,22 @@ class NoraMark::Parser < KPeg::CompiledParser
1880
2377
  break
1881
2378
  end # end sequence
1882
2379
 
1883
- set_failed_rule :_ordered_item unless _tmp
2380
+ set_failed_rule :_DefinitionItem unless _tmp
1884
2381
  return _tmp
1885
2382
  end
1886
2383
 
1887
- # definition_list = < definition_item+:items > { create_item(:dl, nil, items, raw: text) }
1888
- def _definition_list
2384
+ # LongDefinitionList = LongDefinitionItem+:items {definition_list([], [], [], items)}
2385
+ def _LongDefinitionList
1889
2386
 
1890
2387
  _save = self.pos
1891
2388
  while true # sequence
1892
- _text_start = self.pos
1893
2389
  _save1 = self.pos
1894
2390
  _ary = []
1895
- _tmp = apply(:_definition_item)
2391
+ _tmp = apply(:_LongDefinitionItem)
1896
2392
  if _tmp
1897
2393
  _ary << @result
1898
2394
  while true
1899
- _tmp = apply(:_definition_item)
2395
+ _tmp = apply(:_LongDefinitionItem)
1900
2396
  _ary << @result if _tmp
1901
2397
  break unless _tmp
1902
2398
  end
@@ -1906,14 +2402,11 @@ class NoraMark::Parser < KPeg::CompiledParser
1906
2402
  self.pos = _save1
1907
2403
  end
1908
2404
  items = @result
1909
- if _tmp
1910
- text = get_text(_text_start)
1911
- end
1912
2405
  unless _tmp
1913
2406
  self.pos = _save
1914
2407
  break
1915
2408
  end
1916
- @result = begin; create_item(:dl, nil, items, raw: text) ; end
2409
+ @result = begin; definition_list([], [], [], items); end
1917
2410
  _tmp = true
1918
2411
  unless _tmp
1919
2412
  self.pos = _save
@@ -1921,71 +2414,73 @@ class NoraMark::Parser < KPeg::CompiledParser
1921
2414
  break
1922
2415
  end # end sequence
1923
2416
 
1924
- set_failed_rule :_definition_list unless _tmp
2417
+ set_failed_rule :_LongDefinitionList unless _tmp
1925
2418
  return _tmp
1926
2419
  end
1927
2420
 
1928
- # definition_item = < lh ";:" - documentcontent_except(':'):term ":" - documentcontent:definition le > { create_item(:dtdd, {:args => [term, definition]}, nil, raw: text) }
1929
- def _definition_item
2421
+ # LongDefinitionItem = - ";:" - DocumentContentExcept('{'):term "{" - Nl - BlockBody:definition - BlockEnd {dl_item([], [], [term], definition)}
2422
+ def _LongDefinitionItem
1930
2423
 
1931
2424
  _save = self.pos
1932
2425
  while true # sequence
1933
- _text_start = self.pos
1934
-
1935
- _save1 = self.pos
1936
- while true # sequence
1937
- _tmp = apply(:_lh)
1938
- unless _tmp
1939
- self.pos = _save1
1940
- break
1941
- end
1942
- _tmp = match_string(";:")
1943
- unless _tmp
1944
- self.pos = _save1
1945
- break
1946
- end
1947
- _tmp = apply(:__hyphen_)
1948
- unless _tmp
1949
- self.pos = _save1
1950
- break
1951
- end
1952
- _tmp = apply_with_args(:_documentcontent_except, ':')
1953
- term = @result
1954
- unless _tmp
1955
- self.pos = _save1
1956
- break
1957
- end
1958
- _tmp = match_string(":")
1959
- unless _tmp
1960
- self.pos = _save1
1961
- break
1962
- end
1963
- _tmp = apply(:__hyphen_)
1964
- unless _tmp
1965
- self.pos = _save1
1966
- break
1967
- end
1968
- _tmp = apply(:_documentcontent)
1969
- definition = @result
1970
- unless _tmp
1971
- self.pos = _save1
1972
- break
1973
- end
1974
- _tmp = apply(:_le)
1975
- unless _tmp
1976
- self.pos = _save1
1977
- end
2426
+ _tmp = apply(:__hyphen_)
2427
+ unless _tmp
2428
+ self.pos = _save
2429
+ break
2430
+ end
2431
+ _tmp = match_string(";:")
2432
+ unless _tmp
2433
+ self.pos = _save
2434
+ break
2435
+ end
2436
+ _tmp = apply(:__hyphen_)
2437
+ unless _tmp
2438
+ self.pos = _save
2439
+ break
2440
+ end
2441
+ _tmp = apply_with_args(:_DocumentContentExcept, '{')
2442
+ term = @result
2443
+ unless _tmp
2444
+ self.pos = _save
2445
+ break
2446
+ end
2447
+ _tmp = match_string("{")
2448
+ unless _tmp
2449
+ self.pos = _save
2450
+ break
2451
+ end
2452
+ _tmp = apply(:__hyphen_)
2453
+ unless _tmp
2454
+ self.pos = _save
2455
+ break
2456
+ end
2457
+ _tmp = apply(:_Nl)
2458
+ unless _tmp
2459
+ self.pos = _save
2460
+ break
2461
+ end
2462
+ _tmp = apply(:__hyphen_)
2463
+ unless _tmp
2464
+ self.pos = _save
2465
+ break
2466
+ end
2467
+ _tmp = apply(:_BlockBody)
2468
+ definition = @result
2469
+ unless _tmp
2470
+ self.pos = _save
2471
+ break
2472
+ end
2473
+ _tmp = apply(:__hyphen_)
2474
+ unless _tmp
2475
+ self.pos = _save
1978
2476
  break
1979
- end # end sequence
1980
-
1981
- if _tmp
1982
- text = get_text(_text_start)
1983
2477
  end
2478
+ _tmp = apply(:_BlockEnd)
1984
2479
  unless _tmp
1985
2480
  self.pos = _save
1986
2481
  break
1987
2482
  end
1988
- @result = begin; create_item(:dtdd, {:args => [term, definition]}, nil, raw: text) ; end
2483
+ @result = begin; dl_item([], [], [term], definition); end
1989
2484
  _tmp = true
1990
2485
  unless _tmp
1991
2486
  self.pos = _save
@@ -1993,110 +2488,100 @@ class NoraMark::Parser < KPeg::CompiledParser
1993
2488
  break
1994
2489
  end # end sequence
1995
2490
 
1996
- set_failed_rule :_definition_item unless _tmp
2491
+ set_failed_rule :_LongDefinitionItem unless _tmp
1997
2492
  return _tmp
1998
2493
  end
1999
2494
 
2000
- # items_list = (unordered_list | ordered_list | definition_list)
2001
- def _items_list
2495
+ # ItemsList = (UnorderedList | OrderedList | DefinitionList | LongDefinitionList)
2496
+ def _ItemsList
2002
2497
 
2003
2498
  _save = self.pos
2004
2499
  while true # choice
2005
- _tmp = apply(:_unordered_list)
2500
+ _tmp = apply(:_UnorderedList)
2501
+ break if _tmp
2502
+ self.pos = _save
2503
+ _tmp = apply(:_OrderedList)
2006
2504
  break if _tmp
2007
2505
  self.pos = _save
2008
- _tmp = apply(:_ordered_list)
2506
+ _tmp = apply(:_DefinitionList)
2009
2507
  break if _tmp
2010
2508
  self.pos = _save
2011
- _tmp = apply(:_definition_list)
2509
+ _tmp = apply(:_LongDefinitionList)
2012
2510
  break if _tmp
2013
2511
  self.pos = _save
2014
2512
  break
2015
2513
  end # end choice
2016
2514
 
2017
- set_failed_rule :_items_list unless _tmp
2515
+ set_failed_rule :_ItemsList unless _tmp
2018
2516
  return _tmp
2019
2517
  end
2020
2518
 
2021
- # line_command = < lh - !commandname_for_special_line_command command:c ":" documentcontent?:content - le empty_line* > { create_item(:line_command, c, content, raw: text) }
2022
- def _line_command
2519
+ # LineCommand = - !CommandNameForSpecialLineCommand Command:c ":" - DocumentContent?:content - Le EmptyLine* {line_command(c[:name], c[:ids], c[:classes], c[:args], content)}
2520
+ def _LineCommand
2023
2521
 
2024
2522
  _save = self.pos
2025
2523
  while true # sequence
2026
- _text_start = self.pos
2027
-
2524
+ _tmp = apply(:__hyphen_)
2525
+ unless _tmp
2526
+ self.pos = _save
2527
+ break
2528
+ end
2028
2529
  _save1 = self.pos
2029
- while true # sequence
2030
- _tmp = apply(:_lh)
2031
- unless _tmp
2032
- self.pos = _save1
2033
- break
2034
- end
2035
- _tmp = apply(:__hyphen_)
2036
- unless _tmp
2037
- self.pos = _save1
2038
- break
2039
- end
2040
- _save2 = self.pos
2041
- _tmp = apply(:_commandname_for_special_line_command)
2042
- _tmp = _tmp ? nil : true
2043
- self.pos = _save2
2044
- unless _tmp
2045
- self.pos = _save1
2046
- break
2047
- end
2048
- _tmp = apply(:_command)
2049
- c = @result
2050
- unless _tmp
2051
- self.pos = _save1
2052
- break
2053
- end
2054
- _tmp = match_string(":")
2055
- unless _tmp
2056
- self.pos = _save1
2057
- break
2058
- end
2059
- _save3 = self.pos
2060
- _tmp = apply(:_documentcontent)
2061
- @result = nil unless _tmp
2062
- unless _tmp
2063
- _tmp = true
2064
- self.pos = _save3
2065
- end
2066
- content = @result
2067
- unless _tmp
2068
- self.pos = _save1
2069
- break
2070
- end
2071
- _tmp = apply(:__hyphen_)
2072
- unless _tmp
2073
- self.pos = _save1
2074
- break
2075
- end
2076
- _tmp = apply(:_le)
2077
- unless _tmp
2078
- self.pos = _save1
2079
- break
2080
- end
2081
- while true
2082
- _tmp = apply(:_empty_line)
2083
- break unless _tmp
2084
- end
2530
+ _tmp = apply(:_CommandNameForSpecialLineCommand)
2531
+ _tmp = _tmp ? nil : true
2532
+ self.pos = _save1
2533
+ unless _tmp
2534
+ self.pos = _save
2535
+ break
2536
+ end
2537
+ _tmp = apply(:_Command)
2538
+ c = @result
2539
+ unless _tmp
2540
+ self.pos = _save
2541
+ break
2542
+ end
2543
+ _tmp = match_string(":")
2544
+ unless _tmp
2545
+ self.pos = _save
2546
+ break
2547
+ end
2548
+ _tmp = apply(:__hyphen_)
2549
+ unless _tmp
2550
+ self.pos = _save
2551
+ break
2552
+ end
2553
+ _save2 = self.pos
2554
+ _tmp = apply(:_DocumentContent)
2555
+ @result = nil unless _tmp
2556
+ unless _tmp
2085
2557
  _tmp = true
2086
- unless _tmp
2087
- self.pos = _save1
2088
- end
2558
+ self.pos = _save2
2559
+ end
2560
+ content = @result
2561
+ unless _tmp
2562
+ self.pos = _save
2089
2563
  break
2090
- end # end sequence
2091
-
2092
- if _tmp
2093
- text = get_text(_text_start)
2094
2564
  end
2565
+ _tmp = apply(:__hyphen_)
2566
+ unless _tmp
2567
+ self.pos = _save
2568
+ break
2569
+ end
2570
+ _tmp = apply(:_Le)
2571
+ unless _tmp
2572
+ self.pos = _save
2573
+ break
2574
+ end
2575
+ while true
2576
+ _tmp = apply(:_EmptyLine)
2577
+ break unless _tmp
2578
+ end
2579
+ _tmp = true
2095
2580
  unless _tmp
2096
2581
  self.pos = _save
2097
2582
  break
2098
2583
  end
2099
- @result = begin; create_item(:line_command, c, content, raw: text) ; end
2584
+ @result = begin; line_command(c[:name], c[:ids], c[:classes], c[:args], content); end
2100
2585
  _tmp = true
2101
2586
  unless _tmp
2102
2587
  self.pos = _save
@@ -2104,51 +2589,60 @@ class NoraMark::Parser < KPeg::CompiledParser
2104
2589
  break
2105
2590
  end # end sequence
2106
2591
 
2107
- set_failed_rule :_line_command unless _tmp
2592
+ set_failed_rule :_LineCommand unless _tmp
2108
2593
  return _tmp
2109
2594
  end
2110
2595
 
2111
- # line_block = (items_list | line_command)
2112
- def _line_block
2596
+ # LineBlock = (ItemsList | LineCommand)
2597
+ def _LineBlock
2113
2598
 
2114
2599
  _save = self.pos
2115
2600
  while true # choice
2116
- _tmp = apply(:_items_list)
2601
+ _tmp = apply(:_ItemsList)
2117
2602
  break if _tmp
2118
2603
  self.pos = _save
2119
- _tmp = apply(:_line_command)
2604
+ _tmp = apply(:_LineCommand)
2120
2605
  break if _tmp
2121
2606
  self.pos = _save
2122
2607
  break
2123
2608
  end # end choice
2124
2609
 
2125
- set_failed_rule :_line_block unless _tmp
2610
+ set_failed_rule :_LineBlock unless _tmp
2126
2611
  return _tmp
2127
2612
  end
2128
2613
 
2129
- # block = (preformatted_block | headed_section | line_block | explicit_block | paragraph_group):block empty_line* {block}
2130
- def _block
2614
+ # Block = EmptyLine* (PreformattedBlock | HeadedSection | LineBlock | ExplicitBlock | ParagraphGroup):block EmptyLine* {block}
2615
+ def _Block
2131
2616
 
2132
2617
  _save = self.pos
2133
2618
  while true # sequence
2619
+ while true
2620
+ _tmp = apply(:_EmptyLine)
2621
+ break unless _tmp
2622
+ end
2623
+ _tmp = true
2624
+ unless _tmp
2625
+ self.pos = _save
2626
+ break
2627
+ end
2134
2628
 
2135
- _save1 = self.pos
2629
+ _save2 = self.pos
2136
2630
  while true # choice
2137
- _tmp = apply(:_preformatted_block)
2631
+ _tmp = apply(:_PreformattedBlock)
2138
2632
  break if _tmp
2139
- self.pos = _save1
2140
- _tmp = apply(:_headed_section)
2633
+ self.pos = _save2
2634
+ _tmp = apply(:_HeadedSection)
2141
2635
  break if _tmp
2142
- self.pos = _save1
2143
- _tmp = apply(:_line_block)
2636
+ self.pos = _save2
2637
+ _tmp = apply(:_LineBlock)
2144
2638
  break if _tmp
2145
- self.pos = _save1
2146
- _tmp = apply(:_explicit_block)
2639
+ self.pos = _save2
2640
+ _tmp = apply(:_ExplicitBlock)
2147
2641
  break if _tmp
2148
- self.pos = _save1
2149
- _tmp = apply(:_paragraph_group)
2642
+ self.pos = _save2
2643
+ _tmp = apply(:_ParagraphGroup)
2150
2644
  break if _tmp
2151
- self.pos = _save1
2645
+ self.pos = _save2
2152
2646
  break
2153
2647
  end # end choice
2154
2648
 
@@ -2158,7 +2652,7 @@ class NoraMark::Parser < KPeg::CompiledParser
2158
2652
  break
2159
2653
  end
2160
2654
  while true
2161
- _tmp = apply(:_empty_line)
2655
+ _tmp = apply(:_EmptyLine)
2162
2656
  break unless _tmp
2163
2657
  end
2164
2658
  _tmp = true
@@ -2174,57 +2668,57 @@ class NoraMark::Parser < KPeg::CompiledParser
2174
2668
  break
2175
2669
  end # end sequence
2176
2670
 
2177
- set_failed_rule :_block unless _tmp
2671
+ set_failed_rule :_Block unless _tmp
2178
2672
  return _tmp
2179
2673
  end
2180
2674
 
2181
- # block_delimiter = (blockhead | blockend)
2182
- def _block_delimiter
2675
+ # BlockDelimiter = (BlockHead | BlockEnd)
2676
+ def _BlockDelimiter
2183
2677
 
2184
2678
  _save = self.pos
2185
2679
  while true # choice
2186
- _tmp = apply(:_blockhead)
2680
+ _tmp = apply(:_BlockHead)
2187
2681
  break if _tmp
2188
2682
  self.pos = _save
2189
- _tmp = apply(:_blockend)
2683
+ _tmp = apply(:_BlockEnd)
2190
2684
  break if _tmp
2191
2685
  self.pos = _save
2192
2686
  break
2193
2687
  end # end choice
2194
2688
 
2195
- set_failed_rule :_block_delimiter unless _tmp
2689
+ set_failed_rule :_BlockDelimiter unless _tmp
2196
2690
  return _tmp
2197
2691
  end
2198
2692
 
2199
- # paragraph_delimiter = (block_delimiter | preformatted_command_head | line_block | newpage | headed_start)
2200
- def _paragraph_delimiter
2693
+ # ParagraphDelimiter = (BlockDelimiter | PreformattedCommandHead | LineBlock | Newpage | HeadedStart)
2694
+ def _ParagraphDelimiter
2201
2695
 
2202
2696
  _save = self.pos
2203
2697
  while true # choice
2204
- _tmp = apply(:_block_delimiter)
2698
+ _tmp = apply(:_BlockDelimiter)
2205
2699
  break if _tmp
2206
2700
  self.pos = _save
2207
- _tmp = apply(:_preformatted_command_head)
2701
+ _tmp = apply(:_PreformattedCommandHead)
2208
2702
  break if _tmp
2209
2703
  self.pos = _save
2210
- _tmp = apply(:_line_block)
2704
+ _tmp = apply(:_LineBlock)
2211
2705
  break if _tmp
2212
2706
  self.pos = _save
2213
- _tmp = apply(:_newpage)
2707
+ _tmp = apply(:_Newpage)
2214
2708
  break if _tmp
2215
2709
  self.pos = _save
2216
- _tmp = apply(:_headed_start)
2710
+ _tmp = apply(:_HeadedStart)
2217
2711
  break if _tmp
2218
2712
  self.pos = _save
2219
2713
  break
2220
2714
  end # end choice
2221
2715
 
2222
- set_failed_rule :_paragraph_delimiter unless _tmp
2716
+ set_failed_rule :_ParagraphDelimiter unless _tmp
2223
2717
  return _tmp
2224
2718
  end
2225
2719
 
2226
- # h_start_mark = < "="+ ":" > &{ text.length - 1 == n }
2227
- def _h_start_mark(n)
2720
+ # HStartMark = < "="+ ":" > &{ text.length - 1 == n }
2721
+ def _HStartMark(n)
2228
2722
 
2229
2723
  _save = self.pos
2230
2724
  while true # sequence
@@ -2270,20 +2764,15 @@ class NoraMark::Parser < KPeg::CompiledParser
2270
2764
  break
2271
2765
  end # end sequence
2272
2766
 
2273
- set_failed_rule :_h_start_mark unless _tmp
2767
+ set_failed_rule :_HStartMark unless _tmp
2274
2768
  return _tmp
2275
2769
  end
2276
2770
 
2277
- # h_markup_terminator = lh - < "="+ ":" > &{ text.length - 1 <= n }
2278
- def _h_markup_terminator(n)
2771
+ # HMarkupTerminator = - < "="+ ":" > &{ text.length - 1 <= n }
2772
+ def _HMarkupTerminator(n)
2279
2773
 
2280
2774
  _save = self.pos
2281
2775
  while true # sequence
2282
- _tmp = apply(:_lh)
2283
- unless _tmp
2284
- self.pos = _save
2285
- break
2286
- end
2287
2776
  _tmp = apply(:__hyphen_)
2288
2777
  unless _tmp
2289
2778
  self.pos = _save
@@ -2331,37 +2820,37 @@ class NoraMark::Parser < KPeg::CompiledParser
2331
2820
  break
2332
2821
  end # end sequence
2333
2822
 
2334
- set_failed_rule :_h_markup_terminator unless _tmp
2823
+ set_failed_rule :_HMarkupTerminator unless _tmp
2335
2824
  return _tmp
2336
2825
  end
2337
2826
 
2338
- # h_start = lh - h_start_mark(n) charstring:s le { { level: n, heading: s } }
2339
- def _h_start(n)
2827
+ # HStart = - HStartMark(n) - DocumentContent:s Le { { level: n, heading: s } }
2828
+ def _HStart(n)
2340
2829
 
2341
2830
  _save = self.pos
2342
2831
  while true # sequence
2343
- _tmp = apply(:_lh)
2832
+ _tmp = apply(:__hyphen_)
2344
2833
  unless _tmp
2345
2834
  self.pos = _save
2346
2835
  break
2347
2836
  end
2348
- _tmp = apply(:__hyphen_)
2837
+ _tmp = apply_with_args(:_HStartMark, n)
2349
2838
  unless _tmp
2350
2839
  self.pos = _save
2351
2840
  break
2352
2841
  end
2353
- _tmp = apply_with_args(:_h_start_mark, n)
2842
+ _tmp = apply(:__hyphen_)
2354
2843
  unless _tmp
2355
2844
  self.pos = _save
2356
2845
  break
2357
2846
  end
2358
- _tmp = apply(:_charstring)
2847
+ _tmp = apply(:_DocumentContent)
2359
2848
  s = @result
2360
2849
  unless _tmp
2361
2850
  self.pos = _save
2362
2851
  break
2363
2852
  end
2364
- _tmp = apply(:_le)
2853
+ _tmp = apply(:_Le)
2365
2854
  unless _tmp
2366
2855
  self.pos = _save
2367
2856
  break
@@ -2374,105 +2863,60 @@ class NoraMark::Parser < KPeg::CompiledParser
2374
2863
  break
2375
2864
  end # end sequence
2376
2865
 
2377
- set_failed_rule :_h_start unless _tmp
2866
+ set_failed_rule :_HStart unless _tmp
2378
2867
  return _tmp
2379
2868
  end
2380
2869
 
2381
- # h_section = < h_start(n):h (!h_markup_terminator(n) !eof block)+:content > { create_item(:h_section, h, content, raw: text) }
2382
- def _h_section(n)
2870
+ # HSection = HStart(n):h (!HMarkupTerminator(n) !Eof Block)*:content {h_section(h[:level], h[:heading], content)}
2871
+ def _HSection(n)
2383
2872
 
2384
2873
  _save = self.pos
2385
2874
  while true # sequence
2386
- _text_start = self.pos
2875
+ _tmp = apply_with_args(:_HStart, n)
2876
+ h = @result
2877
+ unless _tmp
2878
+ self.pos = _save
2879
+ break
2880
+ end
2881
+ _ary = []
2882
+ while true
2387
2883
 
2388
- _save1 = self.pos
2389
- while true # sequence
2390
- _tmp = apply_with_args(:_h_start, n)
2391
- h = @result
2392
- unless _tmp
2393
- self.pos = _save1
2394
- break
2395
- end
2396
2884
  _save2 = self.pos
2397
- _ary = []
2398
-
2399
- _save3 = self.pos
2400
2885
  while true # sequence
2401
- _save4 = self.pos
2402
- _tmp = apply_with_args(:_h_markup_terminator, n)
2886
+ _save3 = self.pos
2887
+ _tmp = apply_with_args(:_HMarkupTerminator, n)
2403
2888
  _tmp = _tmp ? nil : true
2404
- self.pos = _save4
2889
+ self.pos = _save3
2405
2890
  unless _tmp
2406
- self.pos = _save3
2891
+ self.pos = _save2
2407
2892
  break
2408
2893
  end
2409
- _save5 = self.pos
2410
- _tmp = apply(:_eof)
2894
+ _save4 = self.pos
2895
+ _tmp = apply(:_Eof)
2411
2896
  _tmp = _tmp ? nil : true
2412
- self.pos = _save5
2897
+ self.pos = _save4
2413
2898
  unless _tmp
2414
- self.pos = _save3
2899
+ self.pos = _save2
2415
2900
  break
2416
2901
  end
2417
- _tmp = apply(:_block)
2902
+ _tmp = apply(:_Block)
2418
2903
  unless _tmp
2419
- self.pos = _save3
2904
+ self.pos = _save2
2420
2905
  end
2421
2906
  break
2422
2907
  end # end sequence
2423
2908
 
2424
- if _tmp
2425
- _ary << @result
2426
- while true
2427
-
2428
- _save6 = self.pos
2429
- while true # sequence
2430
- _save7 = self.pos
2431
- _tmp = apply_with_args(:_h_markup_terminator, n)
2432
- _tmp = _tmp ? nil : true
2433
- self.pos = _save7
2434
- unless _tmp
2435
- self.pos = _save6
2436
- break
2437
- end
2438
- _save8 = self.pos
2439
- _tmp = apply(:_eof)
2440
- _tmp = _tmp ? nil : true
2441
- self.pos = _save8
2442
- unless _tmp
2443
- self.pos = _save6
2444
- break
2445
- end
2446
- _tmp = apply(:_block)
2447
- unless _tmp
2448
- self.pos = _save6
2449
- end
2450
- break
2451
- end # end sequence
2452
-
2453
- _ary << @result if _tmp
2454
- break unless _tmp
2455
- end
2456
- _tmp = true
2457
- @result = _ary
2458
- else
2459
- self.pos = _save2
2460
- end
2461
- content = @result
2462
- unless _tmp
2463
- self.pos = _save1
2464
- end
2465
- break
2466
- end # end sequence
2467
-
2468
- if _tmp
2469
- text = get_text(_text_start)
2909
+ _ary << @result if _tmp
2910
+ break unless _tmp
2470
2911
  end
2912
+ _tmp = true
2913
+ @result = _ary
2914
+ content = @result
2471
2915
  unless _tmp
2472
2916
  self.pos = _save
2473
2917
  break
2474
2918
  end
2475
- @result = begin; create_item(:h_section, h, content, raw: text) ; end
2919
+ @result = begin; h_section(h[:level], h[:heading], content); end
2476
2920
  _tmp = true
2477
2921
  unless _tmp
2478
2922
  self.pos = _save
@@ -2480,370 +2924,203 @@ class NoraMark::Parser < KPeg::CompiledParser
2480
2924
  break
2481
2925
  end # end sequence
2482
2926
 
2483
- set_failed_rule :_h_section unless _tmp
2927
+ set_failed_rule :_HSection unless _tmp
2484
2928
  return _tmp
2485
2929
  end
2486
2930
 
2487
- # headed_start = (h_start(1) | h_start(2) | h_start(3) | h_start(4) | h_start(5) | h_start(6))
2488
- def _headed_start
2931
+ # HeadedStart = (HStart(1) | HStart(2) | HStart(3) | HStart(4) | HStart(5) | HStart(6))
2932
+ def _HeadedStart
2489
2933
 
2490
2934
  _save = self.pos
2491
2935
  while true # choice
2492
- _tmp = apply_with_args(:_h_start, 1)
2936
+ _tmp = apply_with_args(:_HStart, 1)
2493
2937
  break if _tmp
2494
2938
  self.pos = _save
2495
- _tmp = apply_with_args(:_h_start, 2)
2939
+ _tmp = apply_with_args(:_HStart, 2)
2496
2940
  break if _tmp
2497
2941
  self.pos = _save
2498
- _tmp = apply_with_args(:_h_start, 3)
2942
+ _tmp = apply_with_args(:_HStart, 3)
2499
2943
  break if _tmp
2500
2944
  self.pos = _save
2501
- _tmp = apply_with_args(:_h_start, 4)
2945
+ _tmp = apply_with_args(:_HStart, 4)
2502
2946
  break if _tmp
2503
2947
  self.pos = _save
2504
- _tmp = apply_with_args(:_h_start, 5)
2948
+ _tmp = apply_with_args(:_HStart, 5)
2505
2949
  break if _tmp
2506
2950
  self.pos = _save
2507
- _tmp = apply_with_args(:_h_start, 6)
2951
+ _tmp = apply_with_args(:_HStart, 6)
2508
2952
  break if _tmp
2509
2953
  self.pos = _save
2510
2954
  break
2511
2955
  end # end choice
2512
2956
 
2513
- set_failed_rule :_headed_start unless _tmp
2957
+ set_failed_rule :_HeadedStart unless _tmp
2514
2958
  return _tmp
2515
2959
  end
2516
2960
 
2517
- # headed_section = (h_section(1) | h_section(2) | h_section(3) | h_section(4) | h_section(5) | h_section(6))
2518
- def _headed_section
2961
+ # HeadedSection = (HSection(1) | HSection(2) | HSection(3) | HSection(4) | HSection(5) | HSection(6))
2962
+ def _HeadedSection
2519
2963
 
2520
2964
  _save = self.pos
2521
2965
  while true # choice
2522
- _tmp = apply_with_args(:_h_section, 1)
2966
+ _tmp = apply_with_args(:_HSection, 1)
2523
2967
  break if _tmp
2524
2968
  self.pos = _save
2525
- _tmp = apply_with_args(:_h_section, 2)
2969
+ _tmp = apply_with_args(:_HSection, 2)
2526
2970
  break if _tmp
2527
2971
  self.pos = _save
2528
- _tmp = apply_with_args(:_h_section, 3)
2972
+ _tmp = apply_with_args(:_HSection, 3)
2529
2973
  break if _tmp
2530
2974
  self.pos = _save
2531
- _tmp = apply_with_args(:_h_section, 4)
2975
+ _tmp = apply_with_args(:_HSection, 4)
2532
2976
  break if _tmp
2533
2977
  self.pos = _save
2534
- _tmp = apply_with_args(:_h_section, 5)
2978
+ _tmp = apply_with_args(:_HSection, 5)
2535
2979
  break if _tmp
2536
2980
  self.pos = _save
2537
- _tmp = apply_with_args(:_h_section, 6)
2981
+ _tmp = apply_with_args(:_HSection, 6)
2538
2982
  break if _tmp
2539
2983
  self.pos = _save
2540
2984
  break
2541
2985
  end # end choice
2542
2986
 
2543
- set_failed_rule :_headed_section unless _tmp
2987
+ set_failed_rule :_HeadedSection unless _tmp
2544
2988
  return _tmp
2545
2989
  end
2546
2990
 
2547
- # stylesheets = < lh - "stylesheets:" !le charstring:s nl > { create_item(:stylesheets, {:stylesheets => s.split(',').map(&:strip)}, nil, raw:text) }
2548
- def _stylesheets
2991
+ # FrontmatterSeparator = - "---" - Nl
2992
+ def _FrontmatterSeparator
2549
2993
 
2550
2994
  _save = self.pos
2551
2995
  while true # sequence
2552
- _text_start = self.pos
2553
-
2554
- _save1 = self.pos
2555
- while true # sequence
2556
- _tmp = apply(:_lh)
2557
- unless _tmp
2558
- self.pos = _save1
2559
- break
2560
- end
2561
- _tmp = apply(:__hyphen_)
2562
- unless _tmp
2563
- self.pos = _save1
2564
- break
2565
- end
2566
- _tmp = match_string("stylesheets:")
2567
- unless _tmp
2568
- self.pos = _save1
2569
- break
2570
- end
2571
- _save2 = self.pos
2572
- _tmp = apply(:_le)
2573
- _tmp = _tmp ? nil : true
2574
- self.pos = _save2
2575
- unless _tmp
2576
- self.pos = _save1
2577
- break
2578
- end
2579
- _tmp = apply(:_charstring)
2580
- s = @result
2581
- unless _tmp
2582
- self.pos = _save1
2583
- break
2584
- end
2585
- _tmp = apply(:_nl)
2586
- unless _tmp
2587
- self.pos = _save1
2588
- end
2589
- break
2590
- end # end sequence
2591
-
2592
- if _tmp
2593
- text = get_text(_text_start)
2594
- end
2996
+ _tmp = apply(:__hyphen_)
2595
2997
  unless _tmp
2596
2998
  self.pos = _save
2597
2999
  break
2598
3000
  end
2599
- @result = begin; create_item(:stylesheets, {:stylesheets => s.split(',').map(&:strip)}, nil, raw:text) ; end
2600
- _tmp = true
3001
+ _tmp = match_string("---")
2601
3002
  unless _tmp
2602
3003
  self.pos = _save
2603
- end
2604
- break
2605
- end # end sequence
2606
-
2607
- set_failed_rule :_stylesheets unless _tmp
2608
- return _tmp
2609
- end
2610
-
2611
- # title = < lh - "title:" !le charstring:t nl > { create_item(:title, {:title => t }, nil, raw:text) }
2612
- def _title
2613
-
2614
- _save = self.pos
2615
- while true # sequence
2616
- _text_start = self.pos
2617
-
2618
- _save1 = self.pos
2619
- while true # sequence
2620
- _tmp = apply(:_lh)
2621
- unless _tmp
2622
- self.pos = _save1
2623
- break
2624
- end
2625
- _tmp = apply(:__hyphen_)
2626
- unless _tmp
2627
- self.pos = _save1
2628
- break
2629
- end
2630
- _tmp = match_string("title:")
2631
- unless _tmp
2632
- self.pos = _save1
2633
- break
2634
- end
2635
- _save2 = self.pos
2636
- _tmp = apply(:_le)
2637
- _tmp = _tmp ? nil : true
2638
- self.pos = _save2
2639
- unless _tmp
2640
- self.pos = _save1
2641
- break
2642
- end
2643
- _tmp = apply(:_charstring)
2644
- t = @result
2645
- unless _tmp
2646
- self.pos = _save1
2647
- break
2648
- end
2649
- _tmp = apply(:_nl)
2650
- unless _tmp
2651
- self.pos = _save1
2652
- end
2653
3004
  break
2654
- end # end sequence
2655
-
2656
- if _tmp
2657
- text = get_text(_text_start)
2658
3005
  end
3006
+ _tmp = apply(:__hyphen_)
2659
3007
  unless _tmp
2660
3008
  self.pos = _save
2661
3009
  break
2662
3010
  end
2663
- @result = begin; create_item(:title, {:title => t }, nil, raw:text) ; end
2664
- _tmp = true
3011
+ _tmp = apply(:_Nl)
2665
3012
  unless _tmp
2666
3013
  self.pos = _save
2667
3014
  end
2668
3015
  break
2669
3016
  end # end sequence
2670
3017
 
2671
- set_failed_rule :_title unless _tmp
3018
+ set_failed_rule :_FrontmatterSeparator unless _tmp
2672
3019
  return _tmp
2673
3020
  end
2674
3021
 
2675
- # lang = < lh - "lang:" !le charstring:l nl > { create_item(:lang, {:lang => l }, nil, raw:text) }
2676
- def _lang
3022
+ # Frontmatter = FrontmatterSeparator (!FrontmatterSeparator CharString Nl)+:yaml FrontmatterSeparator EmptyLine* {frontmatter(yaml)}
3023
+ def _Frontmatter
2677
3024
 
2678
3025
  _save = self.pos
2679
3026
  while true # sequence
2680
- _text_start = self.pos
2681
-
2682
- _save1 = self.pos
2683
- while true # sequence
2684
- _tmp = apply(:_lh)
2685
- unless _tmp
2686
- self.pos = _save1
2687
- break
2688
- end
2689
- _tmp = apply(:__hyphen_)
2690
- unless _tmp
2691
- self.pos = _save1
2692
- break
2693
- end
2694
- _tmp = match_string("lang:")
2695
- unless _tmp
2696
- self.pos = _save1
2697
- break
2698
- end
2699
- _save2 = self.pos
2700
- _tmp = apply(:_le)
2701
- _tmp = _tmp ? nil : true
2702
- self.pos = _save2
2703
- unless _tmp
2704
- self.pos = _save1
2705
- break
2706
- end
2707
- _tmp = apply(:_charstring)
2708
- l = @result
2709
- unless _tmp
2710
- self.pos = _save1
2711
- break
2712
- end
2713
- _tmp = apply(:_nl)
2714
- unless _tmp
2715
- self.pos = _save1
2716
- end
2717
- break
2718
- end # end sequence
2719
-
2720
- if _tmp
2721
- text = get_text(_text_start)
2722
- end
3027
+ _tmp = apply(:_FrontmatterSeparator)
2723
3028
  unless _tmp
2724
3029
  self.pos = _save
2725
3030
  break
2726
3031
  end
2727
- @result = begin; create_item(:lang, {:lang => l }, nil, raw:text) ; end
2728
- _tmp = true
2729
- unless _tmp
2730
- self.pos = _save
2731
- end
2732
- break
2733
- end # end sequence
2734
-
2735
- set_failed_rule :_lang unless _tmp
2736
- return _tmp
2737
- end
2738
-
2739
- # paragraph_style = < lh - "paragraph-style:" !le charstring:l nl > { create_item(:paragraph_style, {:paragraph_style => l }, nil, raw:text) }
2740
- def _paragraph_style
2741
-
2742
- _save = self.pos
2743
- while true # sequence
2744
- _text_start = self.pos
2745
-
2746
3032
  _save1 = self.pos
3033
+ _ary = []
3034
+
3035
+ _save2 = self.pos
2747
3036
  while true # sequence
2748
- _tmp = apply(:_lh)
2749
- unless _tmp
2750
- self.pos = _save1
2751
- break
2752
- end
2753
- _tmp = apply(:__hyphen_)
2754
- unless _tmp
2755
- self.pos = _save1
2756
- break
2757
- end
2758
- _tmp = match_string("paragraph-style:")
2759
- unless _tmp
2760
- self.pos = _save1
2761
- break
2762
- end
2763
- _save2 = self.pos
2764
- _tmp = apply(:_le)
3037
+ _save3 = self.pos
3038
+ _tmp = apply(:_FrontmatterSeparator)
2765
3039
  _tmp = _tmp ? nil : true
2766
- self.pos = _save2
3040
+ self.pos = _save3
2767
3041
  unless _tmp
2768
- self.pos = _save1
3042
+ self.pos = _save2
2769
3043
  break
2770
3044
  end
2771
- _tmp = apply(:_charstring)
2772
- l = @result
3045
+ _tmp = apply(:_CharString)
2773
3046
  unless _tmp
2774
- self.pos = _save1
3047
+ self.pos = _save2
2775
3048
  break
2776
3049
  end
2777
- _tmp = apply(:_nl)
3050
+ _tmp = apply(:_Nl)
2778
3051
  unless _tmp
2779
- self.pos = _save1
3052
+ self.pos = _save2
2780
3053
  end
2781
3054
  break
2782
3055
  end # end sequence
2783
3056
 
2784
3057
  if _tmp
2785
- text = get_text(_text_start)
3058
+ _ary << @result
3059
+ while true
3060
+
3061
+ _save4 = self.pos
3062
+ while true # sequence
3063
+ _save5 = self.pos
3064
+ _tmp = apply(:_FrontmatterSeparator)
3065
+ _tmp = _tmp ? nil : true
3066
+ self.pos = _save5
3067
+ unless _tmp
3068
+ self.pos = _save4
3069
+ break
3070
+ end
3071
+ _tmp = apply(:_CharString)
3072
+ unless _tmp
3073
+ self.pos = _save4
3074
+ break
3075
+ end
3076
+ _tmp = apply(:_Nl)
3077
+ unless _tmp
3078
+ self.pos = _save4
3079
+ end
3080
+ break
3081
+ end # end sequence
3082
+
3083
+ _ary << @result if _tmp
3084
+ break unless _tmp
3085
+ end
3086
+ _tmp = true
3087
+ @result = _ary
3088
+ else
3089
+ self.pos = _save1
2786
3090
  end
3091
+ yaml = @result
2787
3092
  unless _tmp
2788
3093
  self.pos = _save
2789
3094
  break
2790
3095
  end
2791
- @result = begin; create_item(:paragraph_style, {:paragraph_style => l }, nil, raw:text) ; end
2792
- _tmp = true
2793
- unless _tmp
2794
- self.pos = _save
2795
- end
2796
- break
2797
- end # end sequence
2798
-
2799
- set_failed_rule :_paragraph_style unless _tmp
2800
- return _tmp
2801
- end
2802
-
2803
- # header = (stylesheets | title | lang | paragraph_style) empty_line*
2804
- def _header
2805
-
2806
- _save = self.pos
2807
- while true # sequence
2808
-
2809
- _save1 = self.pos
2810
- while true # choice
2811
- _tmp = apply(:_stylesheets)
2812
- break if _tmp
2813
- self.pos = _save1
2814
- _tmp = apply(:_title)
2815
- break if _tmp
2816
- self.pos = _save1
2817
- _tmp = apply(:_lang)
2818
- break if _tmp
2819
- self.pos = _save1
2820
- _tmp = apply(:_paragraph_style)
2821
- break if _tmp
2822
- self.pos = _save1
2823
- break
2824
- end # end choice
2825
-
3096
+ _tmp = apply(:_FrontmatterSeparator)
2826
3097
  unless _tmp
2827
3098
  self.pos = _save
2828
3099
  break
2829
3100
  end
2830
3101
  while true
2831
- _tmp = apply(:_empty_line)
3102
+ _tmp = apply(:_EmptyLine)
2832
3103
  break unless _tmp
2833
3104
  end
2834
3105
  _tmp = true
3106
+ unless _tmp
3107
+ self.pos = _save
3108
+ break
3109
+ end
3110
+ @result = begin; frontmatter(yaml); end
3111
+ _tmp = true
2835
3112
  unless _tmp
2836
3113
  self.pos = _save
2837
3114
  end
2838
3115
  break
2839
3116
  end # end sequence
2840
3117
 
2841
- set_failed_rule :_header unless _tmp
3118
+ set_failed_rule :_Frontmatter unless _tmp
2842
3119
  return _tmp
2843
3120
  end
2844
3121
 
2845
- # char = < /[[:print:]]/ > { text }
2846
- def _char
3122
+ # Char = < /[[:print:]]/ > { text }
3123
+ def _Char
2847
3124
 
2848
3125
  _save = self.pos
2849
3126
  while true # sequence
@@ -2864,18 +3141,18 @@ class NoraMark::Parser < KPeg::CompiledParser
2864
3141
  break
2865
3142
  end # end sequence
2866
3143
 
2867
- set_failed_rule :_char unless _tmp
3144
+ set_failed_rule :_Char unless _tmp
2868
3145
  return _tmp
2869
3146
  end
2870
3147
 
2871
- # charstring = < char* > { text }
2872
- def _charstring
3148
+ # CharString = < Char* > { text }
3149
+ def _CharString
2873
3150
 
2874
3151
  _save = self.pos
2875
3152
  while true # sequence
2876
3153
  _text_start = self.pos
2877
3154
  while true
2878
- _tmp = apply(:_char)
3155
+ _tmp = apply(:_Char)
2879
3156
  break unless _tmp
2880
3157
  end
2881
3158
  _tmp = true
@@ -2894,16 +3171,16 @@ class NoraMark::Parser < KPeg::CompiledParser
2894
3171
  break
2895
3172
  end # end sequence
2896
3173
 
2897
- set_failed_rule :_charstring unless _tmp
3174
+ set_failed_rule :_CharString unless _tmp
2898
3175
  return _tmp
2899
3176
  end
2900
3177
 
2901
- # char_except = char:c &{ c != e }
2902
- def _char_except(e)
3178
+ # CharExcept = Char:c &{ c != e }
3179
+ def _CharExcept(e)
2903
3180
 
2904
3181
  _save = self.pos
2905
3182
  while true # sequence
2906
- _tmp = apply(:_char)
3183
+ _tmp = apply(:_Char)
2907
3184
  c = @result
2908
3185
  unless _tmp
2909
3186
  self.pos = _save
@@ -2918,21 +3195,61 @@ class NoraMark::Parser < KPeg::CompiledParser
2918
3195
  break
2919
3196
  end # end sequence
2920
3197
 
2921
- set_failed_rule :_char_except unless _tmp
3198
+ set_failed_rule :_CharExcept unless _tmp
2922
3199
  return _tmp
2923
3200
  end
2924
3201
 
2925
- # charstring_except = < char_except(e)* > { text }
2926
- def _charstring_except(e)
3202
+ # DocumentTextExcept = < (!Inline CharExcept(e))+ > {text(text)}
3203
+ def _DocumentTextExcept(e)
2927
3204
 
2928
3205
  _save = self.pos
2929
3206
  while true # sequence
2930
3207
  _text_start = self.pos
2931
- while true
2932
- _tmp = apply_with_args(:_char_except, e)
2933
- break unless _tmp
3208
+ _save1 = self.pos
3209
+
3210
+ _save2 = self.pos
3211
+ while true # sequence
3212
+ _save3 = self.pos
3213
+ _tmp = apply(:_Inline)
3214
+ _tmp = _tmp ? nil : true
3215
+ self.pos = _save3
3216
+ unless _tmp
3217
+ self.pos = _save2
3218
+ break
3219
+ end
3220
+ _tmp = apply_with_args(:_CharExcept, e)
3221
+ unless _tmp
3222
+ self.pos = _save2
3223
+ end
3224
+ break
3225
+ end # end sequence
3226
+
3227
+ if _tmp
3228
+ while true
3229
+
3230
+ _save4 = self.pos
3231
+ while true # sequence
3232
+ _save5 = self.pos
3233
+ _tmp = apply(:_Inline)
3234
+ _tmp = _tmp ? nil : true
3235
+ self.pos = _save5
3236
+ unless _tmp
3237
+ self.pos = _save4
3238
+ break
3239
+ end
3240
+ _tmp = apply_with_args(:_CharExcept, e)
3241
+ unless _tmp
3242
+ self.pos = _save4
3243
+ end
3244
+ break
3245
+ end # end sequence
3246
+
3247
+ break unless _tmp
3248
+ end
3249
+ _tmp = true
3250
+ else
3251
+ self.pos = _save1
2934
3252
  end
2935
- _tmp = true
2936
3253
  if _tmp
2937
3254
  text = get_text(_text_start)
2938
3255
  end
@@ -2940,7 +3257,7 @@ class NoraMark::Parser < KPeg::CompiledParser
2940
3257
  self.pos = _save
2941
3258
  break
2942
3259
  end
2943
- @result = begin; text ; end
3260
+ @result = begin; text(text); end
2944
3261
  _tmp = true
2945
3262
  unless _tmp
2946
3263
  self.pos = _save
@@ -2948,12 +3265,12 @@ class NoraMark::Parser < KPeg::CompiledParser
2948
3265
  break
2949
3266
  end # end sequence
2950
3267
 
2951
- set_failed_rule :_charstring_except unless _tmp
3268
+ set_failed_rule :_DocumentTextExcept unless _tmp
2952
3269
  return _tmp
2953
3270
  end
2954
3271
 
2955
- # documentcontent_except = (inline | !inline char_except(e))+:content {parse_text(content)}
2956
- def _documentcontent_except(e)
3272
+ # DocumentContentExcept = (Inline | DocumentTextExcept(e))+:content { content }
3273
+ def _DocumentContentExcept(e)
2957
3274
 
2958
3275
  _save = self.pos
2959
3276
  while true # sequence
@@ -2962,27 +3279,10 @@ class NoraMark::Parser < KPeg::CompiledParser
2962
3279
 
2963
3280
  _save2 = self.pos
2964
3281
  while true # choice
2965
- _tmp = apply(:_inline)
3282
+ _tmp = apply(:_Inline)
2966
3283
  break if _tmp
2967
3284
  self.pos = _save2
2968
-
2969
- _save3 = self.pos
2970
- while true # sequence
2971
- _save4 = self.pos
2972
- _tmp = apply(:_inline)
2973
- _tmp = _tmp ? nil : true
2974
- self.pos = _save4
2975
- unless _tmp
2976
- self.pos = _save3
2977
- break
2978
- end
2979
- _tmp = apply_with_args(:_char_except, e)
2980
- unless _tmp
2981
- self.pos = _save3
2982
- end
2983
- break
2984
- end # end sequence
2985
-
3285
+ _tmp = apply_with_args(:_DocumentTextExcept, e)
2986
3286
  break if _tmp
2987
3287
  self.pos = _save2
2988
3288
  break
@@ -2992,31 +3292,14 @@ class NoraMark::Parser < KPeg::CompiledParser
2992
3292
  _ary << @result
2993
3293
  while true
2994
3294
 
2995
- _save5 = self.pos
3295
+ _save3 = self.pos
2996
3296
  while true # choice
2997
- _tmp = apply(:_inline)
3297
+ _tmp = apply(:_Inline)
2998
3298
  break if _tmp
2999
- self.pos = _save5
3000
-
3001
- _save6 = self.pos
3002
- while true # sequence
3003
- _save7 = self.pos
3004
- _tmp = apply(:_inline)
3005
- _tmp = _tmp ? nil : true
3006
- self.pos = _save7
3007
- unless _tmp
3008
- self.pos = _save6
3009
- break
3010
- end
3011
- _tmp = apply_with_args(:_char_except, e)
3012
- unless _tmp
3013
- self.pos = _save6
3014
- end
3015
- break
3016
- end # end sequence
3017
-
3299
+ self.pos = _save3
3300
+ _tmp = apply_with_args(:_DocumentTextExcept, e)
3018
3301
  break if _tmp
3019
- self.pos = _save5
3302
+ self.pos = _save3
3020
3303
  break
3021
3304
  end # end choice
3022
3305
 
@@ -3033,7 +3316,7 @@ class NoraMark::Parser < KPeg::CompiledParser
3033
3316
  self.pos = _save
3034
3317
  break
3035
3318
  end
3036
- @result = begin; parse_text(content); end
3319
+ @result = begin; content ; end
3037
3320
  _tmp = true
3038
3321
  unless _tmp
3039
3322
  self.pos = _save
@@ -3041,92 +3324,69 @@ class NoraMark::Parser < KPeg::CompiledParser
3041
3324
  break
3042
3325
  end # end sequence
3043
3326
 
3044
- set_failed_rule :_documentcontent_except unless _tmp
3327
+ set_failed_rule :_DocumentContentExcept unless _tmp
3045
3328
  return _tmp
3046
3329
  end
3047
3330
 
3048
- # documentcontent = (inline | !inline char)+:content {parse_text(content)}
3049
- def _documentcontent
3331
+ # DocumentText = < (!Inline Char)+ > {text(text)}
3332
+ def _DocumentText
3050
3333
 
3051
3334
  _save = self.pos
3052
3335
  while true # sequence
3336
+ _text_start = self.pos
3053
3337
  _save1 = self.pos
3054
- _ary = []
3055
3338
 
3056
3339
  _save2 = self.pos
3057
- while true # choice
3058
- _tmp = apply(:_inline)
3059
- break if _tmp
3060
- self.pos = _save2
3061
-
3340
+ while true # sequence
3062
3341
  _save3 = self.pos
3063
- while true # sequence
3064
- _save4 = self.pos
3065
- _tmp = apply(:_inline)
3066
- _tmp = _tmp ? nil : true
3067
- self.pos = _save4
3068
- unless _tmp
3069
- self.pos = _save3
3070
- break
3071
- end
3072
- _tmp = apply(:_char)
3073
- unless _tmp
3074
- self.pos = _save3
3075
- end
3342
+ _tmp = apply(:_Inline)
3343
+ _tmp = _tmp ? nil : true
3344
+ self.pos = _save3
3345
+ unless _tmp
3346
+ self.pos = _save2
3076
3347
  break
3077
- end # end sequence
3078
-
3079
- break if _tmp
3080
- self.pos = _save2
3348
+ end
3349
+ _tmp = apply(:_Char)
3350
+ unless _tmp
3351
+ self.pos = _save2
3352
+ end
3081
3353
  break
3082
- end # end choice
3354
+ end # end sequence
3083
3355
 
3084
3356
  if _tmp
3085
- _ary << @result
3086
3357
  while true
3087
3358
 
3088
- _save5 = self.pos
3089
- while true # choice
3090
- _tmp = apply(:_inline)
3091
- break if _tmp
3359
+ _save4 = self.pos
3360
+ while true # sequence
3361
+ _save5 = self.pos
3362
+ _tmp = apply(:_Inline)
3363
+ _tmp = _tmp ? nil : true
3092
3364
  self.pos = _save5
3093
-
3094
- _save6 = self.pos
3095
- while true # sequence
3096
- _save7 = self.pos
3097
- _tmp = apply(:_inline)
3098
- _tmp = _tmp ? nil : true
3099
- self.pos = _save7
3100
- unless _tmp
3101
- self.pos = _save6
3102
- break
3103
- end
3104
- _tmp = apply(:_char)
3105
- unless _tmp
3106
- self.pos = _save6
3107
- end
3365
+ unless _tmp
3366
+ self.pos = _save4
3108
3367
  break
3109
- end # end sequence
3110
-
3111
- break if _tmp
3112
- self.pos = _save5
3368
+ end
3369
+ _tmp = apply(:_Char)
3370
+ unless _tmp
3371
+ self.pos = _save4
3372
+ end
3113
3373
  break
3114
- end # end choice
3374
+ end # end sequence
3115
3375
 
3116
- _ary << @result if _tmp
3117
3376
  break unless _tmp
3118
3377
  end
3119
3378
  _tmp = true
3120
- @result = _ary
3121
3379
  else
3122
3380
  self.pos = _save1
3123
3381
  end
3124
- content = @result
3382
+ if _tmp
3383
+ text = get_text(_text_start)
3384
+ end
3125
3385
  unless _tmp
3126
3386
  self.pos = _save
3127
3387
  break
3128
3388
  end
3129
- @result = begin; parse_text(content); end
3389
+ @result = begin; text(text); end
3130
3390
  _tmp = true
3131
3391
  unless _tmp
3132
3392
  self.pos = _save
@@ -3134,31 +3394,57 @@ class NoraMark::Parser < KPeg::CompiledParser
3134
3394
  break
3135
3395
  end # end sequence
3136
3396
 
3137
- set_failed_rule :_documentcontent unless _tmp
3397
+ set_failed_rule :_DocumentText unless _tmp
3138
3398
  return _tmp
3139
3399
  end
3140
3400
 
3141
- # documentline = lh documentcontent:content le { content }
3142
- def _documentline
3401
+ # DocumentContent = (Inline | DocumentText)+:content { content }
3402
+ def _DocumentContent
3143
3403
 
3144
3404
  _save = self.pos
3145
3405
  while true # sequence
3146
- _tmp = apply(:_lh)
3147
- unless _tmp
3148
- self.pos = _save
3406
+ _save1 = self.pos
3407
+ _ary = []
3408
+
3409
+ _save2 = self.pos
3410
+ while true # choice
3411
+ _tmp = apply(:_Inline)
3412
+ break if _tmp
3413
+ self.pos = _save2
3414
+ _tmp = apply(:_DocumentText)
3415
+ break if _tmp
3416
+ self.pos = _save2
3149
3417
  break
3418
+ end # end choice
3419
+
3420
+ if _tmp
3421
+ _ary << @result
3422
+ while true
3423
+
3424
+ _save3 = self.pos
3425
+ while true # choice
3426
+ _tmp = apply(:_Inline)
3427
+ break if _tmp
3428
+ self.pos = _save3
3429
+ _tmp = apply(:_DocumentText)
3430
+ break if _tmp
3431
+ self.pos = _save3
3432
+ break
3433
+ end # end choice
3434
+
3435
+ _ary << @result if _tmp
3436
+ break unless _tmp
3437
+ end
3438
+ _tmp = true
3439
+ @result = _ary
3440
+ else
3441
+ self.pos = _save1
3150
3442
  end
3151
- _tmp = apply(:_documentcontent)
3152
3443
  content = @result
3153
3444
  unless _tmp
3154
3445
  self.pos = _save
3155
3446
  break
3156
3447
  end
3157
- _tmp = apply(:_le)
3158
- unless _tmp
3159
- self.pos = _save
3160
- break
3161
- end
3162
3448
  @result = begin; content ; end
3163
3449
  _tmp = true
3164
3450
  unless _tmp
@@ -3167,29 +3453,27 @@ class NoraMark::Parser < KPeg::CompiledParser
3167
3453
  break
3168
3454
  end # end sequence
3169
3455
 
3170
- set_failed_rule :_documentline unless _tmp
3456
+ set_failed_rule :_DocumentContent unless _tmp
3171
3457
  return _tmp
3172
3458
  end
3173
3459
 
3174
- # headers = header*:headers { create_item(:headers, nil, headers) }
3175
- def _headers
3460
+ # DocumentLine = DocumentContent:content Le { content }
3461
+ def _DocumentLine
3176
3462
 
3177
3463
  _save = self.pos
3178
3464
  while true # sequence
3179
- _ary = []
3180
- while true
3181
- _tmp = apply(:_header)
3182
- _ary << @result if _tmp
3183
- break unless _tmp
3465
+ _tmp = apply(:_DocumentContent)
3466
+ content = @result
3467
+ unless _tmp
3468
+ self.pos = _save
3469
+ break
3184
3470
  end
3185
- _tmp = true
3186
- @result = _ary
3187
- headers = @result
3471
+ _tmp = apply(:_Le)
3188
3472
  unless _tmp
3189
3473
  self.pos = _save
3190
3474
  break
3191
3475
  end
3192
- @result = begin; create_item(:headers, nil, headers) ; end
3476
+ @result = begin; content ; end
3193
3477
  _tmp = true
3194
3478
  unless _tmp
3195
3479
  self.pos = _save
@@ -3197,17 +3481,23 @@ class NoraMark::Parser < KPeg::CompiledParser
3197
3481
  break
3198
3482
  end # end sequence
3199
3483
 
3200
- set_failed_rule :_headers unless _tmp
3484
+ set_failed_rule :_DocumentLine unless _tmp
3201
3485
  return _tmp
3202
3486
  end
3203
3487
 
3204
- # page = headers:headers - (!newpage block)*:blocks { create_item(:page, nil, [headers] + blocks.select{ |x| !x.nil?}) }
3205
- def _page
3488
+ # Page = Frontmatter?:frontmatter - (!Newpage Block)*:blocks {page(([frontmatter] + blocks).select{ |x| !x.nil?})}
3489
+ def _Page
3206
3490
 
3207
3491
  _save = self.pos
3208
3492
  while true # sequence
3209
- _tmp = apply(:_headers)
3210
- headers = @result
3493
+ _save1 = self.pos
3494
+ _tmp = apply(:_Frontmatter)
3495
+ @result = nil unless _tmp
3496
+ unless _tmp
3497
+ _tmp = true
3498
+ self.pos = _save1
3499
+ end
3500
+ frontmatter = @result
3211
3501
  unless _tmp
3212
3502
  self.pos = _save
3213
3503
  break
@@ -3220,19 +3510,19 @@ class NoraMark::Parser < KPeg::CompiledParser
3220
3510
  _ary = []
3221
3511
  while true
3222
3512
 
3223
- _save2 = self.pos
3513
+ _save3 = self.pos
3224
3514
  while true # sequence
3225
- _save3 = self.pos
3226
- _tmp = apply(:_newpage)
3515
+ _save4 = self.pos
3516
+ _tmp = apply(:_Newpage)
3227
3517
  _tmp = _tmp ? nil : true
3228
- self.pos = _save3
3518
+ self.pos = _save4
3229
3519
  unless _tmp
3230
- self.pos = _save2
3520
+ self.pos = _save3
3231
3521
  break
3232
3522
  end
3233
- _tmp = apply(:_block)
3523
+ _tmp = apply(:_Block)
3234
3524
  unless _tmp
3235
- self.pos = _save2
3525
+ self.pos = _save3
3236
3526
  end
3237
3527
  break
3238
3528
  end # end sequence
@@ -3247,7 +3537,7 @@ class NoraMark::Parser < KPeg::CompiledParser
3247
3537
  self.pos = _save
3248
3538
  break
3249
3539
  end
3250
- @result = begin; create_item(:page, nil, [headers] + blocks.select{ |x| !x.nil?}) ; end
3540
+ @result = begin; page(([frontmatter] + blocks).select{ |x| !x.nil?}); end
3251
3541
  _tmp = true
3252
3542
  unless _tmp
3253
3543
  self.pos = _save
@@ -3255,28 +3545,28 @@ class NoraMark::Parser < KPeg::CompiledParser
3255
3545
  break
3256
3546
  end # end sequence
3257
3547
 
3258
- set_failed_rule :_page unless _tmp
3548
+ set_failed_rule :_Page unless _tmp
3259
3549
  return _tmp
3260
3550
  end
3261
3551
 
3262
- # newpaged_page = newpage:newpage page:page { page[:children] = page[:children].unshift newpage; page }
3263
- def _newpaged_page
3552
+ # NewpagedPage = Newpage:newpage Page:page { page.content = page.content.unshift newpage; page }
3553
+ def _NewpagedPage
3264
3554
 
3265
3555
  _save = self.pos
3266
3556
  while true # sequence
3267
- _tmp = apply(:_newpage)
3557
+ _tmp = apply(:_Newpage)
3268
3558
  newpage = @result
3269
3559
  unless _tmp
3270
3560
  self.pos = _save
3271
3561
  break
3272
3562
  end
3273
- _tmp = apply(:_page)
3563
+ _tmp = apply(:_Page)
3274
3564
  page = @result
3275
3565
  unless _tmp
3276
3566
  self.pos = _save
3277
3567
  break
3278
3568
  end
3279
- @result = begin; page[:children] = page[:children].unshift newpage; page ; end
3569
+ @result = begin; page.content = page.content.unshift newpage; page ; end
3280
3570
  _tmp = true
3281
3571
  unless _tmp
3282
3572
  self.pos = _save
@@ -3284,16 +3574,16 @@ class NoraMark::Parser < KPeg::CompiledParser
3284
3574
  break
3285
3575
  end # end sequence
3286
3576
 
3287
- set_failed_rule :_newpaged_page unless _tmp
3577
+ set_failed_rule :_NewpagedPage unless _tmp
3288
3578
  return _tmp
3289
3579
  end
3290
3580
 
3291
- # root = page:page newpaged_page*:pages - eof_comment? eof { [ page ] + pages }
3581
+ # root = Page:page NewpagedPage*:pages - EofComment? Eof { [ page ] + pages }
3292
3582
  def _root
3293
3583
 
3294
3584
  _save = self.pos
3295
3585
  while true # sequence
3296
- _tmp = apply(:_page)
3586
+ _tmp = apply(:_Page)
3297
3587
  page = @result
3298
3588
  unless _tmp
3299
3589
  self.pos = _save
@@ -3301,7 +3591,7 @@ class NoraMark::Parser < KPeg::CompiledParser
3301
3591
  end
3302
3592
  _ary = []
3303
3593
  while true
3304
- _tmp = apply(:_newpaged_page)
3594
+ _tmp = apply(:_NewpagedPage)
3305
3595
  _ary << @result if _tmp
3306
3596
  break unless _tmp
3307
3597
  end
@@ -3318,7 +3608,7 @@ class NoraMark::Parser < KPeg::CompiledParser
3318
3608
  break
3319
3609
  end
3320
3610
  _save2 = self.pos
3321
- _tmp = apply(:_eof_comment)
3611
+ _tmp = apply(:_EofComment)
3322
3612
  unless _tmp
3323
3613
  _tmp = true
3324
3614
  self.pos = _save2
@@ -3327,7 +3617,7 @@ class NoraMark::Parser < KPeg::CompiledParser
3327
3617
  self.pos = _save
3328
3618
  break
3329
3619
  end
3330
- _tmp = apply(:_eof)
3620
+ _tmp = apply(:_Eof)
3331
3621
  unless _tmp
3332
3622
  self.pos = _save
3333
3623
  break
@@ -3345,78 +3635,84 @@ class NoraMark::Parser < KPeg::CompiledParser
3345
3635
  end
3346
3636
 
3347
3637
  Rules = {}
3348
- Rules[:_eof] = rule_info("eof", "!.")
3349
- Rules[:_space] = rule_info("space", "(\" \" | \"\\\\t\")")
3350
- Rules[:_eof_comment] = rule_info("eof_comment", "lh space* \"\#\" (!eof .)*")
3351
- Rules[:_comment] = rule_info("comment", "lh space* \"\#\" (!nl .)* nl empty_line*")
3352
- Rules[:__hyphen_] = rule_info("-", "(space | comment)*")
3353
- Rules[:_empty_line] = rule_info("empty_line", "lh - nl")
3354
- Rules[:_nl] = rule_info("nl", "/\\r?\\n/")
3355
- Rules[:_lh] = rule_info("lh", "/^/")
3356
- Rules[:_le] = rule_info("le", "(nl | eof)")
3357
- Rules[:_word] = rule_info("word", "< /[\\w0-9]/ (\"-\" | /[\\w0-9]/)* > { text }")
3358
- Rules[:_num] = rule_info("num", "< [0-9]+ > { text.to_i }")
3359
- Rules[:_classname] = rule_info("classname", "\".\" word:classname { classname }")
3360
- Rules[:_classnames] = rule_info("classnames", "classname*:classnames { classnames }")
3361
- Rules[:_idname] = rule_info("idname", "\"\#\" word:idname { idname }")
3362
- Rules[:_idnames] = rule_info("idnames", "idname*:idnames { idnames }")
3363
- Rules[:_commandname] = rule_info("commandname", "word:name idnames?:idnames classnames?:classes { {:name => name, :ids => idnames, :classes => classes} }")
3364
- Rules[:_parameter] = rule_info("parameter", "< (/[^,)]/* | \"\\\"\" /[^\"]/* \"\\\"\" | \"'\" /[^']/* \"'\") > { text }")
3365
- Rules[:_parameters] = rule_info("parameters", "< parameter (\",\" parameter)* > { text }")
3366
- Rules[:_command] = rule_info("command", "commandname:cn (\"(\" - parameters:arg - \")\")? { arg ||= ''; cn.merge({ :args => arg.split(',') }) }")
3367
- Rules[:_implicit_paragraph] = rule_info("implicit_paragraph", "< !paragraph_delimiter - documentline:p - > { create_item(:paragraph, nil, p, raw: text) }")
3368
- Rules[:_paragraph] = rule_info("paragraph", "(explicit_paragraph | implicit_paragraph)")
3369
- Rules[:_paragraph_group] = rule_info("paragraph_group", "< paragraph+:p empty_line* > { create_item(:paragraph_group, nil, p, raw: text) }")
3370
- Rules[:_blockhead] = rule_info("blockhead", "lh - command:command - \"{\" - nl empty_line* { command }")
3371
- Rules[:_blockend] = rule_info("blockend", "lh - \"}\" - le empty_line*")
3372
- Rules[:_blockbody] = rule_info("blockbody", "(!blockend block)+:body { body }")
3373
- Rules[:_explicit_block] = rule_info("explicit_block", "< blockhead:head - blockbody:body - blockend > { create_item(:block, head, body, raw: text) }")
3374
- Rules[:_preformatted_command] = rule_info("preformatted_command", "command:command &{ ['pre', 'precode'].include? command[:name] }")
3375
- Rules[:_preformatted_command_head] = rule_info("preformatted_command_head", "lh - preformatted_command:command - \"<<\" &/[\\w0-9]/ { command }")
3376
- Rules[:_preformat_end] = rule_info("preformat_end", "lh word:delimiter &{ delimiter == start }")
3377
- Rules[:_preformatted_block] = rule_info("preformatted_block", "< lh - preformatted_command_head:command !nl word:delimiter nl (!preformat_end(delimiter) lh charstring nl)+:content preformat_end(delimiter) > { create_item(:preformatted, command, content, raw: text) }")
3378
- Rules[:_inline] = rule_info("inline", "(img_inline | common_inline)")
3379
- Rules[:_common_inline] = rule_info("common_inline", "< \"[\" command:c \"{\" documentcontent_except('}'):content \"}\" \"]\" > { create_item(:inline, c, content, raw: text) }")
3380
- Rules[:_img_command] = rule_info("img_command", "command:c &{ c[:name] == 'img' && c[:args].size == 2}")
3381
- Rules[:_img_inline] = rule_info("img_inline", "< \"[\" img_command:c \"]\" > { create_item(:inline, c, nil, raw: text) }")
3382
- Rules[:_commandname_for_special_line_command] = rule_info("commandname_for_special_line_command", "(newpage_command | explicit_paragraph_command)")
3383
- Rules[:_newpage_command] = rule_info("newpage_command", "command:command &{ command[:name] == 'newpage' }")
3384
- Rules[:_newpage] = rule_info("newpage", "< lh - newpage_command:c \":\" documentcontent?:content - nl > { create_item(:newpage, c, content, raw:text) }")
3385
- Rules[:_explicit_paragraph_command] = rule_info("explicit_paragraph_command", "command:c &{ c[:name] == 'p' }")
3386
- Rules[:_explicit_paragraph] = rule_info("explicit_paragraph", "< lh - explicit_paragraph_command:c \":\" documentcontent?:content le empty_line* > { create_item(:paragraph, c, content, raw:text) }")
3387
- Rules[:_unordered_list] = rule_info("unordered_list", "< unordered_item+:items > { create_item(:ul, nil, items, raw: text) }")
3388
- Rules[:_unordered_item] = rule_info("unordered_item", "< lh \"*:\" documentcontent:content le > { create_item(:li, nil, content, raw: text) }")
3389
- Rules[:_ordered_list] = rule_info("ordered_list", "< ordered_item+:items > { create_item(:ol, nil, items, raw: text) }")
3390
- Rules[:_ordered_item] = rule_info("ordered_item", "< lh num \":\" documentcontent:content le > { create_item(:li, nil, content, raw: text) }")
3391
- Rules[:_definition_list] = rule_info("definition_list", "< definition_item+:items > { create_item(:dl, nil, items, raw: text) }")
3392
- Rules[:_definition_item] = rule_info("definition_item", "< lh \";:\" - documentcontent_except(':'):term \":\" - documentcontent:definition le > { create_item(:dtdd, {:args => [term, definition]}, nil, raw: text) }")
3393
- Rules[:_items_list] = rule_info("items_list", "(unordered_list | ordered_list | definition_list)")
3394
- Rules[:_line_command] = rule_info("line_command", "< lh - !commandname_for_special_line_command command:c \":\" documentcontent?:content - le empty_line* > { create_item(:line_command, c, content, raw: text) }")
3395
- Rules[:_line_block] = rule_info("line_block", "(items_list | line_command)")
3396
- Rules[:_block] = rule_info("block", "(preformatted_block | headed_section | line_block | explicit_block | paragraph_group):block empty_line* {block}")
3397
- Rules[:_block_delimiter] = rule_info("block_delimiter", "(blockhead | blockend)")
3398
- Rules[:_paragraph_delimiter] = rule_info("paragraph_delimiter", "(block_delimiter | preformatted_command_head | line_block | newpage | headed_start)")
3399
- Rules[:_h_start_mark] = rule_info("h_start_mark", "< \"=\"+ \":\" > &{ text.length - 1 == n }")
3400
- Rules[:_h_markup_terminator] = rule_info("h_markup_terminator", "lh - < \"=\"+ \":\" > &{ text.length - 1 <= n }")
3401
- Rules[:_h_start] = rule_info("h_start", "lh - h_start_mark(n) charstring:s le { { level: n, heading: s } }")
3402
- Rules[:_h_section] = rule_info("h_section", "< h_start(n):h (!h_markup_terminator(n) !eof block)+:content > { create_item(:h_section, h, content, raw: text) }")
3403
- Rules[:_headed_start] = rule_info("headed_start", "(h_start(1) | h_start(2) | h_start(3) | h_start(4) | h_start(5) | h_start(6))")
3404
- Rules[:_headed_section] = rule_info("headed_section", "(h_section(1) | h_section(2) | h_section(3) | h_section(4) | h_section(5) | h_section(6))")
3405
- Rules[:_stylesheets] = rule_info("stylesheets", "< lh - \"stylesheets:\" !le charstring:s nl > { create_item(:stylesheets, {:stylesheets => s.split(',').map(&:strip)}, nil, raw:text) }")
3406
- Rules[:_title] = rule_info("title", "< lh - \"title:\" !le charstring:t nl > { create_item(:title, {:title => t }, nil, raw:text) }")
3407
- Rules[:_lang] = rule_info("lang", "< lh - \"lang:\" !le charstring:l nl > { create_item(:lang, {:lang => l }, nil, raw:text) }")
3408
- Rules[:_paragraph_style] = rule_info("paragraph_style", "< lh - \"paragraph-style:\" !le charstring:l nl > { create_item(:paragraph_style, {:paragraph_style => l }, nil, raw:text) }")
3409
- Rules[:_header] = rule_info("header", "(stylesheets | title | lang | paragraph_style) empty_line*")
3410
- Rules[:_char] = rule_info("char", "< /[[:print:]]/ > { text }")
3411
- Rules[:_charstring] = rule_info("charstring", "< char* > { text }")
3412
- Rules[:_char_except] = rule_info("char_except", "char:c &{ c != e }")
3413
- Rules[:_charstring_except] = rule_info("charstring_except", "< char_except(e)* > { text }")
3414
- Rules[:_documentcontent_except] = rule_info("documentcontent_except", "(inline | !inline char_except(e))+:content {parse_text(content)}")
3415
- Rules[:_documentcontent] = rule_info("documentcontent", "(inline | !inline char)+:content {parse_text(content)}")
3416
- Rules[:_documentline] = rule_info("documentline", "lh documentcontent:content le { content }")
3417
- Rules[:_headers] = rule_info("headers", "header*:headers { create_item(:headers, nil, headers) }")
3418
- Rules[:_page] = rule_info("page", "headers:headers - (!newpage block)*:blocks { create_item(:page, nil, [headers] + blocks.select{ |x| !x.nil?}) }")
3419
- Rules[:_newpaged_page] = rule_info("newpaged_page", "newpage:newpage page:page { page[:children] = page[:children].unshift newpage; page }")
3420
- Rules[:_root] = rule_info("root", "page:page newpaged_page*:pages - eof_comment? eof { [ page ] + pages }")
3638
+ Rules[:_Eof] = rule_info("Eof", "!.")
3639
+ Rules[:_Space] = rule_info("Space", "(\" \" | \"\\\\t\")")
3640
+ Rules[:_EofComment] = rule_info("EofComment", "Space* \"\#\" (!Eof .)*")
3641
+ Rules[:_Comment] = rule_info("Comment", "Space* \"\#\" (!Nl .)* Nl EmptyLine*")
3642
+ Rules[:__hyphen_] = rule_info("-", "Space*")
3643
+ Rules[:_EmptyLine] = rule_info("EmptyLine", "/^/ - (Nl | Comment | EofComment)")
3644
+ Rules[:_Nl] = rule_info("Nl", "/\\r?\\n/")
3645
+ Rules[:_Le] = rule_info("Le", "(Nl | Eof)")
3646
+ Rules[:_Word] = rule_info("Word", "< /[\\w0-9]/ (\"-\" | /[\\w0-9]/)* > { text }")
3647
+ Rules[:_Num] = rule_info("Num", "< [0-9]+ > { text.to_i }")
3648
+ Rules[:_ClassName] = rule_info("ClassName", "\".\" Word:classname { classname }")
3649
+ Rules[:_ClassNames] = rule_info("ClassNames", "ClassName*:classnames { classnames }")
3650
+ Rules[:_IdName] = rule_info("IdName", "\"\#\" Word:idname { idname }")
3651
+ Rules[:_IdNames] = rule_info("IdNames", "IdName*:idnames { idnames }")
3652
+ Rules[:_CommandName] = rule_info("CommandName", "Word:name IdNames?:idnames ClassNames?:classes { {name: name, ids: idnames, classes: classes} }")
3653
+ Rules[:_ParameterNormal] = rule_info("ParameterNormal", "< /[^,)]/* > { text }")
3654
+ Rules[:_ParameterQuoted] = rule_info("ParameterQuoted", "\"\\\"\" < /[^\"]/* > \"\\\"\" - &/[,)]/ { text }")
3655
+ Rules[:_ParameterSingleQuoted] = rule_info("ParameterSingleQuoted", "\"'\" < /[^']/* > \"'\" - &/[,)]/ { text }")
3656
+ Rules[:_Parameter] = rule_info("Parameter", "(ParameterQuoted | ParameterSingleQuoted | ParameterNormal):value { value }")
3657
+ Rules[:_Parameters] = rule_info("Parameters", "Parameter:parameter (\",\" - Parameter)*:rest_parameters { [parameter] + rest_parameters }")
3658
+ Rules[:_Command] = rule_info("Command", "CommandName:cn (\"(\" - Parameters:args - \")\")? { args ||= []; cn.merge({ args: args }) }")
3659
+ Rules[:_ImplicitParagraph] = rule_info("ImplicitParagraph", "- !ParagraphDelimiter Comment* DocumentLine:content Comment* EofComment? {paragraph([],[], [], content)}")
3660
+ Rules[:_Paragraph] = rule_info("Paragraph", "(ExplicitParagraph | ImplicitParagraph)")
3661
+ Rules[:_ParagraphGroup] = rule_info("ParagraphGroup", "Paragraph+:p EmptyLine* {paragraph_group([],[],[],p)}")
3662
+ Rules[:_BlockHead] = rule_info("BlockHead", "- Command:command - \"{\" - Nl EmptyLine* { command }")
3663
+ Rules[:_BlockEnd] = rule_info("BlockEnd", "- \"}\" - Le EmptyLine*")
3664
+ Rules[:_BlockBody] = rule_info("BlockBody", "(!BlockEnd Block)+:body { body }")
3665
+ Rules[:_ExplicitBlock] = rule_info("ExplicitBlock", "BlockHead:c - BlockBody:content - BlockEnd {block(c[:name], c[:ids], c[:classes], c[:args], content)}")
3666
+ Rules[:_PreformattedCommand] = rule_info("PreformattedCommand", "Command:command &{ ['pre', 'code'].include? command[:name] }")
3667
+ Rules[:_PreformattedCommandHeadSimple] = rule_info("PreformattedCommandHeadSimple", "- PreformattedCommand:command - \"{\" - Nl { command }")
3668
+ Rules[:_PreformattedCommandHeadComplex] = rule_info("PreformattedCommandHeadComplex", "- PreformattedCommand:command - \"{//\" Word?:codelanguage - Nl { command.merge({codelanguage: codelanguage}) }")
3669
+ Rules[:_PreformattedCommandHead] = rule_info("PreformattedCommandHead", "(PreformattedCommandHeadComplex | PreformattedCommandHeadSimple)")
3670
+ Rules[:_PreformatEndSimple] = rule_info("PreformatEndSimple", "- \"}\" - Le EmptyLine*")
3671
+ Rules[:_PreformatEndComplex] = rule_info("PreformatEndComplex", "- \"//}\" - Le EmptyLine*")
3672
+ Rules[:_PreformattedBlockSimple] = rule_info("PreformattedBlockSimple", "PreformattedCommandHeadSimple:c (!PreformatEndSimple CharString Nl)+:content PreformatEndSimple {preformatted_block(c[:name], c[:ids], c[:classes], c[:args], c[:codelanguage], content)}")
3673
+ Rules[:_PreformattedBlockComplex] = rule_info("PreformattedBlockComplex", "PreformattedCommandHeadComplex:c (!PreformatEndComplex CharString Nl)+:content PreformatEndComplex {preformatted_block(c[:name], c[:ids], c[:classes], c[:args], c[:codelanguage], content)}")
3674
+ Rules[:_PreformattedBlock] = rule_info("PreformattedBlock", "(PreformattedBlockComplex | PreformattedBlockSimple)")
3675
+ Rules[:_Inline] = rule_info("Inline", "(ImgInline | CommonInline)")
3676
+ Rules[:_CommonInline] = rule_info("CommonInline", "\"[\" Command:c \"{\" - DocumentContentExcept('}'):content \"}\" \"]\" {inline(c[:name], c[:ids], c[:classes], c[:args], content)}")
3677
+ Rules[:_ImgCommand] = rule_info("ImgCommand", "Command:c &{ c[:name] == 'img' && c[:args].size == 2}")
3678
+ Rules[:_ImgInline] = rule_info("ImgInline", "\"[\" ImgCommand:c \"]\" {inline(c[:name], c[:ids], c[:classes], c[:args], nil)}")
3679
+ Rules[:_CommandNameForSpecialLineCommand] = rule_info("CommandNameForSpecialLineCommand", "(NewpageCommand | ExplicitParagraphCommand)")
3680
+ Rules[:_NewpageCommand] = rule_info("NewpageCommand", "Command:command &{ command[:name] == 'newpage' }")
3681
+ Rules[:_Newpage] = rule_info("Newpage", "- NewpageCommand:c \":\" - DocumentContent?:content - Nl {newpage(c[:ids],c[:classes],c[:args], content)}")
3682
+ Rules[:_ExplicitParagraphCommand] = rule_info("ExplicitParagraphCommand", "Command:c &{ c[:name] == 'p' }")
3683
+ Rules[:_ExplicitParagraph] = rule_info("ExplicitParagraph", "- ExplicitParagraphCommand:c \":\" - DocumentContent?:content Le EmptyLine* {paragraph(c[:ids], c[:classes], c[:args], content)}")
3684
+ Rules[:_UnorderedList] = rule_info("UnorderedList", "UnorderedItem+:items {unordered_list([],[],[], items)}")
3685
+ Rules[:_UnorderedItem] = rule_info("UnorderedItem", "\"*:\" - DocumentContent:content Le {ul_item([], [], [], content)}")
3686
+ Rules[:_OrderedList] = rule_info("OrderedList", "OrderedItem+:items {ordered_list([],[],[], items)}")
3687
+ Rules[:_OrderedItem] = rule_info("OrderedItem", "Num \":\" - DocumentContent:content Le {ol_item([], [], [], content)}")
3688
+ Rules[:_DefinitionList] = rule_info("DefinitionList", "DefinitionItem+:items {definition_list([], [], [], items)}")
3689
+ Rules[:_DefinitionItem] = rule_info("DefinitionItem", "- \";:\" - DocumentContentExcept(':'):term \":\" - DocumentContent:definition Le {dl_item([], [], [term], definition)}")
3690
+ Rules[:_LongDefinitionList] = rule_info("LongDefinitionList", "LongDefinitionItem+:items {definition_list([], [], [], items)}")
3691
+ Rules[:_LongDefinitionItem] = rule_info("LongDefinitionItem", "- \";:\" - DocumentContentExcept('{'):term \"{\" - Nl - BlockBody:definition - BlockEnd {dl_item([], [], [term], definition)}")
3692
+ Rules[:_ItemsList] = rule_info("ItemsList", "(UnorderedList | OrderedList | DefinitionList | LongDefinitionList)")
3693
+ Rules[:_LineCommand] = rule_info("LineCommand", "- !CommandNameForSpecialLineCommand Command:c \":\" - DocumentContent?:content - Le EmptyLine* {line_command(c[:name], c[:ids], c[:classes], c[:args], content)}")
3694
+ Rules[:_LineBlock] = rule_info("LineBlock", "(ItemsList | LineCommand)")
3695
+ Rules[:_Block] = rule_info("Block", "EmptyLine* (PreformattedBlock | HeadedSection | LineBlock | ExplicitBlock | ParagraphGroup):block EmptyLine* {block}")
3696
+ Rules[:_BlockDelimiter] = rule_info("BlockDelimiter", "(BlockHead | BlockEnd)")
3697
+ Rules[:_ParagraphDelimiter] = rule_info("ParagraphDelimiter", "(BlockDelimiter | PreformattedCommandHead | LineBlock | Newpage | HeadedStart)")
3698
+ Rules[:_HStartMark] = rule_info("HStartMark", "< \"=\"+ \":\" > &{ text.length - 1 == n }")
3699
+ Rules[:_HMarkupTerminator] = rule_info("HMarkupTerminator", "- < \"=\"+ \":\" > &{ text.length - 1 <= n }")
3700
+ Rules[:_HStart] = rule_info("HStart", "- HStartMark(n) - DocumentContent:s Le { { level: n, heading: s } }")
3701
+ Rules[:_HSection] = rule_info("HSection", "HStart(n):h (!HMarkupTerminator(n) !Eof Block)*:content {h_section(h[:level], h[:heading], content)}")
3702
+ Rules[:_HeadedStart] = rule_info("HeadedStart", "(HStart(1) | HStart(2) | HStart(3) | HStart(4) | HStart(5) | HStart(6))")
3703
+ Rules[:_HeadedSection] = rule_info("HeadedSection", "(HSection(1) | HSection(2) | HSection(3) | HSection(4) | HSection(5) | HSection(6))")
3704
+ Rules[:_FrontmatterSeparator] = rule_info("FrontmatterSeparator", "- \"---\" - Nl")
3705
+ Rules[:_Frontmatter] = rule_info("Frontmatter", "FrontmatterSeparator (!FrontmatterSeparator CharString Nl)+:yaml FrontmatterSeparator EmptyLine* {frontmatter(yaml)}")
3706
+ Rules[:_Char] = rule_info("Char", "< /[[:print:]]/ > { text }")
3707
+ Rules[:_CharString] = rule_info("CharString", "< Char* > { text }")
3708
+ Rules[:_CharExcept] = rule_info("CharExcept", "Char:c &{ c != e }")
3709
+ Rules[:_DocumentTextExcept] = rule_info("DocumentTextExcept", "< (!Inline CharExcept(e))+ > {text(text)}")
3710
+ Rules[:_DocumentContentExcept] = rule_info("DocumentContentExcept", "(Inline | DocumentTextExcept(e))+:content { content }")
3711
+ Rules[:_DocumentText] = rule_info("DocumentText", "< (!Inline Char)+ > {text(text)}")
3712
+ Rules[:_DocumentContent] = rule_info("DocumentContent", "(Inline | DocumentText)+:content { content }")
3713
+ Rules[:_DocumentLine] = rule_info("DocumentLine", "DocumentContent:content Le { content }")
3714
+ Rules[:_Page] = rule_info("Page", "Frontmatter?:frontmatter - (!Newpage Block)*:blocks {page(([frontmatter] + blocks).select{ |x| !x.nil?})}")
3715
+ Rules[:_NewpagedPage] = rule_info("NewpagedPage", "Newpage:newpage Page:page { page.content = page.content.unshift newpage; page }")
3716
+ Rules[:_root] = rule_info("root", "Page:page NewpagedPage*:pages - EofComment? Eof { [ page ] + pages }")
3421
3717
  # :startdoc:
3422
3718
  end