livetext 0.9.37 → 0.9.38

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: 784ac1767694b1d098d3e289082070ef3e3df0aab15766cf42105e854da31730
4
- data.tar.gz: b6f62f1164873ec613b16067c53abc0e1b8906cacaeaae033bd5e862ca6b4bd5
3
+ metadata.gz: dd459c3fa75665b383b8056baa8af5ee9bae77a3abcaeba153b11c422b2f0418
4
+ data.tar.gz: 6f3674f4f5f5408e1b7fbffe45631ebbc0c43abbc624f1ba6ade1232e33d10f3
5
5
  SHA512:
6
- metadata.gz: 795730de451f27c2ffccf326fcc976e170ae884fef45d3bc732bb59826cc40bbff0e877d3ee3ed051fa3f20e0836ccede6668c42ba7a21ec1bf51910ebfc7a99
7
- data.tar.gz: 1db7dfbb839a6787872df65d591b49fb36db69f9d3ddc86805d981f19266c98abcac4a8bbe8efebdf1137ec674201a3b3f4e0f09d849116acb56f390eefd8cbd
6
+ metadata.gz: 49baee92ae2d7a5ef1337ef98258e416014c954a07d5574f697def625c41e06f7cdaa297ca6cc9a88f3cb3dc4f7c58b589aab889f9bb30d67ba4bf583a52c4f7
7
+ data.tar.gz: 6bff41c9c3128a5de6a58f1e81985e35ec3563acbdc133f24427e21c86aca2b475ac0dc1da7967b6e10f92203beab44750ae2ae47bb36a164dfddc62b506c5b9
@@ -94,7 +94,7 @@ module Livetext::Standard
94
94
  loop do
95
95
  line = lines.next
96
96
  line = api.format(line)
97
- str = line[0] == " " ? line : wrapped(line, :li)
97
+ str = line[0] == " " ? line : html.tag(:li, line)
98
98
  api.out str
99
99
  end
100
100
  end
@@ -120,7 +120,7 @@ module Livetext::Standard
120
120
  def say(args = nil, body = nil)
121
121
  data = args || api.args.join(" ")
122
122
  str = api.format(data)
123
- TTY.puts "(say) #{str}"
123
+ TTY.puts str
124
124
  api.optional_blank_line
125
125
  end
126
126
 
@@ -128,7 +128,8 @@ module Livetext::Standard
128
128
  str = api.format(api.data)
129
129
  num = str.length
130
130
  decor = "-"*num + "\n"
131
- puts decor + str + "\n" + decor
131
+ api.tty decor + str + "\n" + decor
132
+ api.optional_blank_line
132
133
  end
133
134
 
134
135
  def quit(args = nil, body = nil)
@@ -334,8 +335,8 @@ module Livetext::Standard
334
335
  api.body do |line|
335
336
  line = api.format(line)
336
337
  term, defn = line.split(delim)
337
- api.out wrapped(term, :dt)
338
- api.out wrapped(defn, :dd)
338
+ api.out html.tag(:dt, term)
339
+ api.out html.tag(:dd, defn)
339
340
  end
340
341
  end
341
342
  api.optional_blank_line
@@ -2,5 +2,5 @@
2
2
  # Defining VERSION
3
3
 
4
4
  class Livetext
5
- VERSION = "0.9.37"
5
+ VERSION = "0.9.38"
6
6
  end
@@ -1,3 +1,32 @@
1
+ require 'fileutils'
2
+
3
+ def epub(args = nil, body = nil)
4
+ api.tty "======== Entering epub"
5
+ out = api.format(api.args[0])
6
+ src = api.args[1]
7
+ api.tty "======== epub: src = #{src}"
8
+ @cover = api.args[2]
9
+ if ::File.directory?(src)
10
+ files = ::Dir["#{src}/*"].grep /\.html$/
11
+ files = files.sort # why is this necessary now?
12
+ cmd = "cat #{files.join(' ')} >TEMP.html"
13
+ system(cmd)
14
+ else
15
+ raise "Not supported yet"
16
+ end
17
+
18
+ cmd = "ebook-convert "
19
+ cmd << "TEMP.html #{out}.epub "
20
+ cmd << "--cover #@cover " if @cover
21
+ system(cmd)
22
+
23
+ system("links -dump TEMP.html >/tmp/links.out")
24
+ str = `wc -w /tmp/links.out`
25
+ nw = str.split[0]
26
+ puts "Approx words: #{nw}"
27
+ # ::FileUtils.rm("TEMP.html")
28
+ end
29
+
1
30
  def hardbreaks(args = nil, body = nil)
2
31
  @hard = false
3
32
  @hard = true unless api.args.first == "off"
@@ -296,7 +325,7 @@ rescue => err
296
325
  exit
297
326
  end
298
327
 
299
- def init_bookish
328
+ def init_booktool
300
329
  @_file_num = 0
301
330
  @toc_file = "toc.tmp"
302
331
  @toc = ::File.new(@toc_file, "w")
@@ -347,10 +376,8 @@ def _prep_next_output(args)
347
376
  *title = args # _next_output(tag, num)
348
377
  title = title.join(" ")
349
378
  slug = _slug(title)
350
- api.tty "title = #{title.inspect}"
351
379
  @_file_num += 1
352
380
  fname = "#{'%03d' % @_file_num}-#{slug}.html"
353
- api.tty "slug, fnum, fname= #{[slug, @_file_num, fname].inspect}"
354
381
  fname
355
382
  end
356
383
 
@@ -86,7 +86,7 @@ def self.pyg_finalize(code, lexer=:elixir)
86
86
  lang = api.args.empty? ? :elixir : api.args.first.to_sym # ruby or elixir
87
87
  api.args = []
88
88
  lines = api.body(true) # .to_a # raw
89
- result = send(lang, lines)
89
+ result = send("format_#{lang}", lines)
90
90
  api.out result
91
91
  api.out "\n"
92
92
  api.optional_blank_line
@@ -94,14 +94,6 @@ def self.pyg_finalize(code, lexer=:elixir)
94
94
  STDERR.puts "fragment Error: #{__method__} err = #{err}\n#{err.backtrace.join("\n")}"
95
95
  end
96
96
 
97
- def dammit(args = nil, body = nil)
98
- lines = api.body(true)
99
- api.out "BODY:"
100
- lines.each {|x| api.out x }
101
- api.out "END BODY"
102
- api.optional_blank_line
103
- end
104
-
105
97
  def code # FIXME ?
106
98
  text = ""
107
99
  api.body {|line| api.out " " + line }
@@ -138,26 +130,7 @@ end
138
130
  File.write("#{dir}/elixir.css", css)
139
131
  end
140
132
 
141
-
142
- def format_ruby(source, theme = "Github", back = "black")
143
- # theme/back not used now
144
- formatter = Rouge::Formatters::HTML.new
145
- lexer = Rouge::Lexers::Ruby.new
146
- body = formatter.format(lexer.lex(source))
147
- text = "<div class=rb_highlight>#{body}</div>"
148
- text
149
- end
150
-
151
- def format_elixir(source, theme = "Github", back = "black")
152
- # theme/back not used now
153
- formatter = Rouge::Formatters::HTML.new
154
- lexer = Rouge::Lexers::Elixir.new
155
- body = formatter.format(lexer.lex(source))
156
- text = "<div class=ex_highlight>#{body}</div>"
157
- text
158
- end
159
-
160
- def xruby
133
+ def ruby(args = nil, body = nil)
161
134
  file = api.args.first
162
135
  code = nil
163
136
  if file.nil?
@@ -171,7 +144,7 @@ end
171
144
  api.out html
172
145
  end
173
146
 
174
- def xelixir
147
+ def elixir(args = nil, body = nil)
175
148
  file = api.args.first
176
149
  code = nil
177
150
  if file.nil?
@@ -184,7 +157,29 @@ end
184
157
  api.out html
185
158
  end
186
159
 
187
- def ruby(lines)
160
+ def format_ruby(lines, theme = "Github", back = "black")
161
+ # theme/back not used now
162
+ source = lines
163
+ source = source.join("\n") if source.is_a?(Array)
164
+ formatter = Rouge::Formatters::HTML.new
165
+ lexer = Rouge::Lexers::Ruby.new
166
+ body = formatter.format(lexer.lex(source))
167
+ text = "<div class=rb_highlight>#{body}</div>"
168
+ text
169
+ end
170
+
171
+ def format_elixir(lines, theme = "Github", back = "black")
172
+ # theme/back not used now
173
+ source = lines
174
+ source = source.join("\n") if source.is_a?(Array)
175
+ formatter = Rouge::Formatters::HTML.new
176
+ lexer = Rouge::Lexers::Elixir.new
177
+ body = formatter.format(lexer.lex(source))
178
+ text = "<div class=ex_highlight>#{body}</div>"
179
+ text
180
+ end
181
+
182
+ def __ruby(lines)
188
183
  theme = :Github # default
189
184
  source = lines.join("\n")
190
185
  formatter = Rouge::Formatters::HTML.new
@@ -214,7 +209,7 @@ rescue => err
214
209
  end
215
210
 
216
211
 
217
- def elixir(lines)
212
+ def __elixir(lines)
218
213
  theme = :Github # default
219
214
  source = lines.join("\n")
220
215
  formatter = Rouge::Formatters::HTML.new
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.9.37
4
+ version: 0.9.38
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hal Fulton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-09 00:00:00.000000000 Z
11
+ date: 2023-03-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
@@ -52,13 +52,12 @@ files:
52
52
  - lib/livetext/userapi.rb
53
53
  - lib/livetext/version.rb
54
54
  - livetext.gemspec
55
- - plugin/bookish.rb
55
+ - plugin/booktool.rb
56
56
  - plugin/bootstrap_menu.rb
57
- - plugin/calibre.rb
57
+ - plugin/codetool.rb
58
58
  - plugin/livemagick.rb
59
59
  - plugin/markdown.rb
60
60
  - plugin/misc/navbar.rb
61
- - plugin/pyggish.rb
62
61
  - plugin/tutorial.rb
63
62
  - test/all.rb
64
63
  - test/extra/README.txt
data/plugin/calibre.rb DELETED
@@ -1,26 +0,0 @@
1
- require 'fileutils'
2
-
3
- def epub!(args = nil, body = nil)
4
- out = api.format(api.args[0])
5
- src = api.args[1]
6
- @cover = api.args[2]
7
- if ::File.directory?(src)
8
- files = ::Dir["#{src}/*"].grep /\.html$/
9
- files = files.sort # why is this necessary now?
10
- cmd = "cat #{files.join(' ')} >TEMP.html"
11
- system(cmd)
12
- else
13
- raise "Not supported yet"
14
- end
15
-
16
- cmd = "ebook-convert "
17
- cmd << "TEMP.html #{out}.epub "
18
- cmd << "--cover #@cover " if @cover
19
- system(cmd)
20
-
21
- system("links -dump TEMP.html >/tmp/links.out")
22
- str = `wc -w /tmp/links.out`
23
- nw = str.split[0]
24
- puts "Approx words: #{nw}"
25
- # ::FileUtils.rm("TEMP.html")
26
- end