livetext 0.8.76 → 0.8.77

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc5fb0814d68c5672211c15ec2e37cfdf1eb0e82509249fa627f4fcc809653a6
4
- data.tar.gz: dd997198c3af0c32b1125fb403ee67d225083c302c3d0bca32c74c89554cf511
3
+ metadata.gz: 904d935b6923cb3dd8a70dc6042b03a95dcd18851d7e3dfb4d9cae61cc0653b9
4
+ data.tar.gz: afdfa6c79db3beeb644bd12de6ab2ee061c48b786f87fdc4b6fb10dbeb706f45
5
5
  SHA512:
6
- metadata.gz: 4d52c231252860de533870f9a31ef9b0c68cfa6579f64d19ed1177e63e9a008e5f35a8aea893ed34a546a419e8f92f644bdf7aa85638786cd55e65007e6202af
7
- data.tar.gz: 7822f9b1f34fdfc7791831c425bf079e25f12e35972855c77b267306957cef48c3394bd04a59385c79d8edb517e3d98be47957ab6eba5d42fb5c4442688089f9
6
+ metadata.gz: 7f18d43dd7672ad30d7c4029e39ddda2eb27316d31f0312cc68f2e751ad34f818949150cb6306dd513194e73d2d54e88b457ce34b37003162f12df3aae476264
7
+ data.tar.gz: c533499a1aeb11bcdaf5937dd9ce25fed799c0e8c02034cff9c6fe845ae57159b8d2a8f5211eeece89eb09e34d1777b69bb36a65d54b40b142dfb877f22b53a0
@@ -82,3 +82,5 @@ loop do
82
82
  x.process_file(arg, @backtrace)
83
83
  end
84
84
  end
85
+
86
+ puts x.body
@@ -1,5 +1,5 @@
1
1
  class Livetext
2
- VERSION = "0.8.76"
2
+ VERSION = "0.8.77"
3
3
  Path = File.expand_path(File.join(File.dirname(__FILE__)))
4
4
  end
5
5
 
@@ -99,6 +99,7 @@ class Livetext
99
99
  val = @main.finalize if @main.respond_to? :finalize
100
100
  val
101
101
  rescue => err
102
+ puts @body
102
103
  puts "process_text: err = #{err}"
103
104
  puts err.backtrace.join("\n")
104
105
  end
@@ -169,6 +170,7 @@ class Livetext
169
170
  end
170
171
  result
171
172
  rescue => err
173
+ puts @body
172
174
  @main._error!(err)
173
175
  end
174
176
 
@@ -32,6 +32,7 @@ class Livetext
32
32
 
33
33
  def _error!(err, abort=true, trace=false)
34
34
  where = @sources.last || @save_location
35
+ puts @parent.body
35
36
  STDERR.puts "Error: #{err} (at #{where[1]} line #{where[2]})"
36
37
  STDERR.puts err.backtrace if trace && err.respond_to?(:backtrace)
37
38
  exit if abort
@@ -146,6 +146,7 @@ module Livetext::Standard
146
146
  str += "end\n"
147
147
  eval str
148
148
  rescue => err
149
+ puts @body
149
150
  _error!(err)
150
151
  end
151
152
 
@@ -77,7 +77,8 @@ module Livetext::UserAPI
77
77
  lines
78
78
  end
79
79
  rescue => err
80
- # FIXME
80
+ puts @body
81
+ # FIXME ?
81
82
  _error!("Expecting .end, found end of file")
82
83
  end
83
84
 
@@ -110,12 +111,17 @@ module Livetext::UserAPI
110
111
  _out line
111
112
  end
112
113
 
113
- def _out(str)
114
- if @no_puts
115
- @parent.body << str
116
- else
117
- _puts str
118
- end
114
+ def _out(str = "")
115
+ # if @no_puts
116
+ @parent.body << str
117
+ @parent.body << "\n" unless str.end_with?("\n")
118
+ # else
119
+ # _puts str
120
+ # end
121
+ end
122
+
123
+ def _out!(str = "")
124
+ @parent.body << str # no newline
119
125
  end
120
126
 
121
127
  def _puts(*args)
@@ -11,28 +11,28 @@ def credit
11
11
  # really just a place marker in source
12
12
  end
13
13
 
14
- def h1; _puts "<h1>#{@_data}</h1>"; end
15
- def h3; _puts "<h3>#{@_data}</h3>"; end
14
+ def h1; _out "<h1>#{@_data}</h1>"; end
15
+ def h3; _out "<h3>#{@_data}</h3>"; end
16
16
 
17
17
  def list
18
- _puts "<ul>"
19
- _body {|line| _puts "<li>#{line}</li>" }
20
- _puts "</ul>"
18
+ _out "<ul>"
19
+ _body {|line| _out "<li>#{line}</li>" }
20
+ _out "</ul>"
21
21
  end
22
22
 
23
23
  def list!
24
- _puts "<ul>"
25
- lines = _body.each # {|line| _puts "<li>#{line}</li>" }
24
+ _out "<ul>"
25
+ lines = _body.each # {|line| _out "<li>#{line}</li>" }
26
26
  loop do
27
27
  line = lines.next
28
28
  line = _formatting(line)
29
29
  if line[0] == " "
30
- _puts line
30
+ _out line
31
31
  else
32
- _puts "<li>#{line}</li>"
32
+ _out "<li>#{line}</li>"
33
33
  end
34
34
  end
35
- _puts "</ul>"
35
+ _out "</ul>"
36
36
  end
37
37
 
38
38
  def alpha_columns
@@ -42,12 +42,12 @@ def alpha_columns
42
42
  words << line.chomp
43
43
  end
44
44
  words.sort!
45
- _puts "<table cellpadding=10>"
45
+ _out "<table cellpadding=10>"
46
46
  words.each_slice(n) do |w|
47
47
  items = w.map {|x| "<tt>#{x}</tt>" }
48
- _puts "<tr><td width=5% valign=top></td><td>" + items.join("</td><td>") + "</td></tr>"
48
+ _out "<tr><td width=5% valign=top></td><td>" + items.join("</td><td>") + "</td></tr>"
49
49
  end
50
- _puts "</table>"
50
+ _out "</table>"
51
51
  end
52
52
 
53
53
  def comment
@@ -70,7 +70,7 @@ end
70
70
 
71
71
  def image
72
72
  name = @_args[0]
73
- _puts "<img src='#{name}'></img>"
73
+ _out "<img src='#{name}'></img>"
74
74
  end
75
75
 
76
76
  def figure
@@ -78,8 +78,8 @@ def figure
78
78
  num = @_args[1]
79
79
  title = @_args[2..-1].join(" ")
80
80
  title = _formatting(title)
81
- _puts "<img src='#{name}'></img>"
82
- _puts "<center><b>Figure #{num}</b> #{title}</center>"
81
+ _out "<img src='#{name}'></img>"
82
+ _out "<center><b>Figure #{num}</b> #{title}</center>"
83
83
  end
84
84
 
85
85
  def chapter
@@ -89,8 +89,8 @@ def chapter
89
89
  title = @_data.split(" ",2)[1]
90
90
  @toc << "<br><b>#@chapter</b> #{title}<br>"
91
91
  _next_output(_slug(title))
92
- _puts "<title>#{@chapter}. #{title}</title>"
93
- _puts <<-HTML
92
+ _out "<title>#{@chapter}. #{title}</title>"
93
+ _out <<-HTML
94
94
  <h2>Chapter #{@chapter}</h1>
95
95
  <h1>#{title}</h1>
96
96
 
@@ -104,8 +104,8 @@ def chapterN
104
104
  _errout("Chapter #@chapter: #{title}")
105
105
  @toc << "<br><b>#@chapter</b> #{title}<br>"
106
106
  _next_output(_slug(title))
107
- _puts "<title>#{@chapter}. #{title}</title>"
108
- _puts <<-HTML
107
+ _out "<title>#{@chapter}. #{title}</title>"
108
+ _out <<-HTML
109
109
  <h2>Chapter #{@chapter}</h1>
110
110
  <h1>#{title}</h1>
111
111
 
@@ -119,7 +119,7 @@ def sec
119
119
  # _errout("section #@section")
120
120
  @toc << "#{_nbsp(3)}<b>#@section</b> #@_data<br>"
121
121
  # _next_output(_slug(@_data))
122
- _puts "<h3>#@section #{@_data}</h3>\n"
122
+ _out "<h3>#@section #{@_data}</h3>\n"
123
123
  end
124
124
 
125
125
  def subsec
@@ -128,7 +128,7 @@ def subsec
128
128
  @toc << "#{_nbsp(6)}<b>#@subsec</b> #@_data<br>"
129
129
  # _errout("section #@subsec")
130
130
  # _next_output(_slug(@_data))
131
- _puts "<h3>#@subsec #{@_data}</h3>\n"
131
+ _out "<h3>#@subsec #{@_data}</h3>\n"
132
132
  end
133
133
 
134
134
  def table2
@@ -136,21 +136,21 @@ def table2
136
136
  wide = "90"
137
137
  extra = _args[2]
138
138
  delim = " :: "
139
- _puts "<br><center><table border=1 width=#{wide}% cellpadding=5>"
139
+ _out "<br><center><table border=1 width=#{wide}% cellpadding=5>"
140
140
  lines = _body(true)
141
141
  lines.map! {|line| _formatting(line) }
142
142
 
143
143
  lines.each do |line|
144
144
  cells = line.split(delim)
145
145
  percent = (100/cells.size.to_f).round
146
- _puts "<tr>"
146
+ _out "<tr>"
147
147
  cells.each do |cell|
148
- _puts " <td width=#{percent}% valign=top " +
148
+ _out " <td width=#{percent}% valign=top " +
149
149
  "#{extra}>#{cell}</td>"
150
150
  end
151
- _puts "</tr>"
151
+ _out "</tr>"
152
152
  end
153
- _puts "</table></center><br><br>"
153
+ _out "</table></center><br><br>"
154
154
 
155
155
  _optional_blank_line
156
156
  end
@@ -158,7 +158,7 @@ end
158
158
  def simple_table
159
159
  title = @_data
160
160
  delim = " :: "
161
- _puts "<table cellpadding=2>"
161
+ _out "<table cellpadding=2>"
162
162
  lines = _body(true)
163
163
  maxw = nil
164
164
  lines.each do |line|
@@ -174,14 +174,14 @@ def simple_table
174
174
 
175
175
  lines.each do |line|
176
176
  cells = line.split(delim)
177
- _puts "<tr>"
177
+ _out "<tr>"
178
178
  cells.each.with_index do |cell, i|
179
- _puts " <td width=#{maxw}% valign=top>" +
179
+ _out " <td width=#{maxw}% valign=top>" +
180
180
  "#{cell}</td>"
181
181
  end
182
- _puts "</tr>"
182
+ _out "</tr>"
183
183
  end
184
- _puts "</table>"
184
+ _out "</table>"
185
185
  end
186
186
 
187
187
  def table
@@ -189,7 +189,7 @@ def table
189
189
  @table_num += 1
190
190
  title = @_data
191
191
  delim = " :: "
192
- _puts "<br><center><table border=1 width=90% cellpadding=5>"
192
+ _out "<br><center><table border=1 width=90% cellpadding=5>"
193
193
  lines = _body(true)
194
194
  maxw = nil
195
195
  lines.each do |line|
@@ -205,23 +205,24 @@ def table
205
205
 
206
206
  lines.each do |line|
207
207
  cells = line.split(delim)
208
- _puts "<tr>"
208
+ _out "<tr>"
209
209
  cells.each.with_index do |cell, i|
210
- _puts " <td width=#{maxw}% valign=top>" +
210
+ _out " <td width=#{maxw}% valign=top>" +
211
211
  "#{cell}</td>"
212
212
  end
213
- _puts "</tr>"
213
+ _out "</tr>"
214
214
  end
215
- _puts "</table>"
215
+ _out "</table>"
216
216
  @toc << "#{_nbsp(8)}<b>Table #@chapter.#@table_num</b> #{title}<br>"
217
217
  # _next_output(_slug("table_#{title}"))
218
- _puts "<b>Table #@chapter.#@table_num &nbsp;&nbsp; #{title}</b></center><br>"
218
+ _out "<b>Table #@chapter.#@table_num &nbsp;&nbsp; #{title}</b></center><br>"
219
219
  end
220
220
 
221
221
  def toc!
222
222
  _debug "Closing TOC"
223
223
  @toc.close
224
224
  rescue => err
225
+ puts @body
225
226
  _errout "Exception: #{err.inspect}"
226
227
  end
227
228
 
@@ -242,7 +243,7 @@ def missing
242
243
  @toc << "#{_nbsp(8)}<font color=red>TBD: #@_data</font><br>"
243
244
  _print "<br><font color=red><i>[Material missing"
244
245
  _print ": #@_data" unless @_data.empty?
245
- _puts "]</i></font><br>\n "
246
+ _out "]</i></font><br>\n "
246
247
  end
247
248
 
248
249
  def TBC
@@ -251,15 +252,15 @@ def TBC
251
252
  end
252
253
 
253
254
  def note
254
- _puts "<br><font color=red><i>Note: "
255
- _puts @_data
256
- _puts "</i></font><br>\n "
255
+ _out "<br><font color=red><i>Note: "
256
+ _out @_data
257
+ _out "</i></font><br>\n "
257
258
  end
258
259
 
259
260
  def quote
260
- _puts "<blockquote>"
261
- _puts _body
262
- _puts "</blockquote>"
261
+ _out "<blockquote>"
262
+ _out _body
263
+ _out "</blockquote>"
263
264
  end
264
265
 
265
266
  def init_bookish
@@ -6,12 +6,12 @@ SimpleFormats[:i] = %w[_ _]
6
6
  SimpleFormats[:t] = %w[` `]
7
7
  SimpleFormats[:s] = %w[<strike> </strike>]
8
8
 
9
- def h1; _puts "# #{@_data}"; _optional_blank_line end # atx style for now
10
- def h2; _puts "## #{@_data}"; _optional_blank_line end
11
- def h3; _puts "### #{@_data}"; _optional_blank_line end
12
- def h4; _puts "#### #{@_data}"; _optional_blank_line end
13
- def h5; _puts "##### #{@_data}"; _optional_blank_line end
14
- def h6; _puts "###### #{@_data}"; _optional_blank_line end
9
+ def h1; _out "# #{@_data}"; _optional_blank_line end # atx style for now
10
+ def h2; _out "## #{@_data}"; _optional_blank_line end
11
+ def h3; _out "### #{@_data}"; _optional_blank_line end
12
+ def h4; _out "#### #{@_data}"; _optional_blank_line end
13
+ def h5; _out "##### #{@_data}"; _optional_blank_line end
14
+ def h6; _out "###### #{@_data}"; _optional_blank_line end
15
15
 
16
16
  def title
17
17
  h1
@@ -22,18 +22,18 @@ def section
22
22
  end
23
23
 
24
24
  def bq # block quote
25
- _body {|line| _puts "> #{line}" }
25
+ _body {|line| _out "> #{line}" }
26
26
  end
27
27
 
28
28
  def list
29
- _body {|line| _puts " * #{line}" }
29
+ _body {|line| _out " * #{line}" }
30
30
  end
31
31
 
32
32
  def olist # Doesn't handle paragraphs yet
33
33
  n = 0
34
34
  _body do |line|
35
35
  n += 1
36
- _puts "#{n}. #{_formatting(line)}"
36
+ _out "#{n}. #{_formatting(line)}"
37
37
  end
38
38
  end
39
39
 
@@ -185,9 +185,9 @@ def code # FIXME ?
185
185
  end
186
186
 
187
187
  def mono
188
- _puts "<pre>"
189
- _body(true) {|line| _puts " " + line }
190
- _puts "</pre>"
188
+ _out "<pre>"
189
+ _body(true) {|line| _out " " + line }
190
+ _out "</pre>"
191
191
  end
192
192
 
193
193
 
@@ -9,7 +9,7 @@ def section
9
9
  end
10
10
 
11
11
  def code
12
- # _puts "<pre>"
12
+ # _out "<pre>"
13
13
  first = true # dumb hack! fixes blank space
14
14
  _body do |line|
15
15
  if first
@@ -17,9 +17,9 @@ def code
17
17
  first = false
18
18
  else
19
19
  end
20
- _puts "#{tag} #{::CGI.escape_html(line)}" # indentation
20
+ _out "#{tag} #{::CGI.escape_html(line)}" # indentation
21
21
  end
22
- _puts "</pre>"
22
+ _out "</pre>"
23
23
  end
24
24
 
25
25
  def rx(str)
@@ -80,9 +80,9 @@ end
80
80
 
81
81
  def testcase
82
82
  name = _args.first
83
- _puts "\n<font size=+1><b>Test: </font><font size=+2><tt>#{name}</tt></font></b></h3><br>"
83
+ _out "\n<font size=+1><b>Test: </font><font size=+2><tt>#{name}</tt></font></b></h3><br>"
84
84
  src, exp = "test/data/#{name}/source.lt3", "test/data/#{name}/expected-output.txt"
85
85
  @_args = [src, exp] # Better way to do this??
86
86
  put_table(src, exp)
87
- _puts "<br>"
87
+ _out "<br>"
88
88
  end
@@ -1,3 +1,4 @@
1
+
1
2
  This file has
2
3
  a defined method
3
4
  that is invalid:
@@ -1,3 +1,4 @@
1
+
1
2
  Blah
2
3
  blah
3
4
  <p>
@@ -1,6 +1,3 @@
1
- Here is an alphabetized list:
2
- <p>
3
-
4
1
  aardvark
5
2
  anamorphic
6
3
  anarchist
@@ -18,6 +15,9 @@ Here is an alphabetized list:
18
15
  quark
19
16
  zootrope
20
17
  zymurgy
18
+ Here is an alphabetized list:
19
+ <p>
20
+
21
21
  <p>
22
22
 
23
23
  That's all.
@@ -1,12 +1,12 @@
1
- Here is an alphabetized list:
2
- <p>
3
-
4
1
  aardvark anamorphic anarchist
5
2
  bellicose cytology ectomorph
6
3
  fishmonger fusillade glyph
7
4
  gryphon halcyon manicotti
8
5
  mataeotechny pareidolia quark
9
6
  zootrope zymurgy
7
+ Here is an alphabetized list:
8
+ <p>
9
+
10
10
  <p>
11
11
 
12
12
  And that is all.
@@ -1,3 +1,4 @@
1
+ .backtrace
1
2
  This text block will be passed thru
2
3
  with no interpretation or processing:
3
4
  .raw
@@ -1,5 +1,2 @@
1
1
  Here I am
2
2
  testing a simple mixin
3
- Now call it:
4
- Hello, world.
5
- That's all.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: livetext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.76
4
+ version: 0.8.77
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hal Fulton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-19 00:00:00.000000000 Z
11
+ date: 2019-04-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A smart text processor extensible in Ruby
14
14
  email: rubyhacker@gmail.com