livetext 0.7.6 → 0.7.7

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
  SHA1:
3
- metadata.gz: b7059d92044e10b0b6434ca10c8fca98495abd9c
4
- data.tar.gz: 7811dac366af024bd3257d31278902d023a5d4ec
3
+ metadata.gz: 1bf150349564c9f613698a94db648859a5b03d3b
4
+ data.tar.gz: cea49f36d5db27d1fdff4d0c5484686044126104
5
5
  SHA512:
6
- metadata.gz: 09c0a9e24e023e36a26c3b176a5ddb7d1e4f474ffe372da8595d947b88f2e7bce49269190dc2e76f4d293354b8582974da41b64dd801dd10c5b0fb84a59d99db
7
- data.tar.gz: eba59a3e5dde7c6c609bbc0e5c6d093d7dc2dacee41301451e06eb5ceb770754025180694fe1cafde14e141301e8d9fc2f273e1e46f76ebe87f74422e67f8d18
6
+ metadata.gz: c8ec7ac2f7028ef1fef91e3e1937e62e7f91fbd467a0a3e0c7c58d51796b05ada956fb89a04ecc8b2487d53591fa5ab211d18bfd095ddc4c5404ce92d178afad
7
+ data.tar.gz: 106ef65fea37b5d262d574f3adf7435ff95397508be3241d7e3711a050f2019f3303bce8bdf9f1b308518568d9c49dc3b5f9cf21066021050513ceb04798b7b9
data/dsl/markdown.rb CHANGED
@@ -1,6 +1,11 @@
1
1
  # This file is intended to be used via a Livetext .mixin
2
2
  # or the equivalent.
3
3
 
4
+ SimpleFormats[:b] = %w[* *]
5
+ SimpleFormats[:i] = %w[_ _]
6
+ SimpleFormats[:t] = %w[` `]
7
+ SimpleFormats[:s] = %w[<strike> </strike>]
8
+
4
9
  def h1; _puts "# #{@_data}"; end # atx style for now
5
10
  def h2; _puts "## #{@_data}"; end
6
11
  def h3; _puts "### #{@_data}"; end
data/lib/livetext.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class Livetext
2
- VERSION = "0.7.6"
2
+ VERSION = "0.7.7"
3
3
  end
4
4
 
5
5
  require 'fileutils'
data/lib/standard.rb CHANGED
@@ -1,13 +1,27 @@
1
1
  module Livetext::Standard
2
2
 
3
+ SimpleFormats = # Move this?
4
+ { b: %w[<b> </b>],
5
+ i: %w[<i> </i>],
6
+ t: %w[<tt> </tt>],
7
+ s: %w[<strike> </strike>] }
8
+
3
9
  def data=(val)
4
10
  @_data = val
5
11
  @_args = val.split
6
12
  @_mixins = []
7
13
  end
8
14
 
15
+ def bits # dumb name - bold, italic, teletype, striketrough
16
+ b0, b1, i0, i1, t0, t1, s0, s1 = *@_args
17
+ SimpleFormats[:b] = [b0, b1]
18
+ SimpleFormats[:i] = [i0, i1]
19
+ SimpleFormats[:t] = [t0, t1]
20
+ SimpleFormats[:s] = [s0, s1]
21
+ end
22
+
9
23
  def comment
10
- junk = _body # do nothing with contents
24
+ _body
11
25
  end
12
26
 
13
27
  def shell
@@ -69,12 +83,14 @@ module Livetext::Standard
69
83
  end
70
84
 
71
85
  def _output(name)
86
+ @_outdir ||= "." # FIXME
72
87
  @output.close unless @output == STDOUT
73
88
  @output = File.open(@_outdir + "/" + name, "w")
74
89
  @output.puts "<meta charset='UTF-8'>\n\n"
75
90
  end
76
91
 
77
92
  def _append(name)
93
+ @_outdir ||= "." # FIXME
78
94
  @output.close unless @output == STDOUT
79
95
  @output = File.open(@_outdir + "/" + name, "a")
80
96
  @output.puts "<meta charset='UTF-8'>\n\n"
data/lib/userapi.rb CHANGED
@@ -80,6 +80,41 @@ module Livetext::UserAPI
80
80
  _body(sigil).join("\n")
81
81
  end
82
82
 
83
+ def _new_format(line, delim, sym)
84
+ d0, d1 = Livetext::Standard::SimpleFormats[sym]
85
+ s = line.each_char
86
+ c = s.next
87
+ last = nil
88
+ getch = -> { last = c; c = s.next }
89
+ buffer = ""
90
+ loop do
91
+ case c
92
+ when " "
93
+ buffer << " "
94
+ last = " "
95
+ when delim
96
+ if last == " " || last == nil
97
+ buffer << d0
98
+ c = getch.call
99
+ if c == "("
100
+ loop { getch.call; break if c == ")"; buffer << c }
101
+ buffer << d1
102
+ else
103
+ loop { buffer << c; getch.call; break if c == " " || c == nil || c == "\n" }
104
+ buffer << d1
105
+ buffer << " " if c == " "
106
+ end
107
+ else
108
+ buffer << delim
109
+ end
110
+ else
111
+ buffer << c
112
+ end
113
+ getch.call
114
+ end
115
+ buffer
116
+ end
117
+
83
118
  def _basic_format(line, delim, tag)
84
119
  s = line.each_char
85
120
  c = s.next
@@ -123,9 +158,13 @@ module Livetext::UserAPI
123
158
  end
124
159
 
125
160
  def _formatting(line)
126
- l2 = _basic_format(line, "_", "i")
127
- l2 = _basic_format(l2, "*", "b")
128
- l2 = _basic_format(l2, "`", "tt")
161
+ # l2 = _basic_format(line, "_", "i")
162
+ l2 = _new_format(line, "_", :i)
163
+ # l2 = _basic_format(l2, "*", "b")
164
+ l2 = _new_format(l2, "*", :b)
165
+ # l2 = _basic_format(l2, "`", "tt")
166
+ l2 = _new_format(l2, "`", :t)
167
+ # Do strikethrough?
129
168
  l2 = _handle_escapes(l2, "_*`")
130
169
  line.replace(l2)
131
170
  end
data/test/test.rb CHANGED
@@ -65,7 +65,6 @@ class TestingLiveText < MiniTest::Test
65
65
  def test_example_alpha2; external_files end
66
66
 
67
67
  def test_functions; external_files end
68
-
69
68
  end
70
69
 
71
70
 
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.6
4
+ version: 0.7.7
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-03-25 00:00:00.000000000 Z
11
+ date: 2017-03-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A smart text processor extensible in Ruby
14
14
  email: rubyhacker@gmail.com