livetext 0.8.1 → 0.8.2
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.ltx +87 -72
- data/README.md +259 -292
- data/bin/livetext +11 -8
- data/dsl/markdown.rb +11 -3
- data/dsl/tutorial.rb +2 -33
- data/lib/livetext.rb +12 -2
- data/lib/standard.rb +1 -1
- data/test/test.rb +6 -2
- data/test/testfiles/lines.txt +8 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd50a45d248673a1629b46e3f46684f7c505fa35
|
4
|
+
data.tar.gz: 3368732003a8e8b006c5b46a5370dc6b5f71fa1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ae32de005cb4b5339b2efdf8e1c1a346fee048c6431080ffa74d8b6590f8cb5f296ef0fb3878840232e23a232175d5f1a418826656e538d48d2bb7aa7b48e92
|
7
|
+
data.tar.gz: dab5779af0d426f72947c939fbabf6375ada785204a54daa97ee4c102d7765d3c71940bd1a3294f62f259f707a4bd8467defc60335546f7e274894de45179931
|
data/README.ltx
CHANGED
@@ -1,10 +1,14 @@
|
|
1
|
-
.mixin
|
1
|
+
.mixin tutorial
|
2
|
+
.mixin markdown
|
3
|
+
|
2
4
|
.title Livetext: A smart processor for text
|
3
5
|
|
6
|
+
*[This README is currently mangled. Fixes coming soon!]
|
7
|
+
|
4
8
|
Livetext is simply a tool for transforming text from one format into another. The source file
|
5
9
|
has commands embedded in it, and the output is dependent on those commands.
|
6
10
|
|
7
|
-
Why is this special? It's very flexible, very extensible, and it's extensible _
|
11
|
+
Why is this special? It's very flexible, very extensible, and it's extensible _[in Ruby].
|
8
12
|
|
9
13
|
.section Why Livetext?
|
10
14
|
|
@@ -12,10 +16,11 @@ Livetext grew out of several motivations. One was a desire for a markup language
|
|
12
16
|
me to write articles (and even books) in my own way and on my own terms. I've done this more
|
13
17
|
than once (and I know others who have, as well).
|
14
18
|
|
15
|
-
I liked Softcover, but I found it to be very complex. I never liked Markdown much -- it
|
16
|
-
dumb and not extensible at all.
|
19
|
+
I liked Softcover, but I found it to be very complex. I never liked Markdown much -- I find it very
|
20
|
+
dumb, and it's not extensible at all. (In fairness to Markdown, it does serve a different purpose
|
21
|
+
in everyday life.)
|
17
22
|
|
18
|
-
I wanted something that had the basic functionality of all my ad hoc solutions but allowed
|
23
|
+
I wanted something that had the basic functionality of all my _[ad hoc] solutions but allowed
|
19
24
|
extensions. Then my old solutions would be like subsets of the new format. This was a generalization
|
20
25
|
similar to the way we began several years ago to view HTML as a subset of XML.
|
21
26
|
|
@@ -52,33 +57,34 @@ you could even emit PDF, PNG, or SVG formats.
|
|
52
57
|
|
53
58
|
. Idea: Make an RMagick DSL as an example.
|
54
59
|
|
55
|
-
It's possible to embed comments in the text
|
56
|
-
in commented form.
|
60
|
+
It's possible to embed comments in the text. Later it will be possible to pass
|
61
|
+
them through to the output in commented form.
|
57
62
|
|
58
63
|
The command `.end is special, marking the end of a body of text. Some commands may operate on
|
59
64
|
a block of lines rather than just a few parameters. (A text block is like a here-document.)
|
60
65
|
There is no method name corresponding to the `.end command.
|
61
66
|
|
62
67
|
The file extension I've chosen is `.ltx (though this may change). *Note: The source for this
|
63
|
-
README is a `.ltx file which uses its own little _
|
68
|
+
README is a `.ltx file which uses its own little _[ad hoc] library (called ``tutorial.rb). Refer to
|
64
69
|
the repo to see these.
|
65
70
|
|
66
71
|
.section Syntax, comments, and more
|
67
72
|
|
68
73
|
At first, my idea was to provide predefined commands and allow user-defined commands (to be
|
69
|
-
distinguished by a leading `. or `..
|
74
|
+
distinguished by a leading `. or `.. marker). So the single and double dots were both legal.
|
70
75
|
|
71
|
-
However, my concept at present is that the double dots (currently unused)
|
76
|
+
However, my concept at present is that the double dots (currently unused) may be used for
|
72
77
|
subcommmands.
|
73
78
|
|
74
|
-
User-defined commands may be added to the standard namespace
|
75
|
-
|
76
|
-
|
79
|
+
User-defined commands may be added to the standard namespace. There are plans to
|
80
|
+
permit commands beginning with a specified character other than the period (to
|
81
|
+
be stored in their own namespace.
|
77
82
|
|
78
|
-
When a leading period
|
79
|
-
|
80
|
-
remaining text on the line is treated as a parameter list to be accessed by that
|
81
|
-
Some methods accept multiple lines of text
|
83
|
+
When a leading period is followed by a space, that line is a comment. When it is
|
84
|
+
follwed by a name, that name is typically understood to be a method name. Any
|
85
|
+
remaining text on the line is treated as a parameter list to be accessed by that
|
86
|
+
method. Some methods accept a text block (multiple lines of text terminated by
|
87
|
+
a `.end tag).
|
82
88
|
|
83
89
|
.section Boldface and italics
|
84
90
|
|
@@ -93,17 +99,25 @@ need a workaround for that.
|
|
93
99
|
I find that most short items I want to format are single tokens. Therefore I use a prefixed
|
94
100
|
character in front of such a token: Underscore for italics, asterisk for boldface, and backtick
|
95
101
|
for "code font." The formatting ends when the first blank space is encountered, without any
|
96
|
-
kind of suffixed character.
|
97
|
-
|
102
|
+
kind of suffixed character.
|
103
|
+
|
104
|
+
I also find it's common to want to terminate such a string with some kind of
|
105
|
+
naturally-occurring punctuation mark. If we double the initial delimiter, it
|
106
|
+
will be understood to terminate at the first period, comma, or right parenthesis.
|
98
107
|
|
99
108
|
Of course, there are cases where this won't work; a formatted string may contain spaces, or it
|
100
|
-
may exclude characters before the blank space. In this case, we can use an opening
|
101
|
-
after the prefix and a closing
|
109
|
+
may exclude characters before the blank space. In this case, we can use an opening bracket
|
110
|
+
after the prefix and a closing bracket at the end of the string.
|
111
|
+
|
112
|
+
This means that it can be difficult to include brackets inside a formatted token. The solution
|
113
|
+
is simply to escape with a backslash.
|
102
114
|
|
103
|
-
|
104
|
-
about that. It also means that a "literal" prefix character must be escaped.
|
115
|
+
A delimiter character sitting by itself need not be escaped. It will be output as a literal.
|
105
116
|
|
106
|
-
|
117
|
+
A delimiter character that is already inside another string need not be escaped. These cannot
|
118
|
+
be nested (though there is a way to accomplish this using functions).
|
119
|
+
|
120
|
+
Most of this is summarized in this example (taken from one of the testcases):
|
107
121
|
|
108
122
|
.testcase basic_formatting
|
109
123
|
|
@@ -111,28 +125,28 @@ This is all summarized in this example (taken from one of the testcases):
|
|
111
125
|
|
112
126
|
The module `Livetext::Standard contains the set of standard or predefined methods. Their
|
113
127
|
names are essentially the same as the names of the dot-commands, with occasional exceptions.
|
114
|
-
(For example, it is impractical to use the name `def as a method name, so
|
115
|
-
Here is the current list:
|
116
|
-
|
117
|
-
.dlist
|
118
|
-
`comment
|
119
|
-
`errout
|
120
|
-
`def
|
121
|
-
`set
|
122
|
-
`include
|
123
|
-
`mixin
|
124
|
-
`copy
|
125
|
-
`r
|
126
|
-
`raw
|
127
|
-
`func
|
128
|
-
`say
|
129
|
-
`banner
|
130
|
-
`quit
|
131
|
-
`nopass
|
132
|
-
`include
|
133
|
-
`debug
|
134
|
-
`nopara
|
135
|
-
`newpage
|
128
|
+
(For example, it is impractical to use the name `def as a method name, so the module has a
|
129
|
+
`_def method instead.) Here is the current list:
|
130
|
+
|
131
|
+
.dlist %%
|
132
|
+
`comment %% Start a comment block
|
133
|
+
`errout %% Write an error message to STDERR
|
134
|
+
`def %% Define a new method inline
|
135
|
+
`set %% Assign values to variables for later interpolation
|
136
|
+
`include %% Include an outside text file (to be interpreted as Livetext)
|
137
|
+
`mixin %% Mix this file of Ruby methods into the standard namespace
|
138
|
+
`copy %% Copy this input file verbatim (no interpretation)
|
139
|
+
`r %% Pass a single line through without processing
|
140
|
+
`raw %% Pass this special text block (terminated with ``__EOF__) directly into output without processing
|
141
|
+
`func %% Define a function to be invoked inline
|
142
|
+
`say %% Print a message to the screen
|
143
|
+
`banner %% Print a "noticeable" message to the screen
|
144
|
+
`quit %% End processing and exit
|
145
|
+
`nopass %% Don't pass lines through (just honor commands)
|
146
|
+
`include %% Read and process another file (typically a `.ltx file)
|
147
|
+
`debug %% Turn on debugging
|
148
|
+
`nopara %% Turn off the "blank line implies new paragraph" switch
|
149
|
+
`newpage %% Start a new output page
|
136
150
|
.end
|
137
151
|
|
138
152
|
.section Examples from the tests
|
@@ -199,7 +213,7 @@ We then create a string using these parameters and call it using the
|
|
199
213
|
wherever the output is currently being sent (defaulting to STDOUT).
|
200
214
|
|
201
215
|
All the "helper" methods start with an underscore so as to avoid name
|
202
|
-
collisions. These are all stored in the `Livetext::
|
216
|
+
collisions. These are all stored in the `Livetext::UserAPI module
|
203
217
|
(which also has some methods you will never use).
|
204
218
|
|
205
219
|
Here is the HTML output of the previous example:
|
@@ -215,14 +229,13 @@ Here is the HTML output of the previous example:
|
|
215
229
|
What are some other helper methods? Here's a list.
|
216
230
|
|
217
231
|
.dlist
|
218
|
-
`_args
|
219
|
-
`_data
|
220
|
-
`_body
|
221
|
-
`_puts
|
222
|
-
`_print
|
223
|
-
`_formatting
|
224
|
-
`
|
225
|
-
`_passthru ~~ Feed a line directly into output after transforming and substituting
|
232
|
+
`_args %% Returns an array of arguments for the method (or an enumerator for that array)
|
233
|
+
`_data %% A single "unsplit" string of all arguments in raw form
|
234
|
+
`_body %% Returns a string (or enumerator) giving access to the text block (preceding ``.end)
|
235
|
+
`_puts %% Write a line to output (STDOUT or wherever)
|
236
|
+
`_print %% Write a line to output (STDOUT or wherever) without a newline
|
237
|
+
`_formatting %% A function transforming boldface, italics, and monospace (Livetext conventions)
|
238
|
+
`_passthru %% Feed a line directly into output after transforming and substituting
|
226
239
|
.end
|
227
240
|
|
228
241
|
Note that the last three methods are typically _not called in your own code. They could be,
|
@@ -285,36 +298,38 @@ Now the `.ltx file can be written this way:
|
|
285
298
|
The output, of course, is the same.
|
286
299
|
|
287
300
|
There is an important feature that has not yet been implemented (the
|
288
|
-
`require method). Like Ruby's
|
289
|
-
load it; however, unlike
|
301
|
+
`require method). Like Ruby's ``require, it will grab Ruby code and
|
302
|
+
load it; however, unlike ``mixin, it will load it into a customized
|
290
303
|
object and associate a new sigil with it. So for example, the command
|
291
304
|
`.foobar would refer to a method in the `Livetext::Standard class
|
292
305
|
(whether predefined or user-defined). If we did a `require on a file
|
293
306
|
and associated the sigil `# with it, then `#foobar would be a method
|
294
|
-
on that new custom object. I
|
307
|
+
on that new custom object. I plan to implement this later.
|
295
308
|
|
296
309
|
.section Issues, open questions, and to-do items
|
297
310
|
|
298
311
|
This list is not prioritized yet.
|
299
312
|
|
300
313
|
.nlist
|
301
|
-
Add versioning information
|
302
|
-
Clean up code structure
|
314
|
+
~[Add versioning information
|
315
|
+
~[Clean up code structure
|
303
316
|
Add RDoc
|
304
|
-
Think about command line executable
|
305
|
-
Write as pure library in addition to executable
|
306
|
-
Package as gem
|
317
|
+
~[Think about command line executable
|
318
|
+
~[Write as pure library in addition to executable
|
319
|
+
~[Package as gem
|
307
320
|
Document: `require `include `copy `mixin `errout and others
|
308
|
-
Need much better error checking and corresponding tests
|
321
|
+
Need ~much better error checking and corresponding tests
|
309
322
|
Worry about nesting of elements (probably mostly disallow)
|
310
323
|
Think about UTF-8
|
311
324
|
Document API fully
|
312
325
|
Add `_raw_args and let `_args honor quotes
|
313
326
|
Support quotes in `.set values
|
314
|
-
Support "namespaced" variables (`
|
315
|
-
Support functions (
|
316
|
-
|
317
|
-
|
327
|
+
Support "namespaced" variables (`[.set code.font="whatever"])
|
328
|
+
~[Support functions (``$$func)
|
329
|
+
Support function namespacing
|
330
|
+
Create predefined variables (e.g., `[$_source_file], `$[_line])
|
331
|
+
Create predefined functions (e.g., `[$$_date])
|
332
|
+
More support for markdown
|
318
333
|
Allow turning on/off: formatting, variable interpolation, function interpolation?
|
319
334
|
`.require with file and sigil parameters
|
320
335
|
Investigate "common intermediate format" - output renderers all read it
|
@@ -325,8 +340,8 @@ Exceptions??
|
|
325
340
|
Ruby `$SAFE levels?
|
326
341
|
Warn when overriding existing names?
|
327
342
|
Think about passing data in (erb replacement)
|
328
|
-
Allow custom ending tag on `raw method
|
329
|
-
Ignore first blank line after `
|
343
|
+
~]Allow custom ending tag on `raw method
|
344
|
+
~[Ignore first blank line after `[.end]? (and after raw-tag?)
|
330
345
|
Allow/encourage custom `passthru method?
|
331
346
|
Must have sane support for CSS
|
332
347
|
Support for Pygments and/or other code processors
|
@@ -340,9 +355,9 @@ Someday: Support other languages (Elixir, Python, ...)
|
|
340
355
|
`.irb method?
|
341
356
|
Other debugging features
|
342
357
|
Feature to "break" to EOF?
|
343
|
-
`.meth? method ending in `? takes a block that may be processed or thrown away (
|
358
|
+
`.meth? method ending in `? takes a block that may be processed or thrown away (`.else perhaps?)
|
344
359
|
`.dump to dump all variables and their values
|
345
|
-
`.if and `
|
360
|
+
`.if and `[.else]?
|
346
361
|
Make any/all delimiters configurable
|
347
362
|
HTML helper? (in their own library?)
|
348
363
|
.end
|
data/README.md
CHANGED
@@ -1,123 +1,151 @@
|
|
1
|
-
|
1
|
+
# Livetext: A smart processor for text
|
2
|
+
<p>
|
3
|
+
|
4
|
+
<b>This README is currently mangled. Fixes coming soon!</b>
|
5
|
+
<p>
|
2
6
|
|
3
7
|
Livetext is simply a tool for transforming text from one format into another. The source file
|
4
8
|
has commands embedded in it, and the output is dependent on those commands.
|
9
|
+
<p>
|
5
10
|
|
6
11
|
Why is this special? It's very flexible, very extensible, and it's extensible <i>in Ruby</i>.
|
12
|
+
<p>
|
7
13
|
|
8
|
-
|
14
|
+
### Why Livetext?
|
15
|
+
<p>
|
9
16
|
|
10
17
|
Livetext grew out of several motivations. One was a desire for a markup language that would permit
|
11
18
|
me to write articles (and even books) in my own way and on my own terms. I've done this more
|
12
19
|
than once (and I know others who have, as well).
|
20
|
+
<p>
|
13
21
|
|
14
|
-
I liked Softcover, but I found it to be very complex. I never liked Markdown much -- it
|
15
|
-
dumb and not extensible at all.
|
22
|
+
I liked Softcover, but I found it to be very complex. I never liked Markdown much -- I find it very
|
23
|
+
dumb, and it's not extensible at all. (In fairness to Markdown, it does serve a different purpose
|
24
|
+
in everyday life.)
|
25
|
+
<p>
|
16
26
|
|
17
|
-
I wanted something that had the basic functionality of all my ad hoc solutions but allowed
|
27
|
+
I wanted something that had the basic functionality of all my <i>ad hoc</i> solutions but allowed
|
18
28
|
extensions. Then my old solutions would be like subsets of the new format. This was a generalization
|
19
29
|
similar to the way we began several years ago to view HTML as a subset of XML.
|
30
|
+
<p>
|
20
31
|
|
21
|
-
|
32
|
+
### What is Livetext really?
|
33
|
+
<p>
|
22
34
|
|
23
35
|
Here goes:
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
<li>It's like markdown and others (but not)
|
40
|
-
</li>
|
41
|
-
<li>It's like erb or HAML (but not)
|
42
|
-
</li>
|
43
|
-
<li>It's powerful but not too dangerous
|
44
|
-
</li>
|
45
|
-
<li>It's not necesarily a markdown replacement
|
46
|
-
</li>
|
47
|
-
<li>It's definitely not a softcover replacement
|
48
|
-
</li>
|
49
|
-
<li>It could possibly augment markdown, softcover, others
|
50
|
-
</li>
|
51
|
-
</ul>
|
52
|
-
|
53
|
-
<br><br><b><font size=+1>How does it work?</font></b><br>
|
36
|
+
* It's a text transformer
|
37
|
+
* It's Ruby-based (later on, more language agnostic)
|
38
|
+
* It's (potentially) agnostic about output format
|
39
|
+
* It's designed to be flexible, extensible, and easy
|
40
|
+
* It's designed to be "plugin" oriented
|
41
|
+
* It's like an old-fashioned text formatter (but extensible)
|
42
|
+
* It's like a macro processor (but not)
|
43
|
+
* It's like markdown and others (but not)
|
44
|
+
* It's like erb or HAML (but not)
|
45
|
+
* It's powerful but not too dangerous
|
46
|
+
* It's not necesarily a markdown replacement
|
47
|
+
* It's definitely not a softcover replacement
|
48
|
+
* It could possibly augment markdown, softcover, others
|
49
|
+
### How does it work?
|
50
|
+
<p>
|
54
51
|
|
55
52
|
A Livetext file is simply a text file which may have commands interspersed. A command is
|
56
53
|
simply a period followed by a name and optional parameters (at the beginning of a line).
|
54
|
+
<p>
|
57
55
|
|
58
|
-
The period
|
56
|
+
The period will be configurable later if you want to use another character. The names are (for now)
|
59
57
|
actual Ruby method names, so names such as <tt>to_s</tt> and <tt>inspect</tt> are currently not allowed.
|
58
|
+
<p>
|
60
59
|
|
61
|
-
|
60
|
+
At present, I am mostly emitting "dumb HTML" or Markdown as output. In theory, you can write
|
62
61
|
code (or use someone else's) to manipulate text in any way and output any format. Technically,
|
63
62
|
you could even emit PDF, PNG, or SVG formats.
|
63
|
+
<p>
|
64
64
|
|
65
|
+
<p>
|
65
66
|
|
66
|
-
It's possible to embed comments in the text
|
67
|
-
in commented form.
|
67
|
+
It's possible to embed comments in the text. Later it will be possible to pass
|
68
|
+
them through to the output in commented form.
|
69
|
+
<p>
|
68
70
|
|
69
71
|
The command <tt>.end</tt> is special, marking the end of a body of text. Some commands may operate on
|
70
72
|
a block of lines rather than just a few parameters. (A text block is like a here-document.)
|
71
73
|
There is no method name corresponding to the <tt>.end</tt> command.
|
74
|
+
<p>
|
72
75
|
|
73
|
-
The file extension I've chosen is <tt>.
|
74
|
-
README is a <tt>.
|
76
|
+
The file extension I've chosen is <tt>.ltx</tt> (though this may change). <b>Note:</b> The source for this
|
77
|
+
README is a <tt>.ltx</tt> file which uses its own little <i>ad hoc</i> library (called <tt>tutorial</tt>.rb). Refer to
|
75
78
|
the repo to see these.
|
79
|
+
<p>
|
76
80
|
|
77
|
-
|
81
|
+
### Syntax, comments, and more
|
82
|
+
<p>
|
78
83
|
|
79
84
|
At first, my idea was to provide predefined commands and allow user-defined commands (to be
|
80
|
-
distinguished by a leading <tt>.</tt> or <tt>..</tt>
|
85
|
+
distinguished by a leading <tt>.</tt> or <tt>..</tt> marker). So the single and double dots were both legal.
|
86
|
+
<p>
|
81
87
|
|
82
|
-
However, my concept at present is that the double dots (currently unused)
|
88
|
+
However, my concept at present is that the double dots (currently unused) may be used for
|
83
89
|
subcommmands.
|
90
|
+
<p>
|
84
91
|
|
85
|
-
User-defined commands may be added to the standard namespace
|
86
|
-
|
87
|
-
|
92
|
+
User-defined commands may be added to the standard namespace. There are plans to
|
93
|
+
permit commands beginning with a specified character other than the period (to
|
94
|
+
be stored in their own namespace.
|
95
|
+
<p>
|
88
96
|
|
89
|
-
When a leading period
|
90
|
-
|
91
|
-
remaining text on the line is treated as a parameter list to be accessed by that
|
92
|
-
Some methods accept multiple lines of text
|
97
|
+
When a leading period is followed by a space, that line is a comment. When it is
|
98
|
+
follwed by a name, that name is typically understood to be a method name. Any
|
99
|
+
remaining text on the line is treated as a parameter list to be accessed by that
|
100
|
+
method. Some methods accept a text block (multiple lines of text terminated by
|
101
|
+
a <tt>.end</tt> tag).
|
102
|
+
<p>
|
93
103
|
|
94
|
-
|
104
|
+
### Boldface and italics
|
105
|
+
<p>
|
95
106
|
|
96
107
|
Very commonly we want to format short words or phrases in italics, boldface, or a monospaced
|
97
108
|
(fixed width) font. The Markdown spec provides ways to do this that are fairly intuitive; but I
|
98
109
|
personally don't like them. My own notation works a different way.
|
110
|
+
<p>
|
99
111
|
|
100
112
|
First of all, note that these don't work across source lines; they're strictly intra-line.
|
101
113
|
You may need (for example) an italicized phrase that spans across a newline; at present, you'll
|
102
114
|
need a workaround for that.
|
115
|
+
<p>
|
103
116
|
|
104
117
|
I find that most short items I want to format are single tokens. Therefore I use a prefixed
|
105
118
|
character in front of such a token: Underscore for italics, asterisk for boldface, and backtick
|
106
119
|
for "code font." The formatting ends when the first blank space is encountered, without any
|
107
|
-
kind of suffixed character.
|
108
|
-
|
120
|
+
kind of suffixed character.
|
121
|
+
<p>
|
122
|
+
|
123
|
+
I also find it's common to want to terminate such a string with some kind of
|
124
|
+
naturally-occurring punctuation mark. If we double the initial delimiter, it
|
125
|
+
will be understood to terminate at the first period, comma, or right parenthesis.
|
126
|
+
<p>
|
109
127
|
|
110
128
|
Of course, there are cases where this won't work; a formatted string may contain spaces, or it
|
111
|
-
may exclude characters before the blank space. In this case, we can use an opening
|
112
|
-
after the prefix and a closing
|
129
|
+
may exclude characters before the blank space. In this case, we can use an opening bracket
|
130
|
+
after the prefix and a closing bracket at the end of the string.
|
131
|
+
<p>
|
132
|
+
|
133
|
+
This means that it can be difficult to include brackets inside a formatted token. The solution
|
134
|
+
is simply to escape with a backslash.
|
135
|
+
<p>
|
113
136
|
|
114
|
-
|
115
|
-
|
137
|
+
A delimiter character sitting by itself need not be escaped. It will be output as a literal.
|
138
|
+
<p>
|
116
139
|
|
117
|
-
|
140
|
+
A delimiter character that is already inside another string need not be escaped. These cannot
|
141
|
+
be nested (though there is a way to accomplish this using functions).
|
142
|
+
<p>
|
118
143
|
|
144
|
+
Most of this is summarized in this example (taken from one of the testcases):
|
145
|
+
<p>
|
119
146
|
|
120
|
-
|
147
|
+
|
148
|
+
<font size=+1><b>Test: </font><font size=+2><tt>basic_formatting</tt></font></b></h3><br>
|
121
149
|
<center>
|
122
150
|
<table width=80% cellpadding=4>
|
123
151
|
<tr>
|
@@ -127,86 +155,107 @@ This is all summarized in this example (taken from one of the testcases):
|
|
127
155
|
<tr>
|
128
156
|
<td width=50% bgcolor=#fec0fe valign=top>
|
129
157
|
<pre> Here are examples of *boldface and \_italics and `code
|
130
|
-
as well as *
|
131
|
-
and `
|
158
|
+
as well as *[more complex] examples of \_[italicized text]
|
159
|
+
and `[code font].
|
132
160
|
|
133
161
|
Here are some random punctuation marks:
|
134
162
|
# . @ * \_ ` : ; % ^ & $
|
135
163
|
|
136
|
-
|
164
|
+
No need to escape these: * \_ `
|
137
165
|
</pre>
|
138
166
|
</td>
|
139
167
|
<td width=50% bgcolor=lightgray valign=top>
|
140
168
|
<pre> Here are examples of <b>boldface</b> and <i>italics</i> and <tt>code</tt>
|
141
169
|
as well as <b>more complex</b> examples of <i>italicized text</i>
|
142
170
|
and <tt>code font</tt>.
|
171
|
+
<p>
|
143
172
|
|
144
173
|
Here are some random punctuation marks:
|
145
174
|
# . @ * \_ ` : ; % ^ & $
|
175
|
+
<p>
|
146
176
|
|
147
|
-
|
177
|
+
No need to escape these: * \_ `
|
148
178
|
</pre>
|
149
179
|
</td>
|
150
180
|
</tr>
|
151
181
|
</table>
|
152
182
|
</center>
|
183
|
+
<br>
|
184
|
+
<p>
|
153
185
|
|
154
|
-
|
186
|
+
### Standard methods
|
187
|
+
<p>
|
155
188
|
|
156
189
|
The module <tt>Livetext::Standard</tt> contains the set of standard or predefined methods. Their
|
157
190
|
names are essentially the same as the names of the dot-commands, with occasional exceptions.
|
158
|
-
(For example, it is impractical to use the name <tt>def</tt> as a method name, so
|
159
|
-
Here is the current list:
|
191
|
+
(For example, it is impractical to use the name <tt>def</tt> as a method name, so the module has a
|
192
|
+
<tt>_def</tt> method instead.) Here is the current list:
|
193
|
+
<p>
|
160
194
|
|
161
195
|
<table>
|
162
196
|
<tr>
|
163
|
-
<td width=3%><td width=10%> <tt>comment</tt>
|
164
|
-
</
|
197
|
+
<td width=3%><td width=10%> <tt>comment</tt> %% Start a comment block</td><td></td>
|
198
|
+
</tr>
|
199
|
+
<tr>
|
200
|
+
<td width=3%><td width=10%> <tt>errout</tt> %% Write an error message to STDERR</td><td></td>
|
201
|
+
</tr>
|
202
|
+
<tr>
|
203
|
+
<td width=3%><td width=10%> <tt>def</tt> %% Define a new method inline</td><td></td>
|
204
|
+
</tr>
|
205
|
+
<tr>
|
206
|
+
<td width=3%><td width=10%> <tt>set</tt> %% Assign values to variables for later interpolation</td><td></td>
|
207
|
+
</tr>
|
208
|
+
<tr>
|
209
|
+
<td width=3%><td width=10%> <tt>include</tt> %% Include an outside text file (to be interpreted as Livetext)</td><td></td>
|
210
|
+
</tr>
|
211
|
+
<tr>
|
212
|
+
<td width=3%><td width=10%> <tt>mixin</tt> %% Mix this file of Ruby methods into the standard namespace</td><td></td>
|
165
213
|
</tr>
|
166
214
|
<tr>
|
167
|
-
<td width=3%><td width=10%> <tt>
|
168
|
-
</td>
|
215
|
+
<td width=3%><td width=10%> <tt>copy</tt> %% Copy this input file verbatim (no interpretation)</td><td></td>
|
169
216
|
</tr>
|
170
217
|
<tr>
|
171
|
-
<td width=3%><td width=10%> <tt>
|
172
|
-
</td>
|
218
|
+
<td width=3%><td width=10%> <tt>r</tt> %% Pass a single line through without processing</td><td></td>
|
173
219
|
</tr>
|
174
220
|
<tr>
|
175
|
-
<td width=3%><td width=10%> <tt>
|
176
|
-
</td>
|
221
|
+
<td width=3%><td width=10%> <tt>raw</tt> %% Pass this special text block (terminated with <tt>__EOF__</tt>) directly into output without processing </td><td></td>
|
177
222
|
</tr>
|
178
223
|
<tr>
|
179
|
-
<td width=3%><td width=10
|
180
|
-
</td>
|
224
|
+
<td width=3%><td width=10%><tt>func</tt> %% Define a function to be invoked inline</td><td></td>
|
181
225
|
</tr>
|
182
226
|
<tr>
|
183
|
-
<td width=3%><td width=10
|
184
|
-
</td>
|
227
|
+
<td width=3%><td width=10%><tt>say</tt> %% Print a message to the screen</td><td></td>
|
185
228
|
</tr>
|
186
229
|
<tr>
|
187
|
-
<td width=3%><td width=10
|
188
|
-
</td>
|
230
|
+
<td width=3%><td width=10%><tt>banner</tt> %% Print a "noticeable" message to the screen</td><td></td>
|
189
231
|
</tr>
|
190
232
|
<tr>
|
191
|
-
<td width=3%><td width=10
|
192
|
-
</td>
|
233
|
+
<td width=3%><td width=10%><tt>quit</tt> %% End processing and exit</td><td></td>
|
193
234
|
</tr>
|
194
235
|
<tr>
|
195
|
-
<td width=3%><td width=10
|
196
|
-
</td>
|
236
|
+
<td width=3%><td width=10%><tt>nopass</tt> %% Don't pass lines through (just honor commands)</td><td></td>
|
197
237
|
</tr>
|
198
238
|
<tr>
|
199
|
-
<td width=3%><td width=10
|
200
|
-
</
|
239
|
+
<td width=3%><td width=10%><tt>include</tt> %% Read and process another file (typically a <tt>.ltx</tt> file)</td><td></td>
|
240
|
+
</tr>
|
241
|
+
<tr>
|
242
|
+
<td width=3%><td width=10%><tt>debug</tt> %% Turn on debugging</td><td></td>
|
243
|
+
</tr>
|
244
|
+
<tr>
|
245
|
+
<td width=3%><td width=10%><tt>nopara</tt> %% Turn off the "blank line implies new paragraph" switch</td><td></td>
|
246
|
+
</tr>
|
247
|
+
<tr>
|
248
|
+
<td width=3%><td width=10%><tt>newpage</tt> %% Start a new output page</td><td></td>
|
201
249
|
</tr>
|
202
250
|
</table>
|
203
|
-
|
204
|
-
<
|
251
|
+
### Examples from the tests
|
252
|
+
<p>
|
205
253
|
|
206
254
|
Here are some tests from the suite. The file name reflects the general purpose of the test.
|
255
|
+
<p>
|
207
256
|
|
208
257
|
|
209
|
-
<b>Test:
|
258
|
+
<font size=+1><b>Test: </font><font size=+2><tt>hello_world</tt></font></b></h3><br>
|
210
259
|
<center>
|
211
260
|
<table width=80% cellpadding=4>
|
212
261
|
<tr>
|
@@ -227,8 +276,9 @@ Here are some tests from the suite. The file name reflects the general purpose o
|
|
227
276
|
</tr>
|
228
277
|
</table>
|
229
278
|
</center>
|
279
|
+
<br>
|
230
280
|
|
231
|
-
<b>Test:
|
281
|
+
<font size=+1><b>Test: </font><font size=+2><tt>comments_ignored_1</tt></font></b></h3><br>
|
232
282
|
<center>
|
233
283
|
<table width=80% cellpadding=4>
|
234
284
|
<tr>
|
@@ -256,72 +306,9 @@ Here are some tests from the suite. The file name reflects the general purpose o
|
|
256
306
|
</tr>
|
257
307
|
</table>
|
258
308
|
</center>
|
309
|
+
<br>
|
259
310
|
|
260
|
-
<b>Test:
|
261
|
-
<center>
|
262
|
-
<table width=80% cellpadding=4>
|
263
|
-
<tr>
|
264
|
-
<td width=50%><b>Input</b></td>
|
265
|
-
<td width=50%><b>Output</b></td>
|
266
|
-
</tr>
|
267
|
-
<tr>
|
268
|
-
<td width=50% bgcolor=#fec0fe valign=top>
|
269
|
-
<pre> .. Comments (with a double-dot) are ignored
|
270
|
-
abc 123
|
271
|
-
this is a test
|
272
|
-
.. whether at beginning, middle, or
|
273
|
-
more stuff
|
274
|
-
still more stuff
|
275
|
-
.. end of the file
|
276
|
-
</pre>
|
277
|
-
</td>
|
278
|
-
<td width=50% bgcolor=lightgray valign=top>
|
279
|
-
<pre> abc 123
|
280
|
-
this is a test
|
281
|
-
more stuff
|
282
|
-
still more stuff
|
283
|
-
</pre>
|
284
|
-
</td>
|
285
|
-
</tr>
|
286
|
-
</table>
|
287
|
-
</center>
|
288
|
-
|
289
|
-
<b>Test: <tt>004\_sigil\_can\_change</tt></b><br>
|
290
|
-
<center>
|
291
|
-
<table width=80% cellpadding=4>
|
292
|
-
<tr>
|
293
|
-
<td width=50%><b>Input</b></td>
|
294
|
-
<td width=50%><b>Output</b></td>
|
295
|
-
</tr>
|
296
|
-
<tr>
|
297
|
-
<td width=50% bgcolor=#fec0fe valign=top>
|
298
|
-
<pre> . This is a comment
|
299
|
-
.sigil #
|
300
|
-
# Comments are ignored
|
301
|
-
abc 123
|
302
|
-
this is a test
|
303
|
-
. this is not a comment
|
304
|
-
# whether at beginning, middle, or
|
305
|
-
more stuff
|
306
|
-
.this means nothing
|
307
|
-
still more stuff
|
308
|
-
# end of the file
|
309
|
-
</pre>
|
310
|
-
</td>
|
311
|
-
<td width=50% bgcolor=lightgray valign=top>
|
312
|
-
<pre> abc 123
|
313
|
-
this is a test
|
314
|
-
. this is not a comment
|
315
|
-
more stuff
|
316
|
-
.this means nothing
|
317
|
-
still more stuff
|
318
|
-
</pre>
|
319
|
-
</td>
|
320
|
-
</tr>
|
321
|
-
</table>
|
322
|
-
</center>
|
323
|
-
|
324
|
-
<b>Test: <tt>005\_block\_comment</tt></b><br>
|
311
|
+
<font size=+1><b>Test: </font><font size=+2><tt>block_comment</tt></font></b></h3><br>
|
325
312
|
<center>
|
326
313
|
<table width=80% cellpadding=4>
|
327
314
|
<tr>
|
@@ -348,12 +335,12 @@ Here are some tests from the suite. The file name reflects the general purpose o
|
|
348
335
|
is
|
349
336
|
this
|
350
337
|
.end
|
338
|
+
|
351
339
|
</pre>
|
352
340
|
</td>
|
353
341
|
<td width=50% bgcolor=lightgray valign=top>
|
354
342
|
<pre> abc 123
|
355
343
|
xyz
|
356
|
-
|
357
344
|
one
|
358
345
|
more
|
359
346
|
time
|
@@ -362,8 +349,9 @@ Here are some tests from the suite. The file name reflects the general purpose o
|
|
362
349
|
</tr>
|
363
350
|
</table>
|
364
351
|
</center>
|
352
|
+
<br>
|
365
353
|
|
366
|
-
<b>Test:
|
354
|
+
<font size=+1><b>Test: </font><font size=+2><tt>def_method</tt></font></b></h3><br>
|
367
355
|
<center>
|
368
356
|
<table width=80% cellpadding=4>
|
369
357
|
<tr>
|
@@ -395,8 +383,9 @@ Here are some tests from the suite. The file name reflects the general purpose o
|
|
395
383
|
</tr>
|
396
384
|
</table>
|
397
385
|
</center>
|
386
|
+
<br>
|
398
387
|
|
399
|
-
<b>Test:
|
388
|
+
<font size=+1><b>Test: </font><font size=+2><tt>simple_vars</tt></font></b></h3><br>
|
400
389
|
<center>
|
401
390
|
<table width=80% cellpadding=4>
|
402
391
|
<tr>
|
@@ -426,8 +415,9 @@ Here are some tests from the suite. The file name reflects the general purpose o
|
|
426
415
|
</tr>
|
427
416
|
</table>
|
428
417
|
</center>
|
418
|
+
<br>
|
429
419
|
|
430
|
-
<b>Test:
|
420
|
+
<font size=+1><b>Test: </font><font size=+2><tt>simple_include</tt></font></b></h3><br>
|
431
421
|
<center>
|
432
422
|
<table width=80% cellpadding=4>
|
433
423
|
<tr>
|
@@ -437,6 +427,7 @@ Here are some tests from the suite. The file name reflects the general purpose o
|
|
437
427
|
<tr>
|
438
428
|
<td width=50% bgcolor=#fec0fe valign=top>
|
439
429
|
<pre> Here I am
|
430
|
+
.debug
|
440
431
|
trying to
|
441
432
|
include
|
442
433
|
.include simplefile.inc
|
@@ -457,8 +448,9 @@ Here are some tests from the suite. The file name reflects the general purpose o
|
|
457
448
|
</tr>
|
458
449
|
</table>
|
459
450
|
</center>
|
451
|
+
<br>
|
460
452
|
|
461
|
-
<b>Test:
|
453
|
+
<font size=+1><b>Test: </font><font size=+2><tt>simple_mixin</tt></font></b></h3><br>
|
462
454
|
<center>
|
463
455
|
<table width=80% cellpadding=4>
|
464
456
|
<tr>
|
@@ -486,8 +478,9 @@ Here are some tests from the suite. The file name reflects the general purpose o
|
|
486
478
|
</tr>
|
487
479
|
</table>
|
488
480
|
</center>
|
481
|
+
<br>
|
489
482
|
|
490
|
-
<b>Test:
|
483
|
+
<font size=+1><b>Test: </font><font size=+2><tt>simple_copy</tt></font></b></h3><br>
|
491
484
|
<center>
|
492
485
|
<table width=80% cellpadding=4>
|
493
486
|
<tr>
|
@@ -517,8 +510,9 @@ Here are some tests from the suite. The file name reflects the general purpose o
|
|
517
510
|
</tr>
|
518
511
|
</table>
|
519
512
|
</center>
|
513
|
+
<br>
|
520
514
|
|
521
|
-
<b>Test:
|
515
|
+
<font size=+1><b>Test: </font><font size=+2><tt>copy_is_raw</tt></font></b></h3><br>
|
522
516
|
<center>
|
523
517
|
<table width=80% cellpadding=4>
|
524
518
|
<tr>
|
@@ -546,8 +540,9 @@ Here are some tests from the suite. The file name reflects the general purpose o
|
|
546
540
|
</tr>
|
547
541
|
</table>
|
548
542
|
</center>
|
543
|
+
<br>
|
549
544
|
|
550
|
-
<b>Test:
|
545
|
+
<font size=+1><b>Test: </font><font size=+2><tt>raw_text_block</tt></font></b></h3><br>
|
551
546
|
<center>
|
552
547
|
<table width=80% cellpadding=4>
|
553
548
|
<tr>
|
@@ -570,6 +565,7 @@ Here are some tests from the suite. The file name reflects the general purpose o
|
|
570
565
|
Or this: `(alpha male) \_(beta max) *(gamma rays)
|
571
566
|
\_\_EOF\_\_
|
572
567
|
|
568
|
+
|
573
569
|
I hope that worked.
|
574
570
|
</pre>
|
575
571
|
</td>
|
@@ -585,6 +581,7 @@ Here are some tests from the suite. The file name reflects the general purpose o
|
|
585
581
|
|
586
582
|
And this stuff won't be munged: `alpha \_beta *gamma
|
587
583
|
Or this: `(alpha male) \_(beta max) *(gamma rays)
|
584
|
+
<p>
|
588
585
|
|
589
586
|
I hope that worked.
|
590
587
|
</pre>
|
@@ -592,15 +589,20 @@ Here are some tests from the suite. The file name reflects the general purpose o
|
|
592
589
|
</tr>
|
593
590
|
</table>
|
594
591
|
</center>
|
592
|
+
<br>
|
593
|
+
<p>
|
595
594
|
|
596
|
-
|
595
|
+
### Writing custom methods
|
596
|
+
<p>
|
597
597
|
|
598
598
|
Suppose you wanted to write a method called <tt>chapter</tt> that would simply
|
599
599
|
output a chapter number and title with certain heading tags and a
|
600
600
|
horizontal rule following. There is more than one way to do this.
|
601
|
+
<p>
|
601
602
|
|
602
603
|
The simplest way is just to define a method inline with the rest of
|
603
604
|
the text. Here's an example.
|
605
|
+
<p>
|
604
606
|
|
605
607
|
<pre>
|
606
608
|
.comment
|
@@ -626,26 +628,30 @@ the text. Here's an example.
|
|
626
628
|
It was the best of times, and you can call me Ishmael. The clocks
|
627
629
|
were striking thirteen.
|
628
630
|
</pre>
|
629
|
-
|
630
631
|
What can we see from this example? First of all, notice that the part
|
631
632
|
between <tt>.def</tt> and <tt>.end</tt> (the body of the method) really is just Ruby
|
632
633
|
code. The method takes no parameters because parameter passing is
|
633
634
|
handled inside the Livetext engine and the instance variable <tt>@_args</tt> is
|
634
635
|
initialized to the contents of this array. We usually refer to the
|
635
636
|
<tt>@_args</tt> array only through the method <tt>_args</tt> which returns it.
|
637
|
+
<p>
|
636
638
|
|
637
639
|
The <tt>_args</tt> method is also an iterator. If a block is attached, that block
|
638
640
|
will be called for every argument.
|
641
|
+
<p>
|
639
642
|
|
640
643
|
We then create a string using these parameters and call it using the
|
641
644
|
<tt>_puts</tt> method. This really does do a <tt>puts</tt> call, but it applies it to
|
642
645
|
wherever the output is currently being sent (defaulting to STDOUT).
|
646
|
+
<p>
|
643
647
|
|
644
648
|
All the "helper" methods start with an underscore so as to avoid name
|
645
|
-
collisions. These are all stored in the <tt>Livetext::
|
649
|
+
collisions. These are all stored in the <tt>Livetext::UserAPI</tt> module
|
646
650
|
(which also has some methods you will never use).
|
651
|
+
<p>
|
647
652
|
|
648
653
|
Here is the HTML output of the previous example:
|
654
|
+
<p>
|
649
655
|
|
650
656
|
<pre>
|
651
657
|
<h3>Chapter 1</h3>
|
@@ -654,55 +660,46 @@ Here is the HTML output of the previous example:
|
|
654
660
|
It was the best of times, and you can call me Ishmael. The clocks
|
655
661
|
were striking thirteen.
|
656
662
|
</pre>
|
657
|
-
|
658
663
|
What are some other helper methods? Here's a list.
|
664
|
+
<p>
|
659
665
|
|
660
666
|
<table>
|
661
667
|
<tr>
|
662
|
-
<td width=3%><td width=10%><tt>_args</tt>
|
663
|
-
</td>
|
664
|
-
</tr>
|
665
|
-
<tr>
|
666
|
-
<td width=3%><td width=10%><tt>_data</tt> </td><td> A single "unsplit" string of all arguments in raw form
|
667
|
-
</td>
|
668
|
+
<td width=3%><td width=10%><tt>_args</tt> %% Returns an array of arguments for the method (or an enumerator for that array)</td><td></td>
|
668
669
|
</tr>
|
669
670
|
<tr>
|
670
|
-
<td width=3%><td width=10%><tt>
|
671
|
-
</td>
|
671
|
+
<td width=3%><td width=10%><tt>_data</tt> %% A single "unsplit" string of all arguments in raw form</td><td></td>
|
672
672
|
</tr>
|
673
673
|
<tr>
|
674
|
-
<td width=3%><td width=10%><tt>
|
675
|
-
</td>
|
674
|
+
<td width=3%><td width=10%><tt>_body</tt> %% Returns a string (or enumerator) giving access to the text block (preceding <tt></tt>.end)</td><td></td>
|
676
675
|
</tr>
|
677
676
|
<tr>
|
678
|
-
<td width=3%><td width=10%><tt>
|
679
|
-
</td>
|
677
|
+
<td width=3%><td width=10%><tt>_puts</tt> %% Write a line to output (STDOUT or wherever)</td><td></td>
|
680
678
|
</tr>
|
681
679
|
<tr>
|
682
|
-
<td width=3%><td width=10%><tt>
|
683
|
-
</td>
|
680
|
+
<td width=3%><td width=10%><tt>_print</tt> %% Write a line to output (STDOUT or wherever) without a newline</td><td></td>
|
684
681
|
</tr>
|
685
682
|
<tr>
|
686
|
-
<td width=3%><td width=10%><tt>
|
687
|
-
</td>
|
683
|
+
<td width=3%><td width=10%><tt>_formatting</tt> %% A function transforming boldface, italics, and monospace (Livetext conventions)</td><td></td>
|
688
684
|
</tr>
|
689
685
|
<tr>
|
690
|
-
<td width=3%><td width=10%><tt>_passthru</tt>
|
691
|
-
</td>
|
686
|
+
<td width=3%><td width=10%><tt>_passthru</tt> %% Feed a line directly into output after transforming and substituting</td><td></td>
|
692
687
|
</tr>
|
693
688
|
</table>
|
694
|
-
|
695
689
|
Note that the last three methods are typically <i>not</i> called in your own code. They could be,
|
696
690
|
but it remains to be seen whether something that advanced is useful.
|
691
|
+
<p>
|
697
692
|
|
698
|
-
|
693
|
+
### More examples
|
694
|
+
<p>
|
699
695
|
|
700
696
|
Suppose you wanted to take a list of words, more than one per line, and alphabetize them.
|
701
697
|
Let's write a method called <tt>alpha</tt> for that. This exercise and the next one are implemented
|
702
698
|
in the test suite.
|
699
|
+
<p>
|
703
700
|
|
704
701
|
|
705
|
-
<b>Test:
|
702
|
+
<font size=+1><b>Test: </font><font size=+2><tt>example_alpha</tt></font></b></h3><br>
|
706
703
|
<center>
|
707
704
|
<table width=80% cellpadding=4>
|
708
705
|
<tr>
|
@@ -726,11 +723,13 @@ in the test suite.
|
|
726
723
|
cytology fusillade ectomorph
|
727
724
|
.end
|
728
725
|
|
726
|
+
|
729
727
|
I hope that worked.
|
730
728
|
</pre>
|
731
729
|
</td>
|
732
730
|
<td width=50% bgcolor=lightgray valign=top>
|
733
731
|
<pre> Here is an alphabetized list:
|
732
|
+
<p>
|
734
733
|
|
735
734
|
aardvark
|
736
735
|
anamorphic
|
@@ -749,6 +748,7 @@ in the test suite.
|
|
749
748
|
quark
|
750
749
|
zootrope
|
751
750
|
zymurgy
|
751
|
+
<p>
|
752
752
|
|
753
753
|
I hope that worked.
|
754
754
|
</pre>
|
@@ -756,12 +756,15 @@ in the test suite.
|
|
756
756
|
</tr>
|
757
757
|
</table>
|
758
758
|
</center>
|
759
|
+
<br>
|
760
|
+
<p>
|
759
761
|
|
760
762
|
I'll let that code stand on its own. Now suppose you wanted to allow columnar output. Let's
|
761
763
|
have the user specify a number of columns (from 1 to 5, defaulting to 1).
|
764
|
+
<p>
|
762
765
|
|
763
766
|
|
764
|
-
<b>Test:
|
767
|
+
<font size=+1><b>Test: </font><font size=+2><tt>example_alpha2</tt></font></b></h3><br>
|
765
768
|
<center>
|
766
769
|
<table width=80% cellpadding=4>
|
767
770
|
<tr>
|
@@ -792,11 +795,13 @@ have the user specify a number of columns (from 1 to 5, defaulting to 1).
|
|
792
795
|
cytology fusillade ectomorph
|
793
796
|
.end
|
794
797
|
|
798
|
+
|
795
799
|
I hope that worked a second time.
|
796
800
|
</pre>
|
797
801
|
</td>
|
798
802
|
<td width=50% bgcolor=lightgray valign=top>
|
799
803
|
<pre> Here is an alphabetized list:
|
804
|
+
<p>
|
800
805
|
|
801
806
|
aardvark anamorphic anarchist
|
802
807
|
bellicose cytology ectomorph
|
@@ -804,6 +809,7 @@ have the user specify a number of columns (from 1 to 5, defaulting to 1).
|
|
804
809
|
gryphon halcyon manicotti
|
805
810
|
mataeotechny pareidolia quark
|
806
811
|
zootrope zymurgy
|
812
|
+
<p>
|
807
813
|
|
808
814
|
I hope that worked a second time.
|
809
815
|
</pre>
|
@@ -811,13 +817,17 @@ have the user specify a number of columns (from 1 to 5, defaulting to 1).
|
|
811
817
|
</tr>
|
812
818
|
</table>
|
813
819
|
</center>
|
820
|
+
<br>
|
821
|
+
<p>
|
814
822
|
|
815
823
|
What if we wanted to store the code outside the text file? There is more than one way to
|
816
824
|
do this.
|
825
|
+
<p>
|
817
826
|
|
818
827
|
Let's assume we have a file called <tt>mylib.rb</tt> in the same directory as the file we're processing.
|
819
828
|
(Issues such as paths and security have not been addressed yet.) We'll stick the actual Ruby code
|
820
829
|
in here (and nothing else).
|
830
|
+
<p>
|
821
831
|
|
822
832
|
<pre>
|
823
833
|
# File: mylib.rb
|
@@ -836,8 +846,8 @@ in here (and nothing else).
|
|
836
846
|
end
|
837
847
|
end
|
838
848
|
</pre>
|
839
|
-
|
840
|
-
|
849
|
+
Now the <tt>.ltx</tt> file can be written this way:
|
850
|
+
<p>
|
841
851
|
|
842
852
|
<pre>
|
843
853
|
.mixin mylib
|
@@ -852,8 +862,8 @@ Now the <tt>.lt</tt> file can be written this way:
|
|
852
862
|
|
853
863
|
I hope that worked a second time.
|
854
864
|
</pre>
|
855
|
-
|
856
865
|
The output, of course, is the same.
|
866
|
+
<p>
|
857
867
|
|
858
868
|
There is an important feature that has not yet been implemented (the
|
859
869
|
<tt>require</tt> method). Like Ruby's <tt>require</tt>, it will grab Ruby code and
|
@@ -862,104 +872,61 @@ object and associate a new sigil with it. So for example, the command
|
|
862
872
|
<tt>.foobar</tt> would refer to a method in the <tt>Livetext::Standard</tt> class
|
863
873
|
(whether predefined or user-defined). If we did a <tt>require</tt> on a file
|
864
874
|
and associated the sigil <tt>#</tt> with it, then <tt>#foobar</tt> would be a method
|
865
|
-
on that new custom object. I
|
875
|
+
on that new custom object. I plan to implement this later.
|
876
|
+
<p>
|
866
877
|
|
867
|
-
|
878
|
+
### Issues, open questions, and to-do items
|
879
|
+
<p>
|
868
880
|
|
869
881
|
This list is not prioritized yet.
|
870
|
-
|
871
|
-
|
872
|
-
<
|
873
|
-
</
|
874
|
-
|
875
|
-
</
|
876
|
-
<
|
877
|
-
</
|
878
|
-
<
|
879
|
-
</
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
</
|
884
|
-
|
885
|
-
</
|
886
|
-
<
|
887
|
-
|
888
|
-
|
889
|
-
</
|
890
|
-
|
891
|
-
|
892
|
-
<
|
893
|
-
|
894
|
-
|
895
|
-
</
|
896
|
-
|
897
|
-
|
898
|
-
<
|
899
|
-
|
900
|
-
|
901
|
-
</
|
902
|
-
<
|
903
|
-
</
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
<
|
913
|
-
</
|
914
|
-
|
915
|
-
|
916
|
-
<
|
917
|
-
</
|
918
|
-
<
|
919
|
-
|
920
|
-
|
921
|
-
</li>
|
922
|
-
<li>Think about passing data in (erb replacement)
|
923
|
-
</li>
|
924
|
-
<li>Allow custom ending tag on <tt>raw</tt> method
|
925
|
-
</li>
|
926
|
-
<li>Ignore first blank line after <tt>.end</tt>? (and after raw-tag?)
|
927
|
-
</li>
|
928
|
-
<li>Allow/encourage custom <tt>passthru</tt> method?
|
929
|
-
</li>
|
930
|
-
<li>Must have sane support for CSS
|
931
|
-
</li>
|
932
|
-
<li>Support for Pygments and/or other code processors
|
933
|
-
</li>
|
934
|
-
<li>Support for gists? arbitrary links? other remote resouces?
|
935
|
-
</li>
|
936
|
-
<li>Small libraries for special purposes (books? special Softcover support? blogs? PDF? RMagick?)
|
937
|
-
</li>
|
938
|
-
<li>Experiment with idea of special libraries having pluggable output formats (via Ruby mixin?)
|
939
|
-
</li>
|
940
|
-
<li>Imagining a lib that can run/test code fragments as part of document generation
|
941
|
-
</li>
|
942
|
-
<li>Create vim (emacs?) syntax files
|
943
|
-
</li>
|
944
|
-
<li>Someday: Support other languages (Elixir, Python, ...)
|
945
|
-
</li>
|
946
|
-
<li><tt>.pry</tt> method?
|
947
|
-
</li>
|
948
|
-
<li><tt>.irb</tt> method?
|
949
|
-
</li>
|
950
|
-
<li>Other debugging features
|
951
|
-
</li>
|
952
|
-
<li>Feature to "break" to EOF?
|
953
|
-
</li>
|
954
|
-
<li><tt>.meth?</tt> method ending in <tt>?</tt> takes a block that may be processed or thrown away (`(.else) perhaps?)
|
955
|
-
</li>
|
956
|
-
<li><tt>.dump</tt> to dump all variables and their values
|
957
|
-
</li>
|
958
|
-
<li><tt>.if</tt> and <tt>.else</tt>?
|
959
|
-
</li>
|
960
|
-
<li>Make any/all delimiters configurable
|
961
|
-
</li>
|
962
|
-
<li>HTML helper? (in their own library?)
|
963
|
-
</li>
|
964
|
-
</ol>
|
965
|
-
|
882
|
+
<p>
|
883
|
+
|
884
|
+
1. <strike>Add versioning information </strike>
|
885
|
+
2. <strike>Clean up code structure</strike>
|
886
|
+
3. Add RDoc
|
887
|
+
4. <strike>Think about command line executable</strike>
|
888
|
+
5. <strike>Write as pure library in addition to executable</strike>
|
889
|
+
6. <strike>Package as gem</strike>
|
890
|
+
7. Document: <tt>require</tt> <tt>include</tt> <tt>copy</tt> <tt>mixin</tt> <tt>errout</tt> and others
|
891
|
+
8. Need <strike>much</strike> better error checking and corresponding tests
|
892
|
+
9. Worry about nesting of elements (probably mostly disallow)
|
893
|
+
10. Think about UTF-8
|
894
|
+
11. Document API fully
|
895
|
+
12. Add <tt>_raw_args</tt> and let <tt>_args</tt> honor quotes
|
896
|
+
13. Support quotes in <tt>.set</tt> values
|
897
|
+
14. Support "namespaced" variables (<tt>.set code.font="whatever"</tt>)
|
898
|
+
15. <strike>Support functions (``$$func) </strike>
|
899
|
+
16. Support function namespacing
|
900
|
+
17. Create predefined variables (e.g., <tt>$_source_file</tt>, <tt>$[_line])</tt>
|
901
|
+
18. Create predefined functions (e.g., <tt>$$_date</tt>)
|
902
|
+
19. More support for markdown
|
903
|
+
20. Allow turning on/off: formatting, variable interpolation, function interpolation?
|
904
|
+
21. <tt>.require</tt> with file and sigil parameters
|
905
|
+
22. Investigate "common intermediate format" - output renderers all read it
|
906
|
+
23. Comments passed through (e.g. as HTML comments)
|
907
|
+
24. <tt>.run</tt> to execute arbitrary Ruby code inline?
|
908
|
+
25. Concept of <tt>.proc</tt> (guaranteed to return no value, produce no output)?
|
909
|
+
26. Exceptions??
|
910
|
+
27. Ruby <tt>$SAFE</tt> levels?
|
911
|
+
28. Warn when overriding existing names?
|
912
|
+
29. Think about passing data in (erb replacement)
|
913
|
+
30. <strike>]Allow</strike> custom ending tag on <tt>raw</tt> method
|
914
|
+
31. <strike>Ignore first blank line after `[.end</strike>? (and after raw-tag?)
|
915
|
+
32. Allow/encourage custom <tt>passthru</tt> method?
|
916
|
+
33. Must have sane support for CSS
|
917
|
+
34. Support for Pygments and/or other code processors
|
918
|
+
35. Support for gists? arbitrary links? other remote resouces?
|
919
|
+
36. Small libraries for special purposes (books? special Softcover support? blogs? PDF? RMagick?)
|
920
|
+
37. Experiment with idea of special libraries having pluggable output formats (via Ruby mixin?)
|
921
|
+
38. Imagining a lib that can run/test code fragments as part of document generation
|
922
|
+
39. Create vim (emacs?) syntax files
|
923
|
+
40. Someday: Support other languages (Elixir, Python, ...)
|
924
|
+
41. <tt>.pry</tt> method?
|
925
|
+
42. <tt>.irb</tt> method?
|
926
|
+
43. Other debugging features
|
927
|
+
44. Feature to "break" to EOF?
|
928
|
+
45. <tt>.meth?</tt> method ending in <tt>?</tt> takes a block that may be processed or thrown away (<tt>.else</tt> perhaps?)
|
929
|
+
46. <tt>.dump</tt> to dump all variables and their values
|
930
|
+
47. <tt>.if</tt> and <tt>.else</tt>?
|
931
|
+
48. Make any/all delimiters configurable
|
932
|
+
49. HTML helper? (in their own library?)
|