livetext 0.8.77 → 0.8.78

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  class Livetext
2
- VERSION = "0.8.77"
2
+ VERSION = "0.8.78"
3
3
  Path = File.expand_path(File.join(File.dirname(__FILE__)))
4
4
  end
5
5
 
@@ -99,9 +99,9 @@ class Livetext
99
99
  val = @main.finalize if @main.respond_to? :finalize
100
100
  val
101
101
  rescue => err
102
- puts @body
103
102
  puts "process_text: err = #{err}"
104
103
  puts err.backtrace.join("\n")
104
+ puts @body
105
105
  end
106
106
 
107
107
  ## FIXME process_file[!] should call process[_text]
@@ -117,6 +117,7 @@ class Livetext
117
117
  loop do
118
118
  line = @main.nextline
119
119
  break if line.nil?
120
+ # STDERR.puts "LINE: #{line.inspect}"
120
121
  process_line(line, context)
121
122
  end
122
123
  val = @main.finalize if @main.respond_to? :finalize
@@ -170,8 +171,8 @@ class Livetext
170
171
  end
171
172
  result
172
173
  rescue => err
173
- puts @body
174
174
  @main._error!(err)
175
+ puts @body
175
176
  end
176
177
 
177
178
  end
@@ -34,7 +34,7 @@ class Livetext
34
34
  where = @sources.last || @save_location
35
35
  puts @parent.body
36
36
  STDERR.puts "Error: #{err} (at #{where[1]} line #{where[2]})"
37
- STDERR.puts err.backtrace if trace && err.respond_to?(:backtrace)
37
+ # STDERR.puts err.backtrace if err.respond_to?(:backtrace) # && trace
38
38
  exit if abort
39
39
  end
40
40
 
@@ -146,8 +146,8 @@ module Livetext::Standard
146
146
  str += "end\n"
147
147
  eval str
148
148
  rescue => err
149
- puts @body
150
149
  _error!(err)
150
+ # puts @body
151
151
  end
152
152
 
153
153
  def set
@@ -164,8 +164,11 @@ module Livetext::Standard
164
164
 
165
165
  def heredoc
166
166
  var = @_args[0]
167
+ # STDERR.puts "var = #{var.inspect}"
167
168
  str = _body_text
169
+ # STDERR.puts "str = #{str.inspect}"
168
170
  Livetext::Vars[var] = str
171
+ # STDERR.puts "vars = #{Livetext::Vars.inspect}"
169
172
  _optional_blank_line
170
173
  end
171
174
 
@@ -217,7 +220,7 @@ module Livetext::Standard
217
220
 
218
221
  def raw
219
222
  # No processing at all (terminate with __EOF__)
220
- _out _raw_body
223
+ _raw_body {|x| _out x } # no formatting
221
224
  end
222
225
 
223
226
  def debug
@@ -49,14 +49,17 @@ module Livetext::UserAPI
49
49
  loop do
50
50
  @line = nextline
51
51
  break if @line.chomp.strip == tag
52
+ # STDERR.puts "_raw_body adds: #{@line.inspect}"
52
53
  lines << @line
53
54
  end
54
55
  _optional_blank_line
55
56
  if block_given?
56
- lines.each {|line| yield @line }
57
+ lines.each {|line| yield line }
57
58
  else
58
59
  lines
59
60
  end
61
+ # STDERR.puts "_raw_body returns: #{lines.inspect}"
62
+ lines
60
63
  end
61
64
 
62
65
  def _body(raw=false, sigil=".")
@@ -77,9 +80,9 @@ module Livetext::UserAPI
77
80
  lines
78
81
  end
79
82
  rescue => err
80
- puts @body
81
83
  # FIXME ?
82
84
  _error!("Expecting .end, found end of file")
85
+ # puts @body
83
86
  end
84
87
 
85
88
  def _body_text(raw=false, sigil=".")
@@ -99,20 +102,20 @@ module Livetext::UserAPI
99
102
  end
100
103
 
101
104
  def _formatting(line, context = nil)
102
- @parser ||= ::FormatLine.new
103
- l2 = @parser.parse(line, context)
105
+ l2 = FormatLine.parse!(line, context)
104
106
  line.replace(l2)
105
107
  end
106
108
 
107
109
  def _passthru(line, context = nil)
108
110
  return if @_nopass
109
111
  _out "<p>" if line == "\n" and ! @_nopara
110
- _formatting(line, context)
112
+ line = _formatting(line, context)
111
113
  _out line
112
114
  end
113
115
 
114
116
  def _out(str = "")
115
117
  # if @no_puts
118
+ # STDERR.puts "_out: #{str.inspect}"
116
119
  @parent.body << str
117
120
  @parent.body << "\n" unless str.end_with?("\n")
118
121
  # else
@@ -0,0 +1,284 @@
1
+ tick: Single token, beginning of line
2
+ `def is like a reserved word
3
+ <font size=+1><tt>def</tt></font> is like a reserved word
4
+
5
+ tick: Single token, middle of line
6
+ They say `def is like a reserved word
7
+ They say <font size=+1><tt>def</tt></font> is like a reserved word
8
+
9
+ tick: Single token, end of line
10
+ like a reserved word, is `def
11
+ like a reserved word, is <font size=+1><tt>def</tt></font>
12
+
13
+ tick: Bracketed, normal
14
+ This is `[code font] here
15
+ This is <font size=+1><tt>code font</tt></font> here
16
+
17
+ tick: Bracketed, hits EOL
18
+ This is `[code font here
19
+ This is <font size=+1><tt>code font here</tt></font>
20
+
21
+ tick: followed by space
22
+ This is not ` code
23
+ This is not ` code
24
+
25
+ tick: followed by EOL
26
+ This also isn't code: `
27
+ This also isn't code: `
28
+
29
+ tick: Doubled, ignores comma
30
+ This is ``code, of course
31
+ This is <font size=+1><tt>code</tt></font>, of course
32
+
33
+ tick: Doubled, ignores period
34
+ This is ``code. Hooray, I guess.
35
+ This is <font size=+1><tt>code</tt></font>. Hooray, I guess.
36
+
37
+ tick: Doubled, ignores right paren
38
+ (By the way, this is ``code)
39
+ (By the way, this is <font size=+1><tt>code</tt></font>)
40
+
41
+ tick: Doubled, ignores EOL
42
+ Up to EOL, this is ``code
43
+ Up to EOL, this is <font size=+1><tt>code</tt></font>
44
+
45
+ uscore: Single token, beginning of line
46
+ _This is italics
47
+ <i>This</i> is italics
48
+
49
+ uscore: Single token, middle of line
50
+ And _this is italics
51
+ And <i>this</i> is italics
52
+
53
+ uscore: Single token, end of line
54
+ And so is _this
55
+ And so is <i>this</i>
56
+
57
+ uscore: Bracketed, normal
58
+ The _[USS Enterprise] was here
59
+ The <i>USS Enterprise</i> was here
60
+
61
+ uscore: Bracketed, hits EOL
62
+ Hey, it's the _[USS Enterprise
63
+ Hey, it's the <i>USS Enterprise</i>
64
+
65
+ uscore: followed by space
66
+ This: _ is just an underscore
67
+ This: _ is just an underscore
68
+
69
+ uscore: followed by EOL
70
+ This is just an underscore: _
71
+ This is just an underscore: _
72
+
73
+ uscore: Doubled, ignores comma
74
+ Just a __second, ok?
75
+ Just a <i>second</i>, ok?
76
+
77
+ uscore: Doubled, ignores period
78
+ Just a __second. OK?
79
+ Just a <i>second</i>. OK?
80
+
81
+ uscore: Doubled, ignores right paren
82
+ I'll (just a __second) be right there.
83
+ I'll (just a <i>second</i>) be right there.
84
+
85
+ uscore: Doubled, ignores EOL
86
+ Be there in a __second
87
+ Be there in a <i>second</i>
88
+
89
+ Tick has precedence over underscore
90
+ This is a `piece_of_code here
91
+ This is a <font size=+1><tt>piece_of_code</tt></font> here
92
+
93
+ under: Starts after double quote?
94
+ He said, "_Please go away."
95
+ He said, "<i>Please</i> go away."
96
+
97
+ Dollar sign followed by blank
98
+ This: $ is a dollar sign
99
+ This: $ is a dollar sign
100
+
101
+ Dollar sign followed by non-alpha
102
+ I'd pay $3 for that
103
+ I'd pay $3 for that
104
+
105
+ Dollar sign followed by EOL
106
+ This is a dollar sign: $
107
+ This is a dollar sign: $
108
+
109
+ Double dollar sign followed by blank
110
+ This: $$ is not a function call
111
+ This: $$ is not a function call
112
+
113
+ Double dollar sign followed by non-alpha
114
+ If I say $$-, that's not a function call
115
+ If I say $$-, that's not a function call
116
+
117
+ Double dollar sign followed by EOL
118
+ This is two dollar signs: $$
119
+ This is two dollar signs: $$
120
+
121
+ Escaped *
122
+ Asterisk followed by abc: \*abc
123
+ Asterisk followed by abc: *abc
124
+
125
+ Escaped _
126
+ Underscore followed by abc: \_abc
127
+ Underscore followed by abc: _abc
128
+
129
+ Escaped `
130
+ Tick followed by abc: \`abc
131
+ Tick followed by abc: `abc
132
+
133
+ Escaped $
134
+ This: \$var is not a variable
135
+ This: $var is not a variable
136
+
137
+ Escaped $$
138
+ This: \$\$func is not a function
139
+ This: $$func is not a function
140
+
141
+ strike: Single token, beginning of line
142
+ ~this - no, I mean that
143
+ <strike>this</strike> - no, I mean that
144
+
145
+ strike: Single token, middle of line
146
+ They say ~redacted is fun
147
+ They say <strike>redacted</strike> is fun
148
+
149
+ strike: Single token, end of line
150
+ Ignore this: ~foobar
151
+ Ignore this: <strike>foobar</strike>
152
+
153
+ strike: Bracketed, normal
154
+ This is ~[crossed out] text
155
+ This is <strike>crossed out</strike> text
156
+
157
+ strike: Bracketed, hits EOL
158
+ This is ~[more stuff crossed out
159
+ This is <strike>more stuff crossed out</strike>
160
+
161
+ strike: followed by space
162
+ This is not ~ overstrike
163
+ This is not ~ overstrike
164
+
165
+ strike: followed by EOL
166
+ This also isn't overstrike: `
167
+ This also isn't overstrike: `
168
+
169
+ strike: Doubled, ignores comma
170
+ This is ~~overstrike, of course
171
+ This is <strike>overstrike</strike>, of course
172
+
173
+ strike: Doubled, ignores period
174
+ This is ~~overstrike. Hooray, I guess.
175
+ This is <strike>overstrike</strike>. Hooray, I guess.
176
+
177
+ strike: Doubled, ignores right paren
178
+ (By the way, this is ~~overstrike)
179
+ (By the way, this is <strike>overstrike</strike>)
180
+
181
+ strike: Doubled, ignores EOL
182
+ Up to EOL, this is ~~redacted
183
+ Up to EOL, this is <strike>redacted</strike>
184
+
185
+ Trying $$b function, no param
186
+ This is $$b being called
187
+ This is <b>NO PARAMETER</b> being called
188
+
189
+ Trying $$b function, brackets
190
+ This is $$b[bold text] being called
191
+ This is <b>bold text</b> being called
192
+
193
+ Trying $$b function, unterminated brackets
194
+ This is $$b[bold text being called
195
+ This is <b>bold text being called</b>
196
+
197
+ Trying $$b function, colon param
198
+ This is $$b:token being called
199
+ This is <b>token</b> being called
200
+
201
+ Try $$i
202
+ There is $$i[some text] here
203
+ There is <i>some text</i> here
204
+
205
+ Try $$t
206
+ There is $$t[some text] here
207
+ There is <font size=+1><tt>some text</tt></font> here
208
+
209
+ Try $$s
210
+ There is $$s[some text] here
211
+ There is <strike>some text</strike> here
212
+
213
+ Try $$bi
214
+ There is $$bi[some text] here
215
+ There is <b><i>some text</i></b> here
216
+
217
+ Try $$bt
218
+ There is $$bt[some text] here
219
+ There is <b><font size=+1><tt>some text</tt></font></b> here
220
+
221
+ Try $$bs
222
+ There is $$bs[some text] here
223
+ There is <b><strike>some text</strike></b> here
224
+
225
+ Try $$it
226
+ There is $$it[some text] here
227
+ There is <i><font size=+1><tt>some text</tt></font></i> here
228
+
229
+ Try $$is
230
+ There is $$is[some text] here
231
+ There is <i><strike>some text</strike></i> here
232
+
233
+ Try $$ts
234
+ There is $$ts[some text] here
235
+ There is <font size=+1><tt><strike>some text</strike></tt></font> here
236
+
237
+ Try $$bit
238
+ There is $$bit[some text] here
239
+ There is <b><i><font size=+1><tt>some text</tt></font></i></b> here
240
+
241
+ Try $$bis
242
+ There is $$bis[some text] here
243
+ There is <b><i><strike>some text</strike></i></b> here
244
+
245
+ Try $$bts
246
+ There is $$bts[some text] here
247
+ There is <b><font size=+1><tt><strike>some text</strike></tt></font></b> here
248
+
249
+ Try $$its
250
+ There is $$its[some text] here
251
+ There is <i><font size=+1><tt><strike>some text</strike></tt></font></i> here
252
+
253
+ Try $$bits
254
+ There is $$bits[some text] here
255
+ There is <b><i><font size=+1><tt><strike>some text</strike></tt></font></i></b> here
256
+
257
+ Escaped brackets inside bracketed function parameter
258
+ Here is an $$t[\[:array, :expression\]] with escapes.
259
+ Here is an <font size=+1><tt>[:array, :expression]</tt></font> with escapes.
260
+
261
+ Escape brackets inside *
262
+ There are brackets *[\[\]] here
263
+ There are brackets <b>[]</b> here
264
+
265
+ Escape brackets inside _
266
+ There are brackets _[\[\]] here
267
+ There are brackets <i>[]</i> here
268
+
269
+ Escape brackets inside `
270
+ There are brackets `[\[\]] here
271
+ There are brackets <font size=+1><tt>[]</tt></font> here
272
+
273
+ Escape brackets inside ~
274
+ There are brackets ~[\[\]] here
275
+ There are brackets <strike>[]</strike> here
276
+
277
+ Check output of $$date
278
+ Today is $$date, I guess
279
+ /Today is \d\d\d\d-\d\d-\d\d, I guess/
280
+
281
+ Check output of $$time
282
+ Tick tock, it's $$time right now
283
+ /Tick tock, it's \d\d:\d\d:\d\d right now/
284
+
@@ -1,4 +1,4 @@
1
- Here are examples of <b>boldface</b>
1
+ Here are examples of <b>boldface</b>
2
2
  and <i>italics</i>
3
3
  and <font size=+1><tt>code</tt></font>
4
4
  as well as <b>more complex</b> examples
@@ -1,4 +1,3 @@
1
-
2
1
  This file has
3
2
  a defined method
4
3
  that is invalid:
@@ -1,4 +1,3 @@
1
-
2
1
  Blah
3
2
  blah
4
3
  <p>
@@ -1,3 +1,6 @@
1
+ Here is an alphabetized list:
2
+ <p>
3
+
1
4
  aardvark
2
5
  anamorphic
3
6
  anarchist
@@ -15,9 +18,6 @@
15
18
  quark
16
19
  zootrope
17
20
  zymurgy
18
- Here is an alphabetized list:
19
- <p>
20
-
21
21
  <p>
22
22
 
23
23
  That's all.
@@ -1,7 +1,7 @@
1
1
  .def alpha
2
2
  text = _body.to_a.join(" ")
3
3
  words = text.split.sort
4
- words.each {|w| _puts " #{w}" }
4
+ words.each {|w| _out " #{w}" }
5
5
  .end
6
6
  Here is an alphabetized list:
7
7