livetext 0.8.94 → 0.8.95

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: 3e03684f43c00dc08a44a65d67d2e768f722bb676ffadd84ad39e464c538f831
4
- data.tar.gz: 7aa534fd733a6ec1d0315a4a534ff2a7027a28dcec2f3ca4da272bdfcca09d9d
3
+ metadata.gz: 8d50c436a237a5e3f02b6619316c5ff37efa5d0c58e4d64eb5445c05f3a54dfa
4
+ data.tar.gz: c849446d4dd970e89c3cace0a8f1af13e3eadc2918df35f6614dc99192cbbd80
5
5
  SHA512:
6
- metadata.gz: 2df6ccff1729ed6ac747a42f210389eb0cee162189bf707e9ebb6eaf7b2c36ee58464ee33e2dc4b5e0e940253707a7a124786d710dfc98441dedcbfeba1ed7e4
7
- data.tar.gz: bbfb6363c513dde5d0c505ffa0c06231c045708cbe6357036a466a5fffff8cd31eb33540282d2263dba2dda8e25b7412fd68346f8f427b7b1fde44dcf49ca46d
6
+ metadata.gz: b778d4a49af38754d8a35df8e8cf42da35933888d26a6e13dd65cf944991f0521fc7138f49d174e7c3e640a93b84c451b3877d5424793e0cf4cd2af580964e66
7
+ data.tar.gz: 620dac5c5eca194d84cf758ceddf738ad5bc41c8574ac110d6599bb5e5542857781e7dd66a4710e3a416490cb7934063b3f826860aa26172bc8f633ad7f562d1
@@ -108,6 +108,7 @@ class FormatLine
108
108
  when :str
109
109
  @out << val unless val == "\n" # BUG
110
110
  when :var
111
+ # STDERR.puts "=== lt: sym = #{sym} val = #{val} sub = #{varsub(val).inspect} #{Livetext::Vars[sym].inspect}"
111
112
  @out << varsub(val)
112
113
  when :func
113
114
  param = nil
@@ -17,6 +17,16 @@ class Livetext::Functions # Functions will go here... user-def AND pre-def??
17
17
  Time.now.strftime("%T")
18
18
  end
19
19
 
20
+ def pwd(param=nil)
21
+ ::Dir.pwd
22
+ end
23
+
24
+ def rand(param=nil)
25
+ # STDERR.puts "param = #{param.inspect}"
26
+ n1, n2 = param.split.map(&:to_i)
27
+ ::Kernel.rand(n1..n2).to_s
28
+ end
29
+
20
30
  def link(param=nil)
21
31
  text, url = param.split("|", 2) # reverse these?
22
32
  "<a href='#{url}'>#{text}</a>"
@@ -1,5 +1,5 @@
1
1
  class Livetext
2
- VERSION = "0.8.94"
2
+ VERSION = "0.8.95"
3
3
  Path = File.expand_path(File.join(File.dirname(__FILE__)))
4
4
  end
5
5
 
@@ -130,8 +130,8 @@ class Livetext
130
130
  rescue => err
131
131
  puts "process_text: err = #{err}"
132
132
  # puts err.backtrace.join("\n")
133
- puts @body
134
- @body = ""
133
+ puts @body
134
+ @body = ""
135
135
  return @body
136
136
  end
137
137
 
@@ -149,10 +149,10 @@ puts @body
149
149
  process_line(line)
150
150
  end
151
151
  val = @main.finalize if @main.respond_to? :finalize
152
- return @body
153
- val
154
- rescue
155
- puts @body
152
+ @body
153
+ rescue => err
154
+ STDERR.puts "ERROR #{err} in process_file"
155
+ err.backtrace.each {|x| STDERR.puts " " + x }
156
156
  @body = ""
157
157
  end
158
158
 
@@ -200,17 +200,14 @@ return @body
200
200
  if @main.respond_to?(name)
201
201
  result = @main.send(name)
202
202
  else
203
- TTY.puts "version = #{Livetext::VERSION}"
204
- TTY.puts "#{(@main.methods - Object.methods).sort.inspect}"
205
- TTY.puts name.inspect
206
- @main._error! "Name '#{name}' is unknown"
203
+ @main._error! "Name '#{name}' is unknown; version = #{Livetext::VERSION}"
207
204
  return
208
205
  end
209
206
  result
210
207
  rescue => err
211
208
  @main._error!(err)
212
- puts @body
213
- @body = ""
209
+ puts @body
210
+ @body = ""
214
211
  return @body
215
212
  end
216
213
 
@@ -34,7 +34,7 @@ module Livetext::Standard
34
34
 
35
35
  def shell
36
36
  cmd = @_data
37
- _errout("Running: #{cmd}")
37
+ # _errout("Running: #{cmd}")
38
38
  system(cmd)
39
39
  end
40
40
 
@@ -79,52 +79,6 @@ EOS
79
79
  # exit!
80
80
  end
81
81
 
82
- # def outdir
83
- # @_outdir = @_args.first
84
- # _optional_blank_line
85
- # end
86
- #
87
- # def outdir! # FIXME ?
88
- # @_outdir = @_args.first
89
- # raise "No output directory specified" if @_outdir.nil?
90
- # raise "No output directory specified" if @_outdir.empty?
91
- # system("rm -f #@_outdir/*.html")
92
- # _optional_blank_line
93
- # end
94
- #
95
- # def _output(name)
96
- # @_outdir ||= "." # FIXME
97
- # @output.puts @body
98
- # @body = ""
99
- # @output.close unless @output == STDOUT
100
- # @output = File.open(@_outdir + "/" + name, "w")
101
- # @output.puts "<meta charset='UTF-8'>\n\n"
102
- # end
103
- #
104
- # def _append(name)
105
- # @_outdir ||= "." # FIXME
106
- # @output.close unless @output == STDOUT
107
- # @output = File.open(@_outdir + "/" + name, "a")
108
- # @output.puts "<meta charset='UTF-8'>\n\n"
109
- # end
110
- #
111
- # def output
112
- # name = @_args.first
113
- # _debug "Redirecting output to: #{name}"
114
- # _output(name)
115
- # end
116
- #
117
- # def append
118
- # file = @_args[0]
119
- # _append(file)
120
- # end
121
- #
122
- # def next_output
123
- # tag, num = @_args
124
- # _next_output(tag, num)
125
- # _optional_blank_line
126
- # end
127
- #
128
82
 
129
83
  def cleanup
130
84
  @_args.each do |item|
@@ -136,13 +90,6 @@ EOS
136
90
  end
137
91
  end
138
92
 
139
- # def _next_output(tag = "sec", num = nil)
140
- # @_file_num = num ? num : @_file_num + 1
141
- # @_file_num = @_file_num.to_i
142
- # name = "#{'%03d' % @_file_num}-#{tag}.html"
143
- # _output(name)
144
- # end
145
-
146
93
  def _def
147
94
  name = @_args[0]
148
95
  str = "def #{name}\n"
@@ -259,12 +206,17 @@ EOS
259
206
  end
260
207
  end
261
208
 
209
+ def reval
210
+ eval _data
211
+ end
212
+
262
213
  def heredoc
263
214
  var = @_args[0]
264
215
  str = _body_text
265
216
  s2 = ""
266
217
  str.each_line do |s|
267
- s2 << s.chomp + "<br>"
218
+ str = FormatLine.var_func_parse(s.chomp)
219
+ s2 << str # + "<br>"
268
220
  end
269
221
  indent = @parent.indentation.last
270
222
  indented = " " * indent
@@ -278,6 +230,7 @@ EOS
278
230
  # end
279
231
  # s2 << line
280
232
  # end
233
+ # STDERR.puts "HERE: #{var} = #{s2.chomp.inspect}"
281
234
  @parent._setvar(var, s2.chomp)
282
235
  _optional_blank_line
283
236
  end
@@ -292,7 +245,7 @@ EOS
292
245
  loop do
293
246
  front = "../" * count
294
247
  count += 1
295
- here = Pathname.new(front).expand_path.dirname
248
+ here = Pathname.new(front).expand_path.dirname.to_s
296
249
  break if here == "/"
297
250
  path = front + file
298
251
  value = path if File.exist?(path)
@@ -366,7 +319,7 @@ EOS
366
319
  if File.exist?(file)
367
320
  # Just keep going...
368
321
  else
369
- if File.expand_path(".") != "/"
322
+ if File.expand_path(".").dirname != "/"
370
323
  Dir.chdir("..") { mixin }
371
324
  return
372
325
  else
@@ -88,8 +88,11 @@ module Livetext::UserAPI
88
88
  break
89
89
  end
90
90
  next if _comment?(@line)
91
+ flag = (@line.include?("og:title"))
91
92
  # FIXME Will cause problem with $. ?
93
+ # STDERR.puts "lt3: _body @line = #{@line.inspect}" if flag
92
94
  @line = _format(@line) unless raw
95
+ # STDERR.puts " @line = #{@line.inspect}" if flag
93
96
  lines << @line
94
97
  end
95
98
  raise unless end_found
@@ -100,9 +103,10 @@ module Livetext::UserAPI
100
103
  lines
101
104
  end
102
105
  rescue => err
103
- # p err.inspect
104
- # puts err.backtrace
105
- _error!("Expecting .end, found end of file")
106
+ str = "Fake error? 'Expecting .end, found end of file'\n"
107
+ str << err.inspect + "\n"
108
+ str << err.backtrace.map {|x| " " + x }.join("\n")
109
+ _error!(str)
106
110
  end
107
111
 
108
112
  def _body_text(raw=false)
@@ -6,12 +6,12 @@ SimpleFormats[:i] = %w[_ _]
6
6
  SimpleFormats[:t] = %w[` `]
7
7
  SimpleFormats[:s] = %w[<strike> </strike>]
8
8
 
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
9
+ def h1; _out "# #{FormatLine.var_func_parse(@_data)}"; _optional_blank_line end # atx style for now
10
+ def h2; _out "## #{FormatLine.var_func_parse(@_data)}"; _optional_blank_line end
11
+ def h3; _out "### #{FormatLine.var_func_parse(@_data)}"; _optional_blank_line end
12
+ def h4; _out "#### #{FormatLine.var_func_parse(@_data)}"; _optional_blank_line end
13
+ def h5; _out "##### #{FormatLine.var_func_parse(@_data)}"; _optional_blank_line end
14
+ def h6; _out "###### #{FormatLine.var_func_parse(@_data)}"; _optional_blank_line end
15
15
 
16
16
  def title
17
17
  h1
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.94
4
+ version: 0.8.95
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-10-07 00:00:00.000000000 Z
11
+ date: 2019-11-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A smart text processor extensible in Ruby
14
14
  email: rubyhacker@gmail.com