Module: Hemingway::Latex
Defined Under Namespace
Modules: LastParagraph0, LastParagraph1, Paragraph0, Paragraph1
Instance Method Summary
collapse
Methods included from Text
#_nt_non_text, #_nt_text
Methods included from Tag
#_nt_accent, #_nt_hfill, #_nt_millimeter, #_nt_neatline, #_nt_tag, #_nt_tag_end, #_nt_tag_start, #_nt_tag_type, #_nt_vertical_height, #_nt_vertical_space
Methods included from Symbol
#_nt_math_symbol
Methods included from Special
#_nt_escape, #_nt_special
Methods included from Override
#_nt_override
Methods included from Math
#_nt_exponent, #_nt_math, #_nt_math_end, #_nt_math_start, #_nt_symbol
Methods included from Footnote
#_nt_footnote
Methods included from Block
#_nt_block, #_nt_block_end, #_nt_block_start
#_nt_center, #_nt_center_type
#_nt_quote_entry, #_nt_quote_last_paragraph, #_nt_quote_paragraph, #_nt_quote_type
#_nt_verbatim, #_nt_verbatim_text, #_nt_verbatim_type
#_nt_item, #_nt_label, #_nt_label_content, #_nt_label_end, #_nt_label_start, #_nt_label_text, #_nt_list, #_nt_list_type
Instance Method Details
#_nt_content ⇒ Object
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
|
# File 'lib/hemingway/latex.rb', line 289
def _nt_content
start_index = index
if node_cache[:content].has_key?(index)
cached = node_cache[:content][index]
if cached
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
@index = cached.interval.end
end
return cached
end
i0 = index
r1 = _nt_special
if r1
r0 = r1
else
r2 = _nt_tag
if r2
r0 = r2
else
r3 = _nt_block
if r3
r0 = r3
else
r4 = _nt_math
if r4
r0 = r4
else
r5 = _nt_override
if r5
r0 = r5
else
r6 = _nt_text
if r6
r0 = r6
else
@index = i0
r0 = nil
end
end
end
end
end
end
node_cache[:content][start_index] = r0
r0
end
|
#_nt_document ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/hemingway/latex.rb', line 39
def _nt_document
start_index = index
if node_cache[:document].has_key?(index)
cached = node_cache[:document][index]
if cached
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
@index = cached.interval.end
end
return cached
end
r0 = _nt_entry
node_cache[:document][start_index] = r0
r0
end
|
#_nt_entry ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/hemingway/latex.rb', line 57
def _nt_entry
start_index = index
if node_cache[:entry].has_key?(index)
cached = node_cache[:entry][index]
if cached
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
@index = cached.interval.end
end
return cached
end
s0, i0 = [], index
loop do
i1 = index
r2 = _nt_paragraph
if r2
r1 = r2
else
r3 = _nt_last_paragraph
if r3
r1 = r3
else
@index = i1
r1 = nil
end
end
if r1
s0 << r1
else
break
end
end
r0 = instantiate_node(EntryNode,input, i0...index, s0)
node_cache[:entry][start_index] = r0
r0
end
|
#_nt_eop ⇒ Object
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
|
# File 'lib/hemingway/latex.rb', line 422
def _nt_eop
start_index = index
if node_cache[:eop].has_key?(index)
cached = node_cache[:eop][index]
if cached
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
@index = cached.interval.end
end
return cached
end
s0, i0 = [], index
loop do
r1 = _nt_newline
if r1
s0 << r1
else
break
end
end
if s0.size < 2
@index = i0
r0 = nil
else
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
end
node_cache[:eop][start_index] = r0
r0
end
|
#_nt_last_paragraph ⇒ Object
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
|
# File 'lib/hemingway/latex.rb', line 202
def _nt_last_paragraph
start_index = index
if node_cache[:last_paragraph].has_key?(index)
cached = node_cache[:last_paragraph][index]
if cached
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
@index = cached.interval.end
end
return cached
end
i0, s0 = index, []
s1, i1 = [], index
loop do
i2 = index
r3 = _nt_content
if r3
r2 = r3
else
r4 =
if r4
r2 = r4
else
i5, s5 = index, []
i6 = index
r7 = _nt_eop
if r7
r6 = nil
else
@index = i6
r6 = instantiate_node(SyntaxNode,input, index...index)
end
s5 << r6
if r6
r8 = _nt_newline
s5 << r8
end
if s5.last
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
r5.extend(LastParagraph0)
else
@index = i5
r5 = nil
end
if r5
r2 = r5
else
@index = i2
r2 = nil
end
end
end
if r2
s1 << r2
else
break
end
end
if s1.empty?
@index = i1
r1 = nil
else
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
end
s0 << r1
if r1
r10 = _nt_eop
if r10
r9 = r10
else
r9 = instantiate_node(SyntaxNode,input, index...index)
end
s0 << r9
end
if s0.last
r0 = instantiate_node(ParagraphNode,input, i0...index, s0)
r0.extend(LastParagraph1)
else
@index = i0
r0 = nil
end
node_cache[:last_paragraph][start_index] = r0
r0
end
|
#_nt_newline ⇒ Object
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
|
# File 'lib/hemingway/latex.rb', line 454
def _nt_newline
start_index = index
if node_cache[:newline].has_key?(index)
cached = node_cache[:newline][index]
if cached
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
@index = cached.interval.end
end
return cached
end
if has_terminal?("\n", false, index)
r0 = instantiate_node(NewlineNode,input, index...(index + 1))
@index += 1
else
terminal_parse_failure("\n")
r0 = nil
end
node_cache[:newline][start_index] = r0
r0
end
|
#_nt_paragraph ⇒ Object
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
# File 'lib/hemingway/latex.rb', line 112
def _nt_paragraph
start_index = index
if node_cache[:paragraph].has_key?(index)
cached = node_cache[:paragraph][index]
if cached
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
@index = cached.interval.end
end
return cached
end
i0, s0 = index, []
s1, i1 = [], index
loop do
i2 = index
r3 = _nt_content
if r3
r2 = r3
else
r4 =
if r4
r2 = r4
else
i5, s5 = index, []
i6 = index
r7 = _nt_eop
if r7
r6 = nil
else
@index = i6
r6 = instantiate_node(SyntaxNode,input, index...index)
end
s5 << r6
if r6
r8 = _nt_newline
s5 << r8
end
if s5.last
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
r5.extend(Paragraph0)
else
@index = i5
r5 = nil
end
if r5
r2 = r5
else
@index = i2
r2 = nil
end
end
end
if r2
s1 << r2
else
break
end
end
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
s0 << r1
if r1
r9 = _nt_eop
s0 << r9
end
if s0.last
r0 = instantiate_node(ParagraphNode,input, i0...index, s0)
r0.extend(Paragraph1)
else
@index = i0
r0 = nil
end
node_cache[:paragraph][start_index] = r0
r0
end
|
#_nt_spaces ⇒ Object
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
|
# File 'lib/hemingway/latex.rb', line 389
def _nt_spaces
start_index = index
if node_cache[:spaces].has_key?(index)
cached = node_cache[:spaces][index]
if cached
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
@index = cached.interval.end
end
return cached
end
s0, i0 = [], index
loop do
if has_terminal?(" ", false, index)
r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
@index += 1
else
terminal_parse_failure(" ")
r1 = nil
end
if r1
s0 << r1
else
break
end
end
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
node_cache[:spaces][start_index] = r0
r0
end
|
#_nt_whitespace ⇒ Object
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
|
# File 'lib/hemingway/latex.rb', line 339
def _nt_whitespace
start_index = index
if node_cache[:whitespace].has_key?(index)
cached = node_cache[:whitespace][index]
if cached
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
@index = cached.interval.end
end
return cached
end
s0, i0 = [], index
loop do
i1 = index
if has_terminal?(" ", false, index)
r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
@index += 1
else
terminal_parse_failure(" ")
r2 = nil
end
if r2
r1 = r2
else
r3 = _nt_newline
if r3
r1 = r3
else
@index = i1
r1 = nil
end
end
if r1
s0 << r1
else
break
end
end
if s0.empty?
@index = i0
r0 = nil
else
r0 = instantiate_node(WhitespaceNode,input, i0...index, s0)
end
node_cache[:whitespace][start_index] = r0
r0
end
|
#root ⇒ Object
19
20
21
|
# File 'lib/hemingway/latex.rb', line 19
def root
@root ||= :document
end
|