glyph 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. data/AUTHORS.textile +1 -1
  2. data/CHANGELOG.textile +119 -222
  3. data/LICENSE.textile +1 -1
  4. data/README.textile +42 -23
  5. data/Rakefile +1 -3
  6. data/VERSION +1 -1
  7. data/benchmark.rb +72 -0
  8. data/book/config.yml +4 -4
  9. data/book/document.glyph +90 -57
  10. data/book/images/document_generation.png +0 -0
  11. data/book/lib/macros/reference.rb +75 -22
  12. data/book/output/html/glyph.html +3183 -2121
  13. data/book/output/html/images/document_generation.png +0 -0
  14. data/book/output/pdf/glyph.pdf +7370 -4913
  15. data/book/resources/document_generation.txt +34 -0
  16. data/book/snippets.yml +6 -0
  17. data/book/text/changelog.glyph +45 -34
  18. data/book/text/compiling/compiling.glyph +23 -0
  19. data/book/text/compiling/lite_mode.glyph +23 -0
  20. data/book/text/compiling/programmatic_usage.glyph +77 -0
  21. data/book/text/extending/bookmarks_headers.glyph +21 -0
  22. data/book/text/extending/further_reading.glyph +13 -0
  23. data/book/text/extending/internals.glyph +79 -0
  24. data/book/text/extending/interpreting.glyph +51 -0
  25. data/book/text/extending/macro_def.glyph +64 -0
  26. data/book/text/extending/params_attrs.glyph +70 -0
  27. data/book/text/extending/placeholders.glyph +34 -0
  28. data/book/text/extending/validators.glyph +16 -0
  29. data/book/text/getting_started/configuration.glyph +49 -0
  30. data/book/text/getting_started/create_project.glyph +41 -0
  31. data/book/text/getting_started/structure.glyph +55 -0
  32. data/book/text/introduction.glyph +49 -26
  33. data/book/text/license.glyph +1 -1
  34. data/book/text/macros/macros_block.glyph +99 -0
  35. data/book/text/macros/macros_core.glyph +208 -0
  36. data/book/text/macros/macros_filters.glyph +40 -0
  37. data/book/text/macros/macros_inline.glyph +50 -0
  38. data/book/text/macros/macros_structure.glyph +100 -0
  39. data/book/text/ref_commands.glyph +94 -73
  40. data/book/text/ref_config.glyph +34 -42
  41. data/book/text/ref_macros.glyph +1 -373
  42. data/book/text/text_editing/code.glyph +51 -0
  43. data/book/text/text_editing/conditionals.glyph +49 -0
  44. data/book/text/text_editing/evaluation.glyph +13 -0
  45. data/book/text/text_editing/glyph_files.glyph +7 -0
  46. data/book/text/text_editing/images.glyph +29 -0
  47. data/book/text/text_editing/inclusions.glyph +44 -0
  48. data/book/text/text_editing/links.glyph +53 -0
  49. data/book/text/text_editing/macro_intro.glyph +111 -0
  50. data/book/text/text_editing/raw_html.glyph +112 -0
  51. data/book/text/text_editing/sections.glyph +63 -0
  52. data/book/text/text_editing/stylesheets.glyph +36 -0
  53. data/book/text/troubleshooting/errors_command.glyph +39 -0
  54. data/book/text/troubleshooting/errors_generic.glyph +29 -0
  55. data/book/text/troubleshooting/errors_intro.glyph +3 -0
  56. data/book/text/troubleshooting/errors_macro.glyph +98 -0
  57. data/book/text/troubleshooting/errors_parser.glyph +29 -0
  58. data/config.yml +77 -58
  59. data/document.glyph +25 -25
  60. data/glyph.gemspec +57 -22
  61. data/lib/glyph.rb +54 -13
  62. data/lib/glyph/commands.rb +84 -17
  63. data/lib/glyph/config.rb +3 -3
  64. data/lib/glyph/document.rb +14 -8
  65. data/lib/glyph/interpreter.rb +18 -58
  66. data/lib/glyph/macro.rb +160 -55
  67. data/lib/glyph/macro_validators.rb +104 -12
  68. data/lib/glyph/node.rb +24 -0
  69. data/lib/glyph/parser.rb +278 -0
  70. data/lib/glyph/syntax_node.rb +225 -0
  71. data/macros/core.rb +212 -0
  72. data/macros/filters.rb +66 -15
  73. data/macros/html/block.rb +43 -105
  74. data/macros/html/inline.rb +11 -12
  75. data/macros/html/structure.rb +123 -58
  76. data/macros/xml.rb +33 -0
  77. data/spec/files/container.textile +2 -2
  78. data/spec/files/document.glyph +2 -2
  79. data/spec/files/document_with_toc.glyph +3 -3
  80. data/spec/files/included.textile +1 -1
  81. data/spec/files/ligature.jpg +0 -0
  82. data/spec/files/markdown.markdown +2 -1
  83. data/spec/lib/commands_spec.rb +46 -3
  84. data/spec/lib/document_spec.rb +4 -4
  85. data/spec/lib/glyph_spec.rb +17 -46
  86. data/spec/lib/interpreter_spec.rb +6 -25
  87. data/spec/lib/macro_spec.rb +141 -43
  88. data/spec/lib/macro_validators_spec.rb +27 -5
  89. data/spec/lib/node_spec.rb +26 -1
  90. data/spec/lib/parser_spec.rb +246 -0
  91. data/spec/lib/syntax_node_spec.rb +111 -0
  92. data/spec/macros/core_spec.rb +195 -0
  93. data/spec/macros/filters_spec.rb +38 -4
  94. data/spec/macros/macros_spec.rb +20 -176
  95. data/spec/macros/textile_spec.rb +13 -71
  96. data/spec/macros/xml_spec.rb +77 -0
  97. data/spec/spec_helper.rb +50 -10
  98. data/spec/tasks/load_spec.rb +13 -2
  99. data/styles/default.css +18 -6
  100. data/styles/pagination.css +1 -19
  101. data/tasks/generate.rake +2 -2
  102. data/tasks/load.rake +27 -17
  103. data/tasks/project.rake +1 -1
  104. metadata +75 -62
  105. data/book/script/compile.rb +0 -8
  106. data/book/script/prof +0 -1
  107. data/book/script/prof_results.htm +0 -21079
  108. data/book/text/authoring.glyph +0 -548
  109. data/book/text/extending.glyph +0 -224
  110. data/book/text/getting_started.glyph +0 -158
  111. data/book/text/troubleshooting.glyph +0 -179
  112. data/lib/glyph/glyph_language.rb +0 -538
  113. data/lib/glyph/glyph_language.treetop +0 -27
  114. data/macros/common.rb +0 -160
@@ -1,538 +0,0 @@
1
- # Autogenerated from a Treetop grammar. Edits may be lost.
2
-
3
- # @private
4
- module GlyphLanguage
5
- include Treetop::Runtime
6
-
7
- def root
8
- @root || :expression
9
- end
10
-
11
- def _nt_expression
12
- start_index = index
13
- if node_cache[:expression].has_key?(index)
14
- cached = node_cache[:expression][index]
15
- @index = cached.interval.end if cached
16
- return cached
17
- end
18
-
19
- s0, i0 = [], index
20
- loop do
21
- i1 = index
22
- r2 = _nt_escaping_macro
23
- if r2
24
- r1 = r2
25
- else
26
- r3 = _nt_macro
27
- if r3
28
- r1 = r3
29
- else
30
- r4 = _nt_escaped_text
31
- if r4
32
- r1 = r4
33
- else
34
- @index = i1
35
- r1 = nil
36
- end
37
- end
38
- end
39
- if r1
40
- s0 << r1
41
- else
42
- break
43
- end
44
- end
45
- r0 = instantiate_node(GlyphSyntaxNode,input, i0...index, s0)
46
-
47
- node_cache[:expression][start_index] = r0
48
-
49
- r0
50
- end
51
-
52
- # @private
53
- module EscapingMacro0
54
- def macro_name
55
- elements[0]
56
- end
57
-
58
- def text
59
- elements[2]
60
- end
61
-
62
- end
63
-
64
- def _nt_escaping_macro
65
- start_index = index
66
- if node_cache[:escaping_macro].has_key?(index)
67
- cached = node_cache[:escaping_macro][index]
68
- @index = cached.interval.end if cached
69
- return cached
70
- end
71
-
72
- i0, s0 = index, []
73
- r1 = _nt_macro_name
74
- s0 << r1
75
- if r1
76
- if has_terminal?('[=', false, index)
77
- r2 = instantiate_node(SyntaxNode,input, index...(index + 2))
78
- @index += 2
79
- else
80
- terminal_parse_failure('[=')
81
- r2 = nil
82
- end
83
- s0 << r2
84
- if r2
85
- r3 = _nt_text
86
- s0 << r3
87
- if r3
88
- if has_terminal?('=]', false, index)
89
- r4 = instantiate_node(SyntaxNode,input, index...(index + 2))
90
- @index += 2
91
- else
92
- terminal_parse_failure('=]')
93
- r4 = nil
94
- end
95
- s0 << r4
96
- end
97
- end
98
- end
99
- if s0.last
100
- r0 = instantiate_node(EscapingMacroNode,input, i0...index, s0)
101
- r0.extend(EscapingMacro0)
102
- else
103
- @index = i0
104
- r0 = nil
105
- end
106
-
107
- node_cache[:escaping_macro][start_index] = r0
108
-
109
- r0
110
- end
111
-
112
- # @private
113
- module Macro0
114
- def macro_name
115
- elements[0]
116
- end
117
-
118
- def expression
119
- elements[2]
120
- end
121
-
122
- end
123
-
124
- def _nt_macro
125
- start_index = index
126
- if node_cache[:macro].has_key?(index)
127
- cached = node_cache[:macro][index]
128
- @index = cached.interval.end if cached
129
- return cached
130
- end
131
-
132
- i0, s0 = index, []
133
- r1 = _nt_macro_name
134
- s0 << r1
135
- if r1
136
- if has_terminal?('[', false, index)
137
- r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
138
- @index += 1
139
- else
140
- terminal_parse_failure('[')
141
- r2 = nil
142
- end
143
- s0 << r2
144
- if r2
145
- r3 = _nt_expression
146
- s0 << r3
147
- if r3
148
- if has_terminal?(']', false, index)
149
- r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
150
- @index += 1
151
- else
152
- terminal_parse_failure(']')
153
- r4 = nil
154
- end
155
- s0 << r4
156
- end
157
- end
158
- end
159
- if s0.last
160
- r0 = instantiate_node(MacroNode,input, i0...index, s0)
161
- r0.extend(Macro0)
162
- else
163
- @index = i0
164
- r0 = nil
165
- end
166
-
167
- node_cache[:macro][start_index] = r0
168
-
169
- r0
170
- end
171
-
172
- # @private
173
- module EscapedText0
174
- end
175
-
176
- # @private
177
- module EscapedText1
178
- def macro_name
179
- elements[0]
180
- end
181
-
182
- end
183
-
184
- # @private
185
- module EscapedText2
186
- end
187
-
188
- def _nt_escaped_text
189
- start_index = index
190
- if node_cache[:escaped_text].has_key?(index)
191
- cached = node_cache[:escaped_text][index]
192
- @index = cached.interval.end if cached
193
- return cached
194
- end
195
-
196
- s0, i0 = [], index
197
- loop do
198
- i1 = index
199
- i2, s2 = index, []
200
- if has_terminal?('\\', false, index)
201
- r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
202
- @index += 1
203
- else
204
- terminal_parse_failure('\\')
205
- r3 = nil
206
- end
207
- s2 << r3
208
- if r3
209
- if index < input_length
210
- r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
211
- @index += 1
212
- else
213
- terminal_parse_failure("any character")
214
- r4 = nil
215
- end
216
- s2 << r4
217
- end
218
- if s2.last
219
- r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
220
- r2.extend(EscapedText0)
221
- else
222
- @index = i2
223
- r2 = nil
224
- end
225
- if r2
226
- r1 = r2
227
- else
228
- i5, s5 = index, []
229
- i6 = index
230
- i7 = index
231
- i8, s8 = index, []
232
- r9 = _nt_macro_name
233
- s8 << r9
234
- if r9
235
- i10 = index
236
- if has_terminal?('[', false, index)
237
- r11 = instantiate_node(SyntaxNode,input, index...(index + 1))
238
- @index += 1
239
- else
240
- terminal_parse_failure('[')
241
- r11 = nil
242
- end
243
- if r11
244
- r10 = r11
245
- else
246
- if has_terminal?('[=', false, index)
247
- r12 = instantiate_node(SyntaxNode,input, index...(index + 2))
248
- @index += 2
249
- else
250
- terminal_parse_failure('[=')
251
- r12 = nil
252
- end
253
- if r12
254
- r10 = r12
255
- else
256
- @index = i10
257
- r10 = nil
258
- end
259
- end
260
- s8 << r10
261
- end
262
- if s8.last
263
- r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
264
- r8.extend(EscapedText1)
265
- else
266
- @index = i8
267
- r8 = nil
268
- end
269
- if r8
270
- r7 = r8
271
- else
272
- i13 = index
273
- if has_terminal?(']', false, index)
274
- r14 = instantiate_node(SyntaxNode,input, index...(index + 1))
275
- @index += 1
276
- else
277
- terminal_parse_failure(']')
278
- r14 = nil
279
- end
280
- if r14
281
- r13 = r14
282
- else
283
- if has_terminal?('=]', false, index)
284
- r15 = instantiate_node(SyntaxNode,input, index...(index + 2))
285
- @index += 2
286
- else
287
- terminal_parse_failure('=]')
288
- r15 = nil
289
- end
290
- if r15
291
- r13 = r15
292
- else
293
- @index = i13
294
- r13 = nil
295
- end
296
- end
297
- if r13
298
- r7 = r13
299
- else
300
- @index = i7
301
- r7 = nil
302
- end
303
- end
304
- if r7
305
- r6 = nil
306
- else
307
- @index = i6
308
- r6 = instantiate_node(SyntaxNode,input, index...index)
309
- end
310
- s5 << r6
311
- if r6
312
- if index < input_length
313
- r16 = instantiate_node(SyntaxNode,input, index...(index + 1))
314
- @index += 1
315
- else
316
- terminal_parse_failure("any character")
317
- r16 = nil
318
- end
319
- s5 << r16
320
- end
321
- if s5.last
322
- r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
323
- r5.extend(EscapedText2)
324
- else
325
- @index = i5
326
- r5 = nil
327
- end
328
- if r5
329
- r1 = r5
330
- else
331
- @index = i1
332
- r1 = nil
333
- end
334
- end
335
- if r1
336
- s0 << r1
337
- else
338
- break
339
- end
340
- end
341
- if s0.empty?
342
- @index = i0
343
- r0 = nil
344
- else
345
- r0 = instantiate_node(TextNode,input, i0...index, s0)
346
- end
347
-
348
- node_cache[:escaped_text][start_index] = r0
349
-
350
- r0
351
- end
352
-
353
- # @private
354
- module Text0
355
- end
356
-
357
- # @private
358
- module Text1
359
- def macro_name
360
- elements[0]
361
- end
362
-
363
- end
364
-
365
- # @private
366
- module Text2
367
- end
368
-
369
- def _nt_text
370
- start_index = index
371
- if node_cache[:text].has_key?(index)
372
- cached = node_cache[:text][index]
373
- @index = cached.interval.end if cached
374
- return cached
375
- end
376
-
377
- s0, i0 = [], index
378
- loop do
379
- i1 = index
380
- i2, s2 = index, []
381
- if has_terminal?('\\', false, index)
382
- r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
383
- @index += 1
384
- else
385
- terminal_parse_failure('\\')
386
- r3 = nil
387
- end
388
- s2 << r3
389
- if r3
390
- if index < input_length
391
- r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
392
- @index += 1
393
- else
394
- terminal_parse_failure("any character")
395
- r4 = nil
396
- end
397
- s2 << r4
398
- end
399
- if s2.last
400
- r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
401
- r2.extend(Text0)
402
- else
403
- @index = i2
404
- r2 = nil
405
- end
406
- if r2
407
- r1 = r2
408
- else
409
- i5, s5 = index, []
410
- i6 = index
411
- i7 = index
412
- i8, s8 = index, []
413
- r9 = _nt_macro_name
414
- s8 << r9
415
- if r9
416
- if has_terminal?('[=', false, index)
417
- r10 = instantiate_node(SyntaxNode,input, index...(index + 2))
418
- @index += 2
419
- else
420
- terminal_parse_failure('[=')
421
- r10 = nil
422
- end
423
- s8 << r10
424
- end
425
- if s8.last
426
- r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
427
- r8.extend(Text1)
428
- else
429
- @index = i8
430
- r8 = nil
431
- end
432
- if r8
433
- r7 = r8
434
- else
435
- if has_terminal?('=]', false, index)
436
- r11 = instantiate_node(SyntaxNode,input, index...(index + 2))
437
- @index += 2
438
- else
439
- terminal_parse_failure('=]')
440
- r11 = nil
441
- end
442
- if r11
443
- r7 = r11
444
- else
445
- @index = i7
446
- r7 = nil
447
- end
448
- end
449
- if r7
450
- r6 = nil
451
- else
452
- @index = i6
453
- r6 = instantiate_node(SyntaxNode,input, index...index)
454
- end
455
- s5 << r6
456
- if r6
457
- if index < input_length
458
- r12 = instantiate_node(SyntaxNode,input, index...(index + 1))
459
- @index += 1
460
- else
461
- terminal_parse_failure("any character")
462
- r12 = nil
463
- end
464
- s5 << r12
465
- end
466
- if s5.last
467
- r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
468
- r5.extend(Text2)
469
- else
470
- @index = i5
471
- r5 = nil
472
- end
473
- if r5
474
- r1 = r5
475
- else
476
- @index = i1
477
- r1 = nil
478
- end
479
- end
480
- if r1
481
- s0 << r1
482
- else
483
- break
484
- end
485
- end
486
- if s0.empty?
487
- @index = i0
488
- r0 = nil
489
- else
490
- r0 = instantiate_node(TextNode,input, i0...index, s0)
491
- end
492
-
493
- node_cache[:text][start_index] = r0
494
-
495
- r0
496
- end
497
-
498
- def _nt_macro_name
499
- start_index = index
500
- if node_cache[:macro_name].has_key?(index)
501
- cached = node_cache[:macro_name][index]
502
- @index = cached.interval.end if cached
503
- return cached
504
- end
505
-
506
- s0, i0 = [], index
507
- loop do
508
- if has_terminal?('\G[^\\[\\]\\|\\\\\\s]', true, index)
509
- r1 = true
510
- @index += 1
511
- else
512
- r1 = nil
513
- end
514
- if r1
515
- s0 << r1
516
- else
517
- break
518
- end
519
- end
520
- if s0.empty?
521
- @index = i0
522
- r0 = nil
523
- else
524
- r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
525
- end
526
-
527
- node_cache[:macro_name][start_index] = r0
528
-
529
- r0
530
- end
531
-
532
- end
533
-
534
- # @private
535
- class GlyphLanguageParser < Treetop::Runtime::CompiledParser
536
- include GlyphLanguage
537
- end
538
-