livetext 0.7.8 → 0.7.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a7abb70149d3ce8d437180e80e90ff923284202f
4
- data.tar.gz: e006a124c7ee1524774b996d6632203bc4d1f8be
3
+ metadata.gz: 1a449b36a919484567bb601649627b5b58f9bdf1
4
+ data.tar.gz: e3549c9abb38e73e7d0536380539d20413740130
5
5
  SHA512:
6
- metadata.gz: 162c8d389a83695a457046a6f57b1e4991f643c15c272a65d6689e5ba171933bcf83cb8fae9407b7cca2abeffe71f6f23085e397024ad1e0c0e2f0e64b7c488b
7
- data.tar.gz: 9d1435ef7cb23a5bcd0293de2649d8d2cc3b4e5e9ff21213f7682621284a011b1a5357110b50c7ebfb0d604588fff6c425eb49600ae992b791358c9390703235
6
+ metadata.gz: 4545e6cc0c86b4014b53c44ffd9df28107bdf72c0c69adaf678f49f1897205b2f2ca66e8ce982a7923205385ae20d3da4cde440cd44131c53467522cd18d2993
7
+ data.tar.gz: b41ffe558578f7bc21c2b6d68417f28265f013617d74a03adf21c7cc1d28452feba09ed7a63d871eff0f28af7b560b429b9cbb4ac02d2397cbf0b6aaacfc5388
data/lib/formatline.rb CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  class FormatLine
3
2
  EOL = :eol
4
3
  Alpha = /[a-z]/
@@ -82,6 +81,12 @@ class FormatLine
82
81
  @substr = ""
83
82
  end
84
83
 
84
+ def strike
85
+ d0, d1 = SimpleFormats[:s]
86
+ @buffer << "#{d0}#@substr#{d1}"
87
+ @substr = ""
88
+ end
89
+
85
90
  def parse(line)
86
91
  @enum = line.chomp.each_char
87
92
  @buffer = ""
@@ -94,6 +99,21 @@ class FormatLine
94
99
  char = peek
95
100
  # puts "char = #{char.inspect}"
96
101
  case char
102
+ when "\\"
103
+ char = skip
104
+ case char
105
+ when "$", "*", "_", "`", "~"
106
+ emit(char)
107
+ skip
108
+ when " "
109
+ emit("\\ ")
110
+ skip
111
+ when EOL
112
+ emit("\\")
113
+ break
114
+ when Other
115
+ emit("\\") # logic??
116
+ end
97
117
  when EOL
98
118
  break
99
119
  when "$" # var or func or $
@@ -106,6 +126,9 @@ class FormatLine
106
126
  vsub
107
127
  when "$"
108
128
  case skip
129
+ when EOL
130
+ emit("$$")
131
+ break
109
132
  when Alpha
110
133
  loop { @fname << grab; break unless Alpha2 === peek }
111
134
  case peek
@@ -186,6 +209,25 @@ class FormatLine
186
209
  loop { @substr << grab; break if [" ", EOL].include?(peek) }
187
210
  ttype
188
211
  end
212
+ when "~"
213
+ case skip
214
+ when EOL
215
+ emit "~"
216
+ when " "
217
+ emit "~"
218
+ when "["
219
+ skip
220
+ loop { break if ["]", EOL].include?(peek); @substr << grab }
221
+ skip
222
+ strike
223
+ when "~" # doubled...
224
+ skip
225
+ loop { break if [".", ",", ")", EOL].include?(peek); @substr << grab } # ";" ?? FIXME
226
+ strike
227
+ when Other
228
+ loop { @substr << grab; break if [" ", EOL].include?(peek) }
229
+ strike
230
+ end
189
231
  when Other
190
232
  keep
191
233
  end
data/lib/functions.rb CHANGED
@@ -4,6 +4,6 @@ class Livetext::Functions # Functions will go here... user-def AND pre-def??
4
4
  end
5
5
 
6
6
  def time
7
- Time.now.strftime("%F")
7
+ Time.now.strftime("%T")
8
8
  end
9
9
  end
data/lib/livetext.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class Livetext
2
- VERSION = "0.7.8"
2
+ VERSION = "0.7.9"
3
3
  end
4
4
 
5
5
  require 'fileutils'
@@ -17,11 +17,7 @@ Plugins = File.expand_path(File.join(File.dirname(__FILE__), "../dsl"))
17
17
 
18
18
  TTY = ::File.open("/dev/tty", "w")
19
19
 
20
- # require_relative "#{Plugins}/pyggish"
21
-
22
-
23
20
  class Livetext
24
-
25
21
  Vars = {}
26
22
 
27
23
  class Processor
@@ -52,7 +48,7 @@ class Livetext
52
48
  def _error!(err, abort=true, trace=false)
53
49
  where = @sources.last || @save_location
54
50
  STDERR.puts "Error: #{err} (at #{where[1]} line #{where[2]})"
55
- STDERR.puts err.backtrace if trace && err.respond_to?(:backtrace)
51
+ STDERR.puts err.backtrace if @backtrace && err.respond_to?(:backtrace)
56
52
  exit if abort
57
53
  end
58
54
 
@@ -91,8 +87,6 @@ class Livetext
91
87
 
92
88
  Space = " "
93
89
 
94
- attr_reader :main
95
-
96
90
  def initialize(output = ::STDOUT)
97
91
  @source = nil
98
92
  @_mixins = []
data/lib/standard.rb CHANGED
@@ -20,6 +20,12 @@ module Livetext::Standard
20
20
  SimpleFormats[:s] = [s0, s1]
21
21
  end
22
22
 
23
+ def backtrace
24
+ arg = @_args.first
25
+ @backtrace = true
26
+ @backtrace = false if arg == "off"
27
+ end
28
+
23
29
  def comment
24
30
  _body
25
31
  end
data/lib/userapi.rb CHANGED
@@ -8,7 +8,6 @@ module Livetext::UserAPI
8
8
 
9
9
  def _check_existence(file, msg)
10
10
  _error! msg unless File.exist?(file)
11
- # puts "ERROR" unless File.exist?(file)
12
11
  end
13
12
 
14
13
  def _source
@@ -84,78 +83,6 @@ module Livetext::UserAPI
84
83
  _body(sigil).join("\n")
85
84
  end
86
85
 
87
- def _full_format(line)
88
- Parser.parse(line)
89
- =begin
90
- d0, d1 = Livetext::Standard::SimpleFormats[sym]
91
- s = line.each_char
92
- c = s.next
93
- last = nil
94
- getch = -> { last = c; c = s.next }
95
- buffer = ""
96
- loop do
97
- case c
98
- when " "
99
- buffer << " "
100
- last = " "
101
- when delim
102
- if last == " " || last == nil
103
- buffer << d0
104
- c = getch.call
105
- if c == "("
106
- loop { getch.call; break if c == ")"; buffer << c }
107
- buffer << d1
108
- else
109
- loop { buffer << c; getch.call; break if c == " " || c == nil || c == "\n" }
110
- buffer << d1
111
- buffer << " " if c == " "
112
- end
113
- else
114
- buffer << delim
115
- end
116
- else
117
- buffer << c
118
- end
119
- getch.call
120
- end
121
- buffer
122
- =end
123
- end
124
-
125
- def _basic_format(line, delim, tag)
126
- s = line.each_char
127
- c = s.next
128
- last = nil
129
- getch = -> { last = c; c = s.next }
130
- buffer = ""
131
- loop do
132
- case c
133
- when " "
134
- buffer << " "
135
- last = " "
136
- when delim
137
- if last == " " || last == nil
138
- buffer << "<#{tag}>"
139
- c = getch.call
140
- if c == "("
141
- loop { getch.call; break if c == ")"; buffer << c }
142
- buffer << "</#{tag}>"
143
- else
144
- loop { buffer << c; getch.call; break if c == " " || c == nil || c == "\n" }
145
- buffer << "</#{tag}>"
146
- buffer << " " if c == " "
147
- end
148
- else
149
- buffer << delim
150
- end
151
- else
152
- buffer << c
153
- end
154
- getch.call
155
- end
156
- buffer
157
- end
158
-
159
86
  def _handle_escapes(str, set)
160
87
  str = str.dup
161
88
  set.each_char do |ch|
@@ -165,47 +92,14 @@ module Livetext::UserAPI
165
92
  end
166
93
 
167
94
  def _formatting(line)
168
- # l2 = _basic_format(line, "_", "i")
169
- # l2 = _new_format(line, "_", :i)
170
- # l2 = _basic_format(l2, "*", "b")
171
- # l2 = _new_format(l2, "*", :b)
172
- # l2 = _basic_format(l2, "`", "tt")
173
- # l2 = _new_format(l2, "`", :t)
174
- # Do strikethrough?
175
- l2 = _full_format(line)
176
- l2 = _handle_escapes(l2, "_*`")
95
+ l2 = Parser.parse(line)
177
96
  line.replace(l2)
178
97
  end
179
98
 
180
- def _func_sub
181
- end
182
-
183
- def _substitution(line)
184
- # FIXME handle vars/functions separately later??
185
- # FIXME permit parameters to functions
186
- fobj = ::Livetext::Functions.new
187
- @funcs = ::Livetext::Functions.instance_methods
188
- @funcs.each do |func|
189
- name = ::Regexp.escape("$$#{func}")
190
- rx = /#{name}\b/
191
- line.gsub!(rx) do |str|
192
- val = fobj.send(func)
193
- str.sub(rx, val)
194
- end
195
- end
196
- @vars.each_pair do |var, val|
197
- name = ::Regexp.escape("$#{var}")
198
- rx = /#{name}\b/
199
- line.gsub!(rx, val)
200
- end
201
- line
202
- end
203
-
204
99
  def _passthru(line)
205
100
  return if @_nopass
206
101
  _puts "<p>" if line == "\n" and ! @_nopara
207
102
  _formatting(line)
208
- # _substitution(line)
209
103
  _puts line
210
104
  end
211
105
 
@@ -94,3 +94,91 @@ under: Starts after double quote?
94
94
  He said, "_Please go away."
95
95
  He said, "<i>Please</i> go away."
96
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
+
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.7.8
4
+ version: 0.7.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hal Fulton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-01 00:00:00.000000000 Z
11
+ date: 2017-04-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A smart text processor extensible in Ruby
14
14
  email: rubyhacker@gmail.com