livetext 0.8.75 → 0.8.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.lt3 +45 -28
- data/README.md +288 -87
- data/lib/livetext.rb +1 -1
- data/lib/standard.rb +1 -1
- data/plugin/tutorial.rb +10 -2
- data/test/data/basic_formatting/expected-output.txt +6 -3
- data/test/data/basic_formatting/source.lt3 +6 -3
- data/test/data/functions/expected-output.txt +12 -0
- data/test/data/functions/source.lt3 +16 -0
- data/test/data/raw_text_block/expected-output.txt +3 -1
- data/test/data/raw_text_block/source.lt3 +3 -1
- data/test/data/simple_vars/source.lt3 +1 -1
- data/test/data/table_with_heredocs/expected-output.txt +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc5fb0814d68c5672211c15ec2e37cfdf1eb0e82509249fa627f4fcc809653a6
|
4
|
+
data.tar.gz: dd997198c3af0c32b1125fb403ee67d225083c302c3d0bca32c74c89554cf511
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d52c231252860de533870f9a31ef9b0c68cfa6579f64d19ed1177e63e9a008e5f35a8aea893ed34a546a419e8f92f644bdf7aa85638786cd55e65007e6202af
|
7
|
+
data.tar.gz: 7822f9b1f34fdfc7791831c425bf079e25f12e35972855c77b267306957cef48c3394bd04a59385c79d8edb517e3d98be47957ab6eba5d42fb5c4442688089f9
|
data/README.lt3
CHANGED
@@ -130,27 +130,28 @@ names are essentially the same as the names of the dot-commands, with occasional
|
|
130
130
|
(For example, it is impractical to use the name `def as a method name, so the module has a
|
131
131
|
`_def method instead.) Here is the current list:
|
132
132
|
|
133
|
-
.
|
134
|
-
`comment
|
135
|
-
`errout
|
136
|
-
`def
|
137
|
-
`set
|
138
|
-
`include
|
139
|
-
`mixin
|
140
|
-
`copy
|
141
|
-
`r
|
142
|
-
`raw
|
143
|
-
`func
|
144
|
-
`say
|
145
|
-
`banner
|
146
|
-
`quit
|
147
|
-
`nopass
|
148
|
-
`include
|
149
|
-
`debug
|
150
|
-
`nopara
|
151
|
-
`newpage
|
133
|
+
.xtable
|
134
|
+
`comment :: Start a comment block
|
135
|
+
`errout :: Write an error message to STDERR
|
136
|
+
`def :: Define a new method inline
|
137
|
+
`set :: Assign values to variables for later interpolation
|
138
|
+
`include :: Include an outside text file (to be interpreted as Livetext)
|
139
|
+
`mixin :: Mix this file of Ruby methods into the standard namespace
|
140
|
+
`copy :: Copy this input file verbatim (no interpretation)
|
141
|
+
`r :: Pass a single line through without processing
|
142
|
+
`raw :: Pass this special text block (terminated with ``__EOF__) directly into output without processing
|
143
|
+
`func :: Define a function to be invoked inline
|
144
|
+
`say :: Print a message to the screen
|
145
|
+
`banner :: Print a "noticeable" message to the screen
|
146
|
+
`quit :: End processing and exit
|
147
|
+
`nopass :: Don't pass lines through (just honor commands)
|
148
|
+
`include :: Read and process another file (typically a `.lt3 file)
|
149
|
+
`debug :: Turn on debugging
|
150
|
+
`nopara :: Turn off the "blank line implies new paragraph" switch
|
151
|
+
`newpage :: Start a new output page
|
152
152
|
.end
|
153
153
|
|
154
|
+
|
154
155
|
.section Examples from the tests
|
155
156
|
|
156
157
|
Here are some tests from the suite. The file name reflects the general purpose of the test.
|
@@ -230,14 +231,14 @@ Here is the HTML output of the previous example:
|
|
230
231
|
|
231
232
|
What are some other helper methods? Here's a list.
|
232
233
|
|
233
|
-
.
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
234
|
+
.xtable
|
235
|
+
`_args :: Returns an array of arguments for the method (or an enumerator for that array)
|
236
|
+
`_data :: A single "unsplit" string of all arguments in raw form
|
237
|
+
`_body :: Returns a string (or enumerator) giving access to the text block (preceding ``.end)
|
238
|
+
`_puts :: Write a line to output (STDOUT or wherever)
|
239
|
+
`_print :: Write a line to output (STDOUT or wherever) without a newline
|
240
|
+
`_formatting :: A function transforming boldface, italics, and monospace (Livetext conventions)
|
241
|
+
`_passthru :: Feed a line directly into output after transforming and substituting
|
241
242
|
.end
|
242
243
|
|
243
244
|
Note that the last three methods are typically _not called in your own code. They could be,
|
@@ -294,11 +295,27 @@ Now the `.lt3 file can be written this way:
|
|
294
295
|
cytology fusillade ectomorph
|
295
296
|
.end
|
296
297
|
|
297
|
-
|
298
|
+
And that is all.
|
298
299
|
.end
|
299
300
|
|
300
301
|
The output, of course, is the same.
|
301
302
|
|
303
|
+
You can define variables in Livetext, defined with `.set and
|
304
|
+
referenced with a ``$. Later there will be a few predefined
|
305
|
+
variables. Variables are just string values.
|
306
|
+
|
307
|
+
.testcase simple_vars
|
308
|
+
|
309
|
+
If a variable needs to contain spaces, you can double-quote it.
|
310
|
+
|
311
|
+
.testcase more_complex_vars
|
312
|
+
|
313
|
+
Livetext permits user-defined functions (as well as defining a few
|
314
|
+
predefined ones). Call a function with `$$ and (if applicable) pass
|
315
|
+
a single string parameter between brackets.
|
316
|
+
|
317
|
+
.testcase functions
|
318
|
+
|
302
319
|
There is an important feature that has not yet been implemented (the
|
303
320
|
`require method). Like Ruby's ``require, it will grab Ruby code and
|
304
321
|
load it; however, unlike ``mixin, it will load it into a customized
|
data/README.md
CHANGED
@@ -1,7 +1,5 @@
|
|
1
|
-
<
|
2
|
-
|
3
|
-
tt {font-size: 14; bold }
|
4
|
-
</style>
|
1
|
+
<p>
|
2
|
+
|
5
3
|
# Livetext: A smart processor for text
|
6
4
|
<b>This README is currently mangled. Fixes coming soon!</b>
|
7
5
|
<p>
|
@@ -146,24 +144,30 @@ Most of this is summarized in this example (taken from one of the testcases):
|
|
146
144
|
</tr>
|
147
145
|
<tr>
|
148
146
|
<td width=50% bgcolor=#fee0fe valign=top>
|
149
|
-
<pre> Here are examples of *boldface
|
150
|
-
|
147
|
+
<pre> Here are examples of *boldface
|
148
|
+
and \_italics
|
149
|
+
and `code
|
150
|
+
as well as *[more complex] examples
|
151
|
+
of \_[italicized text]
|
151
152
|
and `[code font].
|
152
153
|
|
153
154
|
Here are some random punctuation marks:
|
154
|
-
# .
|
155
|
+
; # . * \_ ` : @ % ^ & $
|
155
156
|
|
156
157
|
No need to escape these: * \_ `
|
157
158
|
</pre>
|
158
159
|
</td>
|
159
160
|
<td width=50% bgcolor=#eeeeee valign=top>
|
160
|
-
<pre> Here are examples of <b>boldface</b>
|
161
|
-
|
161
|
+
<pre> Here are examples of <b>boldface</b>
|
162
|
+
and <i>italics</i>
|
163
|
+
and <font size=+1><tt>code</tt></font>
|
164
|
+
as well as <b>more complex</b> examples
|
165
|
+
of <i>italicized text</i>
|
162
166
|
and <font size=+1><tt>code font</tt></font>.
|
163
167
|
<p>
|
164
168
|
|
165
169
|
Here are some random punctuation marks:
|
166
|
-
# .
|
170
|
+
; # . * \_ ` : @ % ^ & $
|
167
171
|
<p>
|
168
172
|
|
169
173
|
No need to escape these: * \_ `
|
@@ -182,44 +186,82 @@ names are essentially the same as the names of the dot-commands, with occasional
|
|
182
186
|
<font size=+1><tt>_def</tt></font> method instead.) Here is the current list:
|
183
187
|
<p>
|
184
188
|
|
185
|
-
<
|
186
|
-
<
|
187
|
-
<
|
188
|
-
<
|
189
|
-
|
190
|
-
<
|
191
|
-
<
|
192
|
-
<
|
193
|
-
|
194
|
-
<
|
195
|
-
<
|
196
|
-
<
|
197
|
-
|
198
|
-
<
|
199
|
-
<
|
200
|
-
<
|
201
|
-
|
202
|
-
<
|
203
|
-
<
|
204
|
-
<
|
205
|
-
|
206
|
-
<
|
207
|
-
<
|
208
|
-
<
|
209
|
-
|
210
|
-
<
|
211
|
-
<
|
212
|
-
<
|
213
|
-
|
214
|
-
<
|
215
|
-
<
|
216
|
-
<
|
217
|
-
|
218
|
-
<
|
219
|
-
<
|
220
|
-
<
|
221
|
-
|
222
|
-
|
189
|
+
<br><center><table width=90% cellpadding=5>
|
190
|
+
<tr>
|
191
|
+
<td valign=top> <font size=+1><tt>comment</tt></font> </td>
|
192
|
+
<td valign=top> Start a comment block</td>
|
193
|
+
</tr>
|
194
|
+
<tr>
|
195
|
+
<td valign=top> <font size=+1><tt>errout</tt></font> </td>
|
196
|
+
<td valign=top> Write an error message to STDERR</td>
|
197
|
+
</tr>
|
198
|
+
<tr>
|
199
|
+
<td valign=top> <font size=+1><tt>def</tt></font> </td>
|
200
|
+
<td valign=top> Define a new method inline</td>
|
201
|
+
</tr>
|
202
|
+
<tr>
|
203
|
+
<td valign=top> <font size=+1><tt>set</tt></font> </td>
|
204
|
+
<td valign=top> Assign values to variables for later interpolation</td>
|
205
|
+
</tr>
|
206
|
+
<tr>
|
207
|
+
<td valign=top> <font size=+1><tt>include</tt></font> </td>
|
208
|
+
<td valign=top> Include an outside text file (to be interpreted as Livetext)</td>
|
209
|
+
</tr>
|
210
|
+
<tr>
|
211
|
+
<td valign=top> <font size=+1><tt>mixin</tt></font> </td>
|
212
|
+
<td valign=top> Mix this file of Ruby methods into the standard namespace</td>
|
213
|
+
</tr>
|
214
|
+
<tr>
|
215
|
+
<td valign=top> <font size=+1><tt>copy</tt></font> </td>
|
216
|
+
<td valign=top> Copy this input file verbatim (no interpretation)</td>
|
217
|
+
</tr>
|
218
|
+
<tr>
|
219
|
+
<td valign=top> <font size=+1><tt>r</tt></font> </td>
|
220
|
+
<td valign=top> Pass a single line through without processing</td>
|
221
|
+
</tr>
|
222
|
+
<tr>
|
223
|
+
<td valign=top> <font size=+1><tt>raw</tt></font> </td>
|
224
|
+
<td valign=top> Pass this special text block (terminated with <font size=+1><tt>__EOF__</tt></font>) directly into output without processing </td>
|
225
|
+
</tr>
|
226
|
+
<tr>
|
227
|
+
<td valign=top> <font size=+1><tt>func</tt></font> </td>
|
228
|
+
<td valign=top> Define a function to be invoked inline</td>
|
229
|
+
</tr>
|
230
|
+
<tr>
|
231
|
+
<td valign=top> <font size=+1><tt>say</tt></font> </td>
|
232
|
+
<td valign=top> Print a message to the screen</td>
|
233
|
+
</tr>
|
234
|
+
<tr>
|
235
|
+
<td valign=top> <font size=+1><tt>banner</tt></font> </td>
|
236
|
+
<td valign=top> Print a "noticeable" message to the screen</td>
|
237
|
+
</tr>
|
238
|
+
<tr>
|
239
|
+
<td valign=top> <font size=+1><tt>quit</tt></font> </td>
|
240
|
+
<td valign=top> End processing and exit</td>
|
241
|
+
</tr>
|
242
|
+
<tr>
|
243
|
+
<td valign=top> <font size=+1><tt>nopass</tt></font> </td>
|
244
|
+
<td valign=top> Don't pass lines through (just honor commands)</td>
|
245
|
+
</tr>
|
246
|
+
<tr>
|
247
|
+
<td valign=top> <font size=+1><tt>include</tt></font> </td>
|
248
|
+
<td valign=top> Read and process another file (typically a <font size=+1><tt>.lt3</tt></font> file)</td>
|
249
|
+
</tr>
|
250
|
+
<tr>
|
251
|
+
<td valign=top> <font size=+1><tt>debug</tt></font> </td>
|
252
|
+
<td valign=top> Turn on debugging</td>
|
253
|
+
</tr>
|
254
|
+
<tr>
|
255
|
+
<td valign=top> <font size=+1><tt>nopara</tt></font> </td>
|
256
|
+
<td valign=top> Turn off the "blank line implies new paragraph" switch</td>
|
257
|
+
</tr>
|
258
|
+
<tr>
|
259
|
+
<td valign=top> <font size=+1><tt>newpage</tt></font> </td>
|
260
|
+
<td valign=top> Start a new output page</td>
|
261
|
+
</tr>
|
262
|
+
</table></center>
|
263
|
+
<p>
|
264
|
+
|
223
265
|
### Examples from the tests
|
224
266
|
Here are some tests from the suite. The file name reflects the general purpose of the test.
|
225
267
|
<p>
|
@@ -367,7 +409,7 @@ Here are some tests from the suite. The file name reflects the general purpose o
|
|
367
409
|
<td width=50% bgcolor=#fee0fe valign=top>
|
368
410
|
<pre> Just
|
369
411
|
some text.
|
370
|
-
.set name=GulliverFoyle,nation=Terra
|
412
|
+
.set name=GulliverFoyle, nation=Terra
|
371
413
|
Hi, there.
|
372
414
|
$name is my name, and $nation is my nation.
|
373
415
|
I'm $name, from $nation.
|
@@ -532,12 +574,14 @@ Here are some tests from the suite. The file name reflects the general purpose o
|
|
532
574
|
|
533
575
|
.not\_a\_method
|
534
576
|
|
535
|
-
And this stuff won't be munged:
|
536
|
-
|
537
|
-
\_\_EOF\_\_
|
538
|
-
|
577
|
+
And this stuff won't be munged:
|
578
|
+
`alpha \_beta *gamma
|
539
579
|
|
540
|
-
|
580
|
+
Or these:
|
581
|
+
`(alpha male)
|
582
|
+
\_(beta max)
|
583
|
+
*(gamma rays)
|
584
|
+
\_\_EOF\_\_
|
541
585
|
</pre>
|
542
586
|
</td>
|
543
587
|
<td width=50% bgcolor=#eeeeee valign=top>
|
@@ -550,11 +594,13 @@ Here are some tests from the suite. The file name reflects the general purpose o
|
|
550
594
|
|
551
595
|
.not\_a\_method
|
552
596
|
|
553
|
-
And this stuff won't be munged:
|
554
|
-
|
555
|
-
<p>
|
597
|
+
And this stuff won't be munged:
|
598
|
+
`alpha \_beta *gamma
|
556
599
|
|
557
|
-
|
600
|
+
Or these:
|
601
|
+
`(alpha male)
|
602
|
+
\_(beta max)
|
603
|
+
*(gamma rays)
|
558
604
|
</pre>
|
559
605
|
</td>
|
560
606
|
</tr>
|
@@ -573,8 +619,7 @@ The simplest way is just to define a method inline with the rest of
|
|
573
619
|
the text. Here's an example.
|
574
620
|
<p>
|
575
621
|
|
576
|
-
<pre>
|
577
|
-
.comment
|
622
|
+
<pre> .comment
|
578
623
|
This example shows how to define
|
579
624
|
a simple method "chapter" inline
|
580
625
|
.end
|
@@ -622,8 +667,7 @@ collisions. These are all stored in the <font size=+1><tt>Livetext::UserAPI</tt>
|
|
622
667
|
Here is the HTML output of the previous example:
|
623
668
|
<p>
|
624
669
|
|
625
|
-
<pre>
|
626
|
-
<h3>Chapter 1</h3>
|
670
|
+
<pre> <h3>Chapter 1</h3>
|
627
671
|
<h2>Why I Went to the Woods</h2>
|
628
672
|
<hr>
|
629
673
|
It was the best of times, and you can call me Ishmael. The clocks
|
@@ -632,22 +676,36 @@ Here is the HTML output of the previous example:
|
|
632
676
|
What are some other helper methods? Here's a list.
|
633
677
|
<p>
|
634
678
|
|
635
|
-
<
|
636
|
-
<
|
637
|
-
<
|
638
|
-
<
|
639
|
-
|
640
|
-
<
|
641
|
-
<
|
642
|
-
<
|
643
|
-
|
644
|
-
<
|
645
|
-
<
|
646
|
-
<
|
647
|
-
|
648
|
-
<
|
649
|
-
<
|
650
|
-
</
|
679
|
+
<br><center><table width=90% cellpadding=5>
|
680
|
+
<tr>
|
681
|
+
<td valign=top><font size=+1><tt>_args</tt></font> </td>
|
682
|
+
<td valign=top> Returns an array of arguments for the method (or an enumerator for that array)</td>
|
683
|
+
</tr>
|
684
|
+
<tr>
|
685
|
+
<td valign=top><font size=+1><tt>_data</tt></font> </td>
|
686
|
+
<td valign=top> A single "unsplit" string of all arguments in raw form</td>
|
687
|
+
</tr>
|
688
|
+
<tr>
|
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 <font size=+1><tt></tt></font>.end)</td>
|
691
|
+
</tr>
|
692
|
+
<tr>
|
693
|
+
<td valign=top><font size=+1><tt>_puts</tt></font> </td>
|
694
|
+
<td valign=top> Write a line to output (STDOUT or wherever)</td>
|
695
|
+
</tr>
|
696
|
+
<tr>
|
697
|
+
<td valign=top><font size=+1><tt>_print</tt></font> </td>
|
698
|
+
<td valign=top> Write a line to output (STDOUT or wherever) without a newline</td>
|
699
|
+
</tr>
|
700
|
+
<tr>
|
701
|
+
<td valign=top><font size=+1><tt>_formatting</tt></font> </td>
|
702
|
+
<td valign=top> A function transforming boldface, italics, and monospace (Livetext conventions)</td>
|
703
|
+
</tr>
|
704
|
+
<tr>
|
705
|
+
<td valign=top><font size=+1><tt>_passthru</tt></font> </td>
|
706
|
+
<td valign=top> Feed a line directly into output after transforming and substituting</td>
|
707
|
+
</tr>
|
708
|
+
</table></center>
|
651
709
|
Note that the last three methods are typically <i>not</i> called in your own code. They could be,
|
652
710
|
but it remains to be seen whether something that advanced is useful.
|
653
711
|
<p>
|
@@ -683,7 +741,7 @@ in the test suite.
|
|
683
741
|
.end
|
684
742
|
|
685
743
|
|
686
|
-
|
744
|
+
That's all.
|
687
745
|
</pre>
|
688
746
|
</td>
|
689
747
|
<td width=50% bgcolor=#eeeeee valign=top>
|
@@ -709,7 +767,7 @@ in the test suite.
|
|
709
767
|
zymurgy
|
710
768
|
<p>
|
711
769
|
|
712
|
-
|
770
|
+
That's all.
|
713
771
|
</pre>
|
714
772
|
</td>
|
715
773
|
</tr>
|
@@ -755,7 +813,7 @@ have the user specify a number of columns (from 1 to 5, defaulting to 1).
|
|
755
813
|
.end
|
756
814
|
|
757
815
|
|
758
|
-
|
816
|
+
And that is all.
|
759
817
|
</pre>
|
760
818
|
</td>
|
761
819
|
<td width=50% bgcolor=#eeeeee valign=top>
|
@@ -770,7 +828,7 @@ have the user specify a number of columns (from 1 to 5, defaulting to 1).
|
|
770
828
|
zootrope zymurgy
|
771
829
|
<p>
|
772
830
|
|
773
|
-
|
831
|
+
And that is all.
|
774
832
|
</pre>
|
775
833
|
</td>
|
776
834
|
</tr>
|
@@ -788,8 +846,7 @@ Let's assume we have a file called <font size=+1><tt>mylib.rb</tt></font> in the
|
|
788
846
|
in here (and nothing else).
|
789
847
|
<p>
|
790
848
|
|
791
|
-
<pre>
|
792
|
-
# File: mylib.rb
|
849
|
+
<pre> # File: mylib.rb
|
793
850
|
|
794
851
|
def alpha
|
795
852
|
cols = <i>args.first</i>
|
@@ -808,8 +865,7 @@ in here (and nothing else).
|
|
808
865
|
Now the <font size=+1><tt>.lt3</tt></font> file can be written this way:
|
809
866
|
<p>
|
810
867
|
|
811
|
-
<pre>
|
812
|
-
.mixin mylib
|
868
|
+
<pre> .mixin mylib
|
813
869
|
Here is an alphabetized list:
|
814
870
|
|
815
871
|
.alpha 3
|
@@ -819,11 +875,156 @@ Now the <font size=+1><tt>.lt3</tt></font> file can be written this way:
|
|
819
875
|
cytology fusillade ectomorph
|
820
876
|
.end
|
821
877
|
|
822
|
-
|
878
|
+
And that is all.
|
823
879
|
</pre>
|
824
880
|
The output, of course, is the same.
|
825
881
|
<p>
|
826
882
|
|
883
|
+
You can define variables in Livetext, defined with <font size=+1><tt>.set</tt></font> and
|
884
|
+
referenced with a <font size=+1><tt>$</tt></font>. Later there will be a few predefined
|
885
|
+
variables. Variables are just string values.
|
886
|
+
<p>
|
887
|
+
|
888
|
+
|
889
|
+
<font size=+1><b>Test: </font><font size=+2><tt>simple_vars</tt></font></b></h3><br>
|
890
|
+
<font size=+1>
|
891
|
+
<table width=80% cellpadding=4>
|
892
|
+
<tr>
|
893
|
+
<td width=50%><b>Input</b></td>
|
894
|
+
<td width=50%><b>Output</b></td>
|
895
|
+
</tr>
|
896
|
+
<tr>
|
897
|
+
<td width=50% bgcolor=#fee0fe valign=top>
|
898
|
+
<pre> Just
|
899
|
+
some text.
|
900
|
+
.set name=GulliverFoyle, nation=Terra
|
901
|
+
Hi, there.
|
902
|
+
$name is my name, and $nation is my nation.
|
903
|
+
I'm $name, from $nation.
|
904
|
+
That's all.
|
905
|
+
</pre>
|
906
|
+
</td>
|
907
|
+
<td width=50% bgcolor=#eeeeee valign=top>
|
908
|
+
<pre> Just
|
909
|
+
some text.
|
910
|
+
Hi, there.
|
911
|
+
GulliverFoyle is my name, and Terra is my nation.
|
912
|
+
I'm GulliverFoyle, from Terra.
|
913
|
+
That's all.
|
914
|
+
</pre>
|
915
|
+
</td>
|
916
|
+
</tr>
|
917
|
+
</table>
|
918
|
+
</font>
|
919
|
+
<br>
|
920
|
+
<p>
|
921
|
+
|
922
|
+
If a variable needs to contain spaces, you can double-quote it.
|
923
|
+
<p>
|
924
|
+
|
925
|
+
|
926
|
+
<font size=+1><b>Test: </font><font size=+2><tt>more_complex_vars</tt></font></b></h3><br>
|
927
|
+
<font size=+1>
|
928
|
+
<table width=80% cellpadding=4>
|
929
|
+
<tr>
|
930
|
+
<td width=50%><b>Input</b></td>
|
931
|
+
<td width=50%><b>Output</b></td>
|
932
|
+
</tr>
|
933
|
+
<tr>
|
934
|
+
<td width=50% bgcolor=#fee0fe valign=top>
|
935
|
+
<pre> Just some more text.
|
936
|
+
.set bday="May 31", date="5/31"
|
937
|
+
My birthday is $bday, so they tell me.
|
938
|
+
That's $date if you're American.
|
939
|
+
That's all.
|
940
|
+
</pre>
|
941
|
+
</td>
|
942
|
+
<td width=50% bgcolor=#eeeeee valign=top>
|
943
|
+
<pre> Just some more text.
|
944
|
+
My birthday is May 31, so they tell me.
|
945
|
+
That's 5/31 if you're American.
|
946
|
+
That's all.
|
947
|
+
</pre>
|
948
|
+
</td>
|
949
|
+
</tr>
|
950
|
+
</table>
|
951
|
+
</font>
|
952
|
+
<br>
|
953
|
+
<p>
|
954
|
+
|
955
|
+
Livetext permits user-defined functions (as well as defining a few
|
956
|
+
predefined ones). Call a function with <font size=+1><tt>$$</tt></font> and (if applicable) pass
|
957
|
+
a single string parameter between brackets.
|
958
|
+
<p>
|
959
|
+
|
960
|
+
|
961
|
+
<font size=+1><b>Test: </font><font size=+2><tt>functions</tt></font></b></h3><br>
|
962
|
+
<font size=+1>
|
963
|
+
<table width=80% cellpadding=4>
|
964
|
+
<tr>
|
965
|
+
<td width=50%><b>Input</b></td>
|
966
|
+
<td width=50%><b>Output</b></td>
|
967
|
+
</tr>
|
968
|
+
<tr>
|
969
|
+
<td width=50% bgcolor=#fee0fe valign=top>
|
970
|
+
<pre> Testing out
|
971
|
+
some functions
|
972
|
+
here...
|
973
|
+
|
974
|
+
.func myfunc
|
975
|
+
"Eureka!"
|
976
|
+
.end
|
977
|
+
|
978
|
+
I am calling $$myfunc here...
|
979
|
+
Let's see
|
980
|
+
what happens.
|
981
|
+
|
982
|
+
Functions can take a parameter in brackets
|
983
|
+
(which it can parse itself as needed):
|
984
|
+
|
985
|
+
.func mean
|
986
|
+
list = self.class.param
|
987
|
+
list = list.split(",").map(&:to\_f)
|
988
|
+
sum = list.inject(0, :+)
|
989
|
+
avg = sum / list.size.to\_f
|
990
|
+
avg.to\_s
|
991
|
+
.end
|
992
|
+
|
993
|
+
The result is $$mean[1,2,3,4,5,6,7] as I see it.
|
994
|
+
|
995
|
+
Some functions like date and time are predefined.
|
996
|
+
|
997
|
+
</pre>
|
998
|
+
</td>
|
999
|
+
<td width=50% bgcolor=#eeeeee valign=top>
|
1000
|
+
<pre> Testing out
|
1001
|
+
some functions
|
1002
|
+
here...
|
1003
|
+
<p>
|
1004
|
+
|
1005
|
+
I am calling Eureka! here...
|
1006
|
+
Let's see
|
1007
|
+
what happens.
|
1008
|
+
<p>
|
1009
|
+
|
1010
|
+
Functions can take a parameter in brackets
|
1011
|
+
(which it can parse itself as needed):
|
1012
|
+
<p>
|
1013
|
+
|
1014
|
+
The result is 4.0 as I see it.
|
1015
|
+
<p>
|
1016
|
+
|
1017
|
+
Some functions like date and time are predefined.
|
1018
|
+
<p>
|
1019
|
+
|
1020
|
+
</pre>
|
1021
|
+
</td>
|
1022
|
+
</tr>
|
1023
|
+
</table>
|
1024
|
+
</font>
|
1025
|
+
<br>
|
1026
|
+
<p>
|
1027
|
+
|
827
1028
|
There is an important feature that has not yet been implemented (the
|
828
1029
|
<font size=+1><tt>require</tt></font> method). Like Ruby's <font size=+1><tt>require</tt></font>, it will grab Ruby code and
|
829
1030
|
load it; however, unlike <font size=+1><tt>mixin</tt></font>, it will load it into a customized
|
data/lib/livetext.rb
CHANGED
data/lib/standard.rb
CHANGED
@@ -310,7 +310,7 @@ module Livetext::Standard
|
|
310
310
|
def xtable # Borrowed from bookish - FIXME
|
311
311
|
title = @_data
|
312
312
|
delim = " :: "
|
313
|
-
_out "<br><center><table
|
313
|
+
_out "<br><center><table width=90% cellpadding=5>"
|
314
314
|
lines = _body(true)
|
315
315
|
maxw = nil
|
316
316
|
lines.each do |line|
|
data/plugin/tutorial.rb
CHANGED
@@ -9,8 +9,16 @@ def section
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def code
|
12
|
-
|
13
|
-
|
12
|
+
# _puts "<pre>"
|
13
|
+
first = true # dumb hack! fixes blank space
|
14
|
+
_body do |line|
|
15
|
+
if first
|
16
|
+
tag = "<pre>"
|
17
|
+
first = false
|
18
|
+
else
|
19
|
+
end
|
20
|
+
_puts "#{tag} #{::CGI.escape_html(line)}" # indentation
|
21
|
+
end
|
14
22
|
_puts "</pre>"
|
15
23
|
end
|
16
24
|
|
@@ -1,10 +1,13 @@
|
|
1
|
-
Here are examples of <b>boldface</b>
|
2
|
-
|
1
|
+
Here are examples of <b>boldface</b>
|
2
|
+
and <i>italics</i>
|
3
|
+
and <font size=+1><tt>code</tt></font>
|
4
|
+
as well as <b>more complex</b> examples
|
5
|
+
of <i>italicized text</i>
|
3
6
|
and <font size=+1><tt>code font</tt></font>.
|
4
7
|
<p>
|
5
8
|
|
6
9
|
Here are some random punctuation marks:
|
7
|
-
|
10
|
+
; # . * _ ` : @ % ^ & $
|
8
11
|
<p>
|
9
12
|
|
10
13
|
No need to escape these: * _ `
|
@@ -1,8 +1,11 @@
|
|
1
|
-
Here are examples of *boldface
|
2
|
-
|
1
|
+
Here are examples of *boldface
|
2
|
+
and _italics
|
3
|
+
and `code
|
4
|
+
as well as *[more complex] examples
|
5
|
+
of _[italicized text]
|
3
6
|
and `[code font].
|
4
7
|
|
5
8
|
Here are some random punctuation marks:
|
6
|
-
|
9
|
+
; # . * _ ` : @ % ^ & $
|
7
10
|
|
8
11
|
No need to escape these: * _ `
|
@@ -6,3 +6,15 @@ here...
|
|
6
6
|
I am calling Eureka! here...
|
7
7
|
Let's see
|
8
8
|
what happens.
|
9
|
+
<p>
|
10
|
+
|
11
|
+
Functions can take a parameter in brackets
|
12
|
+
(which it can parse itself as needed):
|
13
|
+
<p>
|
14
|
+
|
15
|
+
The result is 4.0 as I see it.
|
16
|
+
<p>
|
17
|
+
|
18
|
+
Some functions like date and time are predefined.
|
19
|
+
<p>
|
20
|
+
|
@@ -9,3 +9,19 @@ here...
|
|
9
9
|
I am calling $$myfunc here...
|
10
10
|
Let's see
|
11
11
|
what happens.
|
12
|
+
|
13
|
+
Functions can take a parameter in brackets
|
14
|
+
(which it can parse itself as needed):
|
15
|
+
|
16
|
+
.func mean
|
17
|
+
list = self.class.param
|
18
|
+
list = list.split(",").map(&:to_f)
|
19
|
+
sum = list.inject(0, :+)
|
20
|
+
avg = sum / list.size.to_f
|
21
|
+
avg.to_s
|
22
|
+
.end
|
23
|
+
|
24
|
+
The result is $$mean[1,2,3,4,5,6,7] as I see it.
|
25
|
+
|
26
|
+
Some functions like date and time are predefined.
|
27
|
+
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Testing heredocs (used in a table)
|
2
2
|
<p>
|
3
3
|
|
4
|
-
<br><center><table
|
4
|
+
<br><center><table width=90% cellpadding=5>
|
5
5
|
<tr>
|
6
6
|
<td valign=top>This is <br>only <br>a test.<br></td>
|
7
7
|
<td valign=top>This is <br>just <br>some <br>random text.<br></td>
|