livetext 0.9.20 → 0.9.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.lt3 +2 -0
- data/README.md +330 -339
- data/bin/livetext +0 -2
- data/imports/markdown.rb +6 -6
- data/imports/markdown_importable.rb +33 -34
- data/imports/tutorial.rb +1 -1
- data/lib/cmdargs.rb +26 -17
- data/lib/formatline.rb +4 -4
- data/lib/helpers.rb +30 -4
- data/lib/livetext.rb +1 -1
- data/lib/parser/general.rb +1 -1
- data/lib/parser/set.rb +2 -2
- data/lib/parser/string.rb +9 -8
- data/lib/processor.rb +19 -11
- data/lib/standard.rb +1 -1
- data/lib/userapi.rb +2 -2
- data/plugin/markdown.rb +6 -6
- data/plugin/tutorial.rb +4 -3
- data/test/snapshots/subset.txt +84 -0
- data/test/snapshots.rb +25 -38
- data/test/unit/parser/set.rb +17 -15
- data/test/unit/parser/string.rb +45 -6
- metadata +2 -11
- data/test/affirm/kbks.jpg +0 -0
- data/test/affirm/lm-kbks.lt +0 -19
- data/test/cleanup +0 -1
- data/test/newtest +0 -14
- data/test/sdtest +0 -6
- data/test/snapshots/OMIT.txt +0 -11
- data/test/snapshots/clusion.txt +0 -84
- data/test/snapshots/crap +0 -16
- data/test/snapshots/fixit +0 -6
data/README.md
CHANGED
@@ -110,6 +110,10 @@ for "code font." The formatting ends when the first blank space is encountered,
|
|
110
110
|
kind of suffixed character.
|
111
111
|
<p>
|
112
112
|
|
113
|
+
<p>
|
114
|
+
|
115
|
+
<p>
|
116
|
+
|
113
117
|
I also find it's common to want to terminate such a string with some kind of
|
114
118
|
naturally-occurring punctuation mark. If we double the initial delimiter, it
|
115
119
|
will be understood to terminate at the first period, comma, or right parenthesis.
|
@@ -136,15 +140,15 @@ Most of this is summarized in this example (taken from one of the testcases):
|
|
136
140
|
|
137
141
|
|
138
142
|
<font size=+1><b>Test: </font><font size=+2><tt>basic_formatting</tt></font></b></h3><br>
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
143
|
+
<font size=+1>
|
144
|
+
<table width=80% cellpadding=4>
|
145
|
+
<tr>
|
146
|
+
<td width=50%><b>Input</b></td>
|
147
|
+
<td width=50%><b>Output</b></td>
|
148
|
+
</tr>
|
149
|
+
<tr>
|
150
|
+
<td width=50% bgcolor=#fee0fe valign=top>
|
151
|
+
<pre> Here are examples of *boldface
|
148
152
|
and \_italics
|
149
153
|
and `code
|
150
154
|
as well as *[more complex] examples
|
@@ -156,9 +160,9 @@ Most of this is summarized in this example (taken from one of the testcases):
|
|
156
160
|
|
157
161
|
No need to escape these: * \_ `
|
158
162
|
</pre>
|
159
|
-
|
160
|
-
|
161
|
-
|
163
|
+
</td>
|
164
|
+
<td width=50% bgcolor=#eeeeee valign=top>
|
165
|
+
<pre> Here are examples of <b>boldface</b>
|
162
166
|
and <i>italics</i>
|
163
167
|
and <font size=+1><tt>code</tt></font>
|
164
168
|
as well as <b>more complex</b> examples
|
@@ -172,13 +176,11 @@ Most of this is summarized in this example (taken from one of the testcases):
|
|
172
176
|
|
173
177
|
No need to escape these: * \_ `
|
174
178
|
</pre>
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
+
</td>
|
180
|
+
</tr>
|
181
|
+
</table>
|
182
|
+
</font>
|
179
183
|
<br>
|
180
|
-
<p>
|
181
|
-
|
182
184
|
### Standard methods
|
183
185
|
The module <font size=+1><tt>Livetext::Standard</tt></font> contains the set of standard or predefined methods. Their
|
184
186
|
names are essentially the same as the names of the dot-commands, with occasional exceptions.
|
@@ -268,38 +270,38 @@ Here are some tests from the suite. The file name reflects the general purpose o
|
|
268
270
|
|
269
271
|
|
270
272
|
<font size=+1><b>Test: </font><font size=+2><tt>hello_world</tt></font></b></h3><br>
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
273
|
+
<font size=+1>
|
274
|
+
<table width=80% cellpadding=4>
|
275
|
+
<tr>
|
276
|
+
<td width=50%><b>Input</b></td>
|
277
|
+
<td width=50%><b>Output</b></td>
|
278
|
+
</tr>
|
279
|
+
<tr>
|
280
|
+
<td width=50% bgcolor=#fee0fe valign=top>
|
281
|
+
<pre> Hello,
|
280
282
|
world!
|
281
283
|
</pre>
|
282
|
-
|
283
|
-
|
284
|
-
|
284
|
+
</td>
|
285
|
+
<td width=50% bgcolor=#eeeeee valign=top>
|
286
|
+
<pre> Hello,
|
285
287
|
world!
|
286
288
|
</pre>
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
289
|
+
</td>
|
290
|
+
</tr>
|
291
|
+
</table>
|
292
|
+
</font>
|
291
293
|
<br>
|
292
294
|
|
293
295
|
<font size=+1><b>Test: </font><font size=+2><tt>comments_ignored_1</tt></font></b></h3><br>
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
296
|
+
<font size=+1>
|
297
|
+
<table width=80% cellpadding=4>
|
298
|
+
<tr>
|
299
|
+
<td width=50%><b>Input</b></td>
|
300
|
+
<td width=50%><b>Output</b></td>
|
301
|
+
</tr>
|
302
|
+
<tr>
|
303
|
+
<td width=50% bgcolor=#fee0fe valign=top>
|
304
|
+
<pre> . Comments are ignored
|
303
305
|
abc 123
|
304
306
|
this is a test
|
305
307
|
. whether at beginning, middle, or
|
@@ -307,29 +309,29 @@ Here are some tests from the suite. The file name reflects the general purpose o
|
|
307
309
|
still more stuff
|
308
310
|
. end of the file
|
309
311
|
</pre>
|
310
|
-
|
311
|
-
|
312
|
-
|
312
|
+
</td>
|
313
|
+
<td width=50% bgcolor=#eeeeee valign=top>
|
314
|
+
<pre> abc 123
|
313
315
|
this is a test
|
314
316
|
more stuff
|
315
317
|
still more stuff
|
316
318
|
</pre>
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
319
|
+
</td>
|
320
|
+
</tr>
|
321
|
+
</table>
|
322
|
+
</font>
|
321
323
|
<br>
|
322
324
|
|
323
325
|
<font size=+1><b>Test: </font><font size=+2><tt>block_comment</tt></font></b></h3><br>
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
326
|
+
<font size=+1>
|
327
|
+
<table width=80% cellpadding=4>
|
328
|
+
<tr>
|
329
|
+
<td width=50%><b>Input</b></td>
|
330
|
+
<td width=50%><b>Output</b></td>
|
331
|
+
</tr>
|
332
|
+
<tr>
|
333
|
+
<td width=50% bgcolor=#fee0fe valign=top>
|
334
|
+
<pre> .comment
|
333
335
|
This is
|
334
336
|
a comment
|
335
337
|
.end
|
@@ -349,107 +351,106 @@ Here are some tests from the suite. The file name reflects the general purpose o
|
|
349
351
|
.end
|
350
352
|
|
351
353
|
</pre>
|
352
|
-
|
353
|
-
|
354
|
-
|
354
|
+
</td>
|
355
|
+
<td width=50% bgcolor=#eeeeee valign=top>
|
356
|
+
<pre> abc 123
|
355
357
|
xyz
|
356
358
|
one
|
357
359
|
more
|
358
360
|
time
|
359
361
|
</pre>
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
362
|
+
</td>
|
363
|
+
</tr>
|
364
|
+
</table>
|
365
|
+
</font>
|
364
366
|
<br>
|
365
367
|
|
366
368
|
<font size=+1><b>Test: </font><font size=+2><tt>def_method</tt></font></b></h3><br>
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
369
|
+
<font size=+1>
|
370
|
+
<table width=80% cellpadding=4>
|
371
|
+
<tr>
|
372
|
+
<td width=50%><b>Input</b></td>
|
373
|
+
<td width=50%><b>Output</b></td>
|
374
|
+
</tr>
|
375
|
+
<tr>
|
376
|
+
<td width=50% bgcolor=#fee0fe valign=top>
|
377
|
+
<pre> .backtrace
|
376
378
|
abc
|
377
379
|
123
|
378
|
-
.def foobar
|
380
|
+
.def foobar # yet another experimental comment
|
379
381
|
::STDERR.puts "This is the"
|
380
382
|
::STDERR.puts "foobar method"
|
381
383
|
.end
|
382
384
|
xyz
|
383
|
-
.foobar
|
385
|
+
.foobar # and still another
|
384
386
|
xyzzy
|
385
387
|
123
|
386
388
|
</pre>
|
387
|
-
|
388
|
-
|
389
|
-
|
389
|
+
</td>
|
390
|
+
<td width=50% bgcolor=#eeeeee valign=top>
|
391
|
+
<pre> abc
|
390
392
|
123
|
391
393
|
xyz
|
392
394
|
xyzzy
|
393
395
|
123
|
394
396
|
</pre>
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
397
|
+
</td>
|
398
|
+
</tr>
|
399
|
+
</table>
|
400
|
+
</font>
|
399
401
|
<br>
|
400
402
|
|
401
403
|
<font size=+1><b>Test: </font><font size=+2><tt>simple_vars</tt></font></b></h3><br>
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
404
|
+
<font size=+1>
|
405
|
+
<table width=80% cellpadding=4>
|
406
|
+
<tr>
|
407
|
+
<td width=50%><b>Input</b></td>
|
408
|
+
<td width=50%><b>Output</b></td>
|
409
|
+
</tr>
|
410
|
+
<tr>
|
411
|
+
<td width=50% bgcolor=#fee0fe valign=top>
|
412
|
+
<pre> Just
|
411
413
|
some text.
|
412
414
|
.set name=GulliverFoyle, nation=Terra
|
413
415
|
Hi, there.
|
414
416
|
$name is my name, and $nation is my nation.
|
415
|
-
I'm $name, from $nation
|
417
|
+
I'm $name, from $nation\.
|
416
418
|
That's all.
|
417
419
|
</pre>
|
418
|
-
|
419
|
-
|
420
|
-
|
420
|
+
</td>
|
421
|
+
<td width=50% bgcolor=#eeeeee valign=top>
|
422
|
+
<pre> Just
|
421
423
|
some text.
|
422
424
|
Hi, there.
|
423
425
|
GulliverFoyle is my name, and Terra is my nation.
|
424
426
|
I'm GulliverFoyle, from Terra.
|
425
427
|
That's all.
|
426
428
|
</pre>
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
429
|
+
</td>
|
430
|
+
</tr>
|
431
|
+
</table>
|
432
|
+
</font>
|
431
433
|
<br>
|
432
434
|
|
433
435
|
<font size=+1><b>Test: </font><font size=+2><tt>simple_include</tt></font></b></h3><br>
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
.debug
|
436
|
+
<font size=+1>
|
437
|
+
<table width=80% cellpadding=4>
|
438
|
+
<tr>
|
439
|
+
<td width=50%><b>Input</b></td>
|
440
|
+
<td width=50%><b>Output</b></td>
|
441
|
+
</tr>
|
442
|
+
<tr>
|
443
|
+
<td width=50% bgcolor=#fee0fe valign=top>
|
444
|
+
<pre> Here I am
|
444
445
|
trying to
|
445
446
|
include
|
446
447
|
.include simplefile.inc
|
447
448
|
I hope that
|
448
449
|
worked.
|
449
450
|
</pre>
|
450
|
-
|
451
|
-
|
452
|
-
|
451
|
+
</td>
|
452
|
+
<td width=50% bgcolor=#eeeeee valign=top>
|
453
|
+
<pre> Here I am
|
453
454
|
trying to
|
454
455
|
include
|
455
456
|
a simple
|
@@ -457,61 +458,61 @@ Here are some tests from the suite. The file name reflects the general purpose o
|
|
457
458
|
I hope that
|
458
459
|
worked.
|
459
460
|
</pre>
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
461
|
+
</td>
|
462
|
+
</tr>
|
463
|
+
</table>
|
464
|
+
</font>
|
464
465
|
<br>
|
465
466
|
|
466
467
|
<font size=+1><b>Test: </font><font size=+2><tt>simple_mixin</tt></font></b></h3><br>
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
468
|
+
<font size=+1>
|
469
|
+
<table width=80% cellpadding=4>
|
470
|
+
<tr>
|
471
|
+
<td width=50%><b>Input</b></td>
|
472
|
+
<td width=50%><b>Output</b></td>
|
473
|
+
</tr>
|
474
|
+
<tr>
|
475
|
+
<td width=50% bgcolor=#fee0fe valign=top>
|
476
|
+
<pre> Here I am
|
476
477
|
testing a simple mixin
|
477
478
|
.mixin simple\_mixin
|
478
|
-
Now call
|
479
|
+
Now call a method:
|
479
480
|
.hello\_world
|
480
481
|
That's all.
|
481
482
|
</pre>
|
482
|
-
|
483
|
-
|
484
|
-
|
483
|
+
</td>
|
484
|
+
<td width=50% bgcolor=#eeeeee valign=top>
|
485
|
+
<pre> Here I am
|
485
486
|
testing a simple mixin
|
486
|
-
Now call
|
487
|
+
Now call a method:
|
487
488
|
Hello, world.
|
488
489
|
That's all.
|
489
490
|
</pre>
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
491
|
+
</td>
|
492
|
+
</tr>
|
493
|
+
</table>
|
494
|
+
</font>
|
494
495
|
<br>
|
495
496
|
|
496
497
|
<font size=+1><b>Test: </font><font size=+2><tt>simple_copy</tt></font></b></h3><br>
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
498
|
+
<font size=+1>
|
499
|
+
<table width=80% cellpadding=4>
|
500
|
+
<tr>
|
501
|
+
<td width=50%><b>Input</b></td>
|
502
|
+
<td width=50%><b>Output</b></td>
|
503
|
+
</tr>
|
504
|
+
<tr>
|
505
|
+
<td width=50% bgcolor=#fee0fe valign=top>
|
506
|
+
<pre> The copy command
|
506
507
|
copies any file
|
507
508
|
without interpretation,
|
508
509
|
such as:
|
509
510
|
.copy simplefile.inc
|
510
511
|
That is all.
|
511
512
|
</pre>
|
512
|
-
|
513
|
-
|
514
|
-
|
513
|
+
</td>
|
514
|
+
<td width=50% bgcolor=#eeeeee valign=top>
|
515
|
+
<pre> The copy command
|
515
516
|
copies any file
|
516
517
|
without interpretation,
|
517
518
|
such as:
|
@@ -519,29 +520,29 @@ Here are some tests from the suite. The file name reflects the general purpose o
|
|
519
520
|
include file.
|
520
521
|
That is all.
|
521
522
|
</pre>
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
523
|
+
</td>
|
524
|
+
</tr>
|
525
|
+
</table>
|
526
|
+
</font>
|
526
527
|
<br>
|
527
528
|
|
528
529
|
<font size=+1><b>Test: </font><font size=+2><tt>copy_is_raw</tt></font></b></h3><br>
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
530
|
+
<font size=+1>
|
531
|
+
<table width=80% cellpadding=4>
|
532
|
+
<tr>
|
533
|
+
<td width=50%><b>Input</b></td>
|
534
|
+
<td width=50%><b>Output</b></td>
|
535
|
+
</tr>
|
536
|
+
<tr>
|
537
|
+
<td width=50% bgcolor=#fee0fe valign=top>
|
538
|
+
<pre> A copy command
|
538
539
|
does not interpret its input:
|
539
|
-
.copy rawtext.inc
|
540
|
+
.copy rawtext.inc # another useless comment
|
540
541
|
That's all.
|
541
542
|
</pre>
|
542
|
-
|
543
|
-
|
544
|
-
|
543
|
+
</td>
|
544
|
+
<td width=50% bgcolor=#eeeeee valign=top>
|
545
|
+
<pre> A copy command
|
545
546
|
does not interpret its input:
|
546
547
|
This is not a comment:
|
547
548
|
.comment woohoo!
|
@@ -549,22 +550,23 @@ Here are some tests from the suite. The file name reflects the general purpose o
|
|
549
550
|
.no\_such\_method
|
550
551
|
That's all.
|
551
552
|
</pre>
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
553
|
+
</td>
|
554
|
+
</tr>
|
555
|
+
</table>
|
556
|
+
</font>
|
556
557
|
<br>
|
557
558
|
|
558
559
|
<font size=+1><b>Test: </font><font size=+2><tt>raw_text_block</tt></font></b></h3><br>
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
560
|
+
<font size=+1>
|
561
|
+
<table width=80% cellpadding=4>
|
562
|
+
<tr>
|
563
|
+
<td width=50%><b>Input</b></td>
|
564
|
+
<td width=50%><b>Output</b></td>
|
565
|
+
</tr>
|
566
|
+
<tr>
|
567
|
+
<td width=50% bgcolor=#fee0fe valign=top>
|
568
|
+
<pre> .backtrace
|
569
|
+
This text block will be passed thru
|
568
570
|
with no interpretation or processing:
|
569
571
|
.raw
|
570
572
|
.comment
|
@@ -583,9 +585,9 @@ Here are some tests from the suite. The file name reflects the general purpose o
|
|
583
585
|
*(gamma rays)
|
584
586
|
\_\_EOF\_\_
|
585
587
|
</pre>
|
586
|
-
|
587
|
-
|
588
|
-
|
588
|
+
</td>
|
589
|
+
<td width=50% bgcolor=#eeeeee valign=top>
|
590
|
+
<pre> This text block will be passed thru
|
589
591
|
with no interpretation or processing:
|
590
592
|
.comment
|
591
593
|
This isn't a
|
@@ -602,13 +604,11 @@ Here are some tests from the suite. The file name reflects the general purpose o
|
|
602
604
|
\_(beta max)
|
603
605
|
*(gamma rays)
|
604
606
|
</pre>
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
607
|
+
</td>
|
608
|
+
</tr>
|
609
|
+
</table>
|
610
|
+
</font>
|
609
611
|
<br>
|
610
|
-
<p>
|
611
|
-
|
612
612
|
### Writing custom methods
|
613
613
|
Suppose you wanted to write a method called <font size=+1><tt>chapter</tt></font> that would simply
|
614
614
|
output a chapter number and title with certain heading tags and a
|
@@ -687,7 +687,7 @@ What are some other helper methods? Here's a list.
|
|
687
687
|
</tr>
|
688
688
|
<tr>
|
689
689
|
<td valign=top><font size=+1><tt>_body</tt></font> </td>
|
690
|
-
<td valign=top> Returns a string (or enumerator) giving access to the text block (preceding
|
690
|
+
<td valign=top> Returns a string (or enumerator) giving access to the text block (preceding .end)</td>
|
691
691
|
</tr>
|
692
692
|
<tr>
|
693
693
|
<td valign=top><font size=+1><tt>_puts</tt></font> </td>
|
@@ -718,18 +718,18 @@ in the test suite.
|
|
718
718
|
|
719
719
|
|
720
720
|
<font size=+1><b>Test: </font><font size=+2><tt>example_alpha</tt></font></b></h3><br>
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
721
|
+
<font size=+1>
|
722
|
+
<table width=80% cellpadding=4>
|
723
|
+
<tr>
|
724
|
+
<td width=50%><b>Input</b></td>
|
725
|
+
<td width=50%><b>Output</b></td>
|
726
|
+
</tr>
|
727
|
+
<tr>
|
728
|
+
<td width=50% bgcolor=#fee0fe valign=top>
|
729
|
+
<pre> .def alpha
|
730
730
|
text = \_body.to\_a.join(" ")
|
731
731
|
words = text.split.sort
|
732
|
-
words.each {|w| \
|
732
|
+
words.each {|w| \_out " #{w}" }
|
733
733
|
.end
|
734
734
|
Here is an alphabetized list:
|
735
735
|
|
@@ -743,9 +743,9 @@ in the test suite.
|
|
743
743
|
|
744
744
|
That's all.
|
745
745
|
</pre>
|
746
|
-
|
747
|
-
|
748
|
-
|
746
|
+
</td>
|
747
|
+
<td width=50% bgcolor=#eeeeee valign=top>
|
748
|
+
<pre> Here is an alphabetized list:
|
749
749
|
<p>
|
750
750
|
|
751
751
|
aardvark
|
@@ -769,38 +769,36 @@ in the test suite.
|
|
769
769
|
|
770
770
|
That's all.
|
771
771
|
</pre>
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
772
|
+
</td>
|
773
|
+
</tr>
|
774
|
+
</table>
|
775
|
+
</font>
|
776
776
|
<br>
|
777
|
-
<p>
|
778
|
-
|
779
777
|
I'll let that code stand on its own. Now suppose you wanted to allow columnar output. Let's
|
780
778
|
have the user specify a number of columns (from 1 to 5, defaulting to 1).
|
781
779
|
<p>
|
782
780
|
|
783
781
|
|
784
782
|
<font size=+1><b>Test: </font><font size=+2><tt>example_alpha2</tt></font></b></h3><br>
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
783
|
+
<font size=+1>
|
784
|
+
<table width=80% cellpadding=4>
|
785
|
+
<tr>
|
786
|
+
<td width=50%><b>Input</b></td>
|
787
|
+
<td width=50%><b>Output</b></td>
|
788
|
+
</tr>
|
789
|
+
<tr>
|
790
|
+
<td width=50% bgcolor=#fee0fe valign=top>
|
791
|
+
<pre> .def alpha
|
794
792
|
cols = \_args.first
|
795
793
|
cols = "1" if cols == ""
|
796
794
|
cols = cols.to\_i
|
797
795
|
raise "Columns must be 1-5" unless cols.between?(1,5)
|
798
|
-
text = \_body\
|
796
|
+
text = \_body.join("\n")
|
799
797
|
text.gsub!(/\n/, " ")
|
800
798
|
words = text.split.sort
|
801
799
|
words.each\_slice(cols) do |row|
|
802
|
-
row.each {|w| \
|
803
|
-
\
|
800
|
+
row.each {|w| \_out! '%-15s' % w }
|
801
|
+
\_out
|
804
802
|
end
|
805
803
|
.end
|
806
804
|
Here is an alphabetized list:
|
@@ -815,9 +813,9 @@ have the user specify a number of columns (from 1 to 5, defaulting to 1).
|
|
815
813
|
|
816
814
|
And that is all.
|
817
815
|
</pre>
|
818
|
-
|
819
|
-
|
820
|
-
|
816
|
+
</td>
|
817
|
+
<td width=50% bgcolor=#eeeeee valign=top>
|
818
|
+
<pre> Here is an alphabetized list:
|
821
819
|
<p>
|
822
820
|
|
823
821
|
aardvark anamorphic anarchist
|
@@ -830,13 +828,11 @@ have the user specify a number of columns (from 1 to 5, defaulting to 1).
|
|
830
828
|
|
831
829
|
And that is all.
|
832
830
|
</pre>
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
831
|
+
</td>
|
832
|
+
</tr>
|
833
|
+
</table>
|
834
|
+
</font>
|
837
835
|
<br>
|
838
|
-
<p>
|
839
|
-
|
840
836
|
What if we wanted to store the code outside the text file? There is more than one way to
|
841
837
|
do this.
|
842
838
|
<p>
|
@@ -851,12 +847,12 @@ in here (and nothing else).
|
|
851
847
|
def alpha
|
852
848
|
cols = <i>args.first</i>
|
853
849
|
cols = "1" if cols == ""
|
854
|
-
cols = cols.
|
850
|
+
cols = cols.to_i
|
855
851
|
raise "Columns must be 1-5" unless cols.between?(1,5)
|
856
852
|
text = <i>body.join</i>
|
857
|
-
text.gsub!(
|
853
|
+
text.gsub!(/n/, " ")
|
858
854
|
words = text.split.sort
|
859
|
-
words.
|
855
|
+
words.each_slice(cols) do |row|
|
860
856
|
row.each {|w| <i>print</i> '%-15s' % w }
|
861
857
|
<i>puts</i>
|
862
858
|
end
|
@@ -881,77 +877,73 @@ The output, of course, is the same.
|
|
881
877
|
<p>
|
882
878
|
|
883
879
|
You can define variables in Livetext, defined with <font size=+1><tt>.set</tt></font> and
|
884
|
-
referenced with a <font size=+1><tt
|
880
|
+
referenced with a <font size=+1><tt>$$</tt></font>. Later there will be a few predefined
|
885
881
|
variables. Variables are just string values.
|
886
882
|
<p>
|
887
883
|
|
888
884
|
|
889
885
|
<font size=+1><b>Test: </font><font size=+2><tt>simple_vars</tt></font></b></h3><br>
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
886
|
+
<font size=+1>
|
887
|
+
<table width=80% cellpadding=4>
|
888
|
+
<tr>
|
889
|
+
<td width=50%><b>Input</b></td>
|
890
|
+
<td width=50%><b>Output</b></td>
|
891
|
+
</tr>
|
892
|
+
<tr>
|
893
|
+
<td width=50% bgcolor=#fee0fe valign=top>
|
894
|
+
<pre> Just
|
899
895
|
some text.
|
900
896
|
.set name=GulliverFoyle, nation=Terra
|
901
897
|
Hi, there.
|
902
898
|
$name is my name, and $nation is my nation.
|
903
|
-
I'm $name, from $nation
|
899
|
+
I'm $name, from $nation\.
|
904
900
|
That's all.
|
905
901
|
</pre>
|
906
|
-
|
907
|
-
|
908
|
-
|
902
|
+
</td>
|
903
|
+
<td width=50% bgcolor=#eeeeee valign=top>
|
904
|
+
<pre> Just
|
909
905
|
some text.
|
910
906
|
Hi, there.
|
911
907
|
GulliverFoyle is my name, and Terra is my nation.
|
912
908
|
I'm GulliverFoyle, from Terra.
|
913
909
|
That's all.
|
914
910
|
</pre>
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
911
|
+
</td>
|
912
|
+
</tr>
|
913
|
+
</table>
|
914
|
+
</font>
|
919
915
|
<br>
|
920
|
-
<p>
|
921
|
-
|
922
916
|
If a variable needs to contain spaces, you can double-quote it.
|
923
917
|
<p>
|
924
918
|
|
925
919
|
|
926
920
|
<font size=+1><b>Test: </font><font size=+2><tt>more_complex_vars</tt></font></b></h3><br>
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
921
|
+
<font size=+1>
|
922
|
+
<table width=80% cellpadding=4>
|
923
|
+
<tr>
|
924
|
+
<td width=50%><b>Input</b></td>
|
925
|
+
<td width=50%><b>Output</b></td>
|
926
|
+
</tr>
|
927
|
+
<tr>
|
928
|
+
<td width=50% bgcolor=#fee0fe valign=top>
|
929
|
+
<pre> Just some more text.
|
936
930
|
.set bday="May 31", date="5/31"
|
937
931
|
My birthday is $bday, so they tell me.
|
938
932
|
That's $date if you're American.
|
939
933
|
That's all.
|
940
934
|
</pre>
|
941
|
-
|
942
|
-
|
943
|
-
|
935
|
+
</td>
|
936
|
+
<td width=50% bgcolor=#eeeeee valign=top>
|
937
|
+
<pre> Just some more text.
|
944
938
|
My birthday is May 31, so they tell me.
|
945
939
|
That's 5/31 if you're American.
|
946
940
|
That's all.
|
947
941
|
</pre>
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
942
|
+
</td>
|
943
|
+
</tr>
|
944
|
+
</table>
|
945
|
+
</font>
|
952
946
|
<br>
|
953
|
-
<p>
|
954
|
-
|
955
947
|
Livetext permits user-defined functions (as well as defining a few
|
956
948
|
predefined ones). Call a function with <font size=+1><tt>$$</tt></font> and (if applicable) pass
|
957
949
|
a single string parameter between brackets.
|
@@ -959,20 +951,20 @@ a single string parameter between brackets.
|
|
959
951
|
|
960
952
|
|
961
953
|
<font size=+1><b>Test: </font><font size=+2><tt>functions</tt></font></b></h3><br>
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
954
|
+
<font size=+1>
|
955
|
+
<table width=80% cellpadding=4>
|
956
|
+
<tr>
|
957
|
+
<td width=50%><b>Input</b></td>
|
958
|
+
<td width=50%><b>Output</b></td>
|
959
|
+
</tr>
|
960
|
+
<tr>
|
961
|
+
<td width=50% bgcolor=#fee0fe valign=top>
|
962
|
+
<pre> Testing out
|
971
963
|
some functions
|
972
964
|
here...
|
973
965
|
|
974
966
|
.func myfunc
|
975
|
-
|
967
|
+
"Eureka!"
|
976
968
|
.end
|
977
969
|
|
978
970
|
I am calling $$myfunc here...
|
@@ -983,8 +975,7 @@ a single string parameter between brackets.
|
|
983
975
|
(which it can parse itself as needed):
|
984
976
|
|
985
977
|
.func mean
|
986
|
-
list =
|
987
|
-
list = list.split(",").map(&:to\_f)
|
978
|
+
list = param.split(",").map(&:to\_f)
|
988
979
|
sum = list.inject(0, :+)
|
989
980
|
avg = sum / list.size.to\_f
|
990
981
|
avg.to\_s
|
@@ -995,9 +986,9 @@ a single string parameter between brackets.
|
|
995
986
|
Some functions like date and time are predefined.
|
996
987
|
|
997
988
|
</pre>
|
998
|
-
|
999
|
-
|
1000
|
-
|
989
|
+
</td>
|
990
|
+
<td width=50% bgcolor=#eeeeee valign=top>
|
991
|
+
<pre> Testing out
|
1001
992
|
some functions
|
1002
993
|
here...
|
1003
994
|
<p>
|
@@ -1018,13 +1009,11 @@ a single string parameter between brackets.
|
|
1018
1009
|
<p>
|
1019
1010
|
|
1020
1011
|
</pre>
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1012
|
+
</td>
|
1013
|
+
</tr>
|
1014
|
+
</table>
|
1015
|
+
</font>
|
1025
1016
|
<br>
|
1026
|
-
<p>
|
1027
|
-
|
1028
1017
|
There is an important feature that has not yet been implemented (the
|
1029
1018
|
<font size=+1><tt>require</tt></font> method). Like Ruby's <font size=+1><tt>require</tt></font>, it will grab Ruby code and
|
1030
1019
|
load it; however, unlike <font size=+1><tt>mixin</tt></font>, it will load it into a customized
|
@@ -1039,52 +1028,54 @@ on that new custom object. I plan to implement this later.
|
|
1039
1028
|
This list is not prioritized yet.
|
1040
1029
|
<p>
|
1041
1030
|
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1031
|
+
* <strike>Add versioning information </strike>
|
1032
|
+
* <strike>Clean up code structure</strike>
|
1033
|
+
* Add RDoc
|
1034
|
+
* <strike>Think about command line executable</strike>
|
1035
|
+
* <strike>Write as pure library in addition to executable</strike>
|
1036
|
+
* <strike>Package as gem</strike>
|
1037
|
+
* Document: <font size=+1><tt>require</tt></font> <font size=+1><tt>include</tt></font> <font size=+1><tt>copy</tt></font> <font size=+1><tt>mixin</tt></font> <font size=+1><tt>errout</tt></font> and others
|
1038
|
+
* Need <strike>much</strike> better error checking and corresponding tests
|
1039
|
+
* Worry about nesting of elements (probably mostly disallow)
|
1040
|
+
* Think about UTF-8
|
1041
|
+
* Document API fully
|
1042
|
+
* Add <font size=+1><tt>_raw_args</tt></font> and let <font size=+1><tt>_args</tt></font> honor quotes
|
1043
|
+
* Support quotes in <font size=+1><tt>.set</tt></font> values
|
1044
|
+
* Support "namespaced" variables (`[.set code.font="whatever"])
|
1045
|
+
* <strike>Support functions (``[func is undefined]$c)</strike>
|
1046
|
+
* Support function namespacing
|
1047
|
+
* Create predefined variables (e.g., <font size=+1><tt>[source_file is undefined]$</tt></font>, <font size=+1><tt>$_line])</tt></font>
|
1048
|
+
* Create predefined functions (e.g., <font size=+1><tt>$_date</tt></font>)
|
1049
|
+
* More support for markdown
|
1050
|
+
* Allow turning on/off: formatting, variable interpolation, function interpolation?
|
1051
|
+
* <font size=+1><tt>.require</tt></font> with file and sigil parameters
|
1052
|
+
* Investigate "common intermediate format" - output renderers all read it
|
1053
|
+
* Comments passed through (e.g. as HTML comments)
|
1054
|
+
* <font size=+1><tt>.run</tt></font> to execute arbitrary Ruby code inline?
|
1055
|
+
* Concept of <font size=+1><tt>.proc</tt></font> (guaranteed to return no value, produce no output)?
|
1056
|
+
* Exceptions??
|
1057
|
+
* Ruby <font size=+1><tt>[AFE is undefined]$</tt></font> levels?
|
1058
|
+
* Warn when overriding existing names?
|
1059
|
+
* Think about passing data in (erb replacement)
|
1060
|
+
* <strike>]Allow</strike> custom ending tag on <font size=+1><tt>raw</tt></font> method
|
1061
|
+
* <strike>Ignore first blank line after `[.end</strike>? (and after raw-tag?)
|
1062
|
+
* Allow/encourage custom <font size=+1><tt>passthru</tt></font> method?
|
1063
|
+
* Must have sane support for CSS
|
1064
|
+
* Support for Pygments and/or other code processors
|
1065
|
+
* Support for gists? arbitrary links? other remote resouces?
|
1066
|
+
* Small libraries for special purposes (books? special Softcover support? blogs? PDF? RMagick?)
|
1067
|
+
* Experiment with idea of special libraries having pluggable output formats (via Ruby mixin?)
|
1068
|
+
* Imagining a lib that can run/test code fragments as part of document generation
|
1069
|
+
* Create vim (emacs?) syntax files
|
1070
|
+
* Someday: Support other languages (Elixir, Python, ...)
|
1071
|
+
* <font size=+1><tt>.pry</tt></font> method?
|
1072
|
+
* <font size=+1><tt>.irb</tt></font> method?
|
1073
|
+
* Other debugging features
|
1074
|
+
* Feature to "break" to EOF?
|
1075
|
+
* <font size=+1><tt>.meth?</tt></font> method ending in <font size=+1><tt>?</tt></font> takes a block that may be processed or thrown away (`.else perhaps?)
|
1076
|
+
* <font size=+1><tt>.dump</tt></font> to dump all variables and their values
|
1077
|
+
* <font size=+1><tt>.if</tt></font> and <font size=+1><tt>.else</tt></font>?
|
1078
|
+
* Make any/all delimiters configurable
|
1079
|
+
* HTML helper? (in their own library?)
|
1080
|
+
<p>
|
1081
|
+
|