livetext 0.7.6 → 0.7.7
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 +4 -4
- data/dsl/markdown.rb +5 -0
- data/lib/livetext.rb +1 -1
- data/lib/standard.rb +17 -1
- data/lib/userapi.rb +42 -3
- data/test/test.rb +0 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1bf150349564c9f613698a94db648859a5b03d3b
|
4
|
+
data.tar.gz: cea49f36d5db27d1fdff4d0c5484686044126104
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
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
|
-
|
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
|
-
|
127
|
-
l2 =
|
128
|
-
|
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
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.
|
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-
|
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
|