martile 0.1.26 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/martile.rb +23 -22
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1bd0764fcf645b03a35dcb6d27b423c2fbd2ef5c
|
4
|
+
data.tar.gz: 47583be9f06a798ea9ba1ff2e224a319efa76648
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e7a4c0b49e109ac5357a305f3b40706523984a42b3524dc7126488c1223d2822f9c02efcf12f625fb5011b181abca7052cc606b63192229ed87a76f813b393a
|
7
|
+
data.tar.gz: d42f83523621072e67a4a7df8de6efb74822d23f5c6612749383fca7fdc215c68e9b284a41c8ddc9950d9125b09e4f5b069b66f99f06bcb1b5f72b08d2dc515f
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/martile.rb
CHANGED
@@ -8,6 +8,8 @@ require 'dynarex'
|
|
8
8
|
require 'rdiscount'
|
9
9
|
|
10
10
|
|
11
|
+
# bug fix: 03-Apr-2014: XML or HTML elements should now be filtered out
|
12
|
+
# of any transformations.
|
11
13
|
# feature: 31-Mar-2014: Added an _underline_ feature.
|
12
14
|
# bug fix: 01-Mar-2014: A Dynarex_to_table statement between 2 HTML blocks
|
13
15
|
# is now handled properly.
|
@@ -34,7 +36,9 @@ class Martile
|
|
34
36
|
attr_reader :to_html
|
35
37
|
|
36
38
|
def initialize(s)
|
37
|
-
|
39
|
+
|
40
|
+
raw_s2 = apply_filter(s) {|x| code_block_to_html x }
|
41
|
+
#puts 'raw_s2: ' + raw_s2.inspect
|
38
42
|
|
39
43
|
# ensure all angle brackets within <pre><code> is escaped
|
40
44
|
s2 = raw_s2.split(/(?=<pre><code>)/m).map { |y|
|
@@ -55,16 +59,22 @@ class Martile
|
|
55
59
|
end
|
56
60
|
|
57
61
|
#puts 's2 : ' + s2.inspect
|
58
|
-
|
62
|
+
|
63
|
+
s3 = apply_filter(s2) {|x| ordered_list_to_html x }
|
59
64
|
#puts 's3 : ' + s3.inspect
|
60
|
-
|
65
|
+
|
66
|
+
s4 = apply_filter(s3) {|x| unordered_list_to_html x }
|
61
67
|
#puts 's4 : ' + s4.inspect
|
62
|
-
|
68
|
+
|
69
|
+
s5 = apply_filter(s4) {|x| dynarex_to_table x }
|
63
70
|
#puts 's5 :' + s5.inspect
|
64
|
-
|
71
|
+
|
72
|
+
s6 = apply_filter(s5) {|x| table_to_html x }
|
65
73
|
#puts 's6 : ' + s6.inspect
|
66
|
-
|
74
|
+
|
75
|
+
s7 = apply_filter(s6) {|x| underline x }
|
67
76
|
#puts 's7 : ' + s7.inspect
|
77
|
+
|
68
78
|
@to_html = s7
|
69
79
|
end
|
70
80
|
|
@@ -105,8 +115,8 @@ class Martile
|
|
105
115
|
|
106
116
|
dynarex = Dynarex.new($1)
|
107
117
|
dynarex.to_h.map(&:values)
|
108
|
-
'[' + dynarex.to_h.map{|x| x.values.join('|')
|
109
|
-
|
118
|
+
'[' + dynarex.to_h.map{|x| x.values.join('|').gsub('<','<')\
|
119
|
+
.gsub('>','>') + "\n"}.join('|').chomp + ']'
|
110
120
|
end
|
111
121
|
end
|
112
122
|
|
@@ -136,19 +146,11 @@ class Martile
|
|
136
146
|
|
137
147
|
end
|
138
148
|
|
139
|
-
def
|
140
|
-
|
141
|
-
s.gsub(/<(\w+)>[^(?:<\/\1>)]+<\/\1>*|.+/m) do |x|
|
149
|
+
def apply_filter(s, &block)
|
142
150
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
s1 = text1.length > 0 ? self.method(name).call(text1) : ''
|
147
|
-
#puts 'plain_text : ' + plain_text.inspect
|
148
|
-
s2 = plain_text.length > 0 ? self.method(name).call(plain_text.to_s) : ''
|
149
|
-
s1 + html.to_s + s2
|
150
|
-
end
|
151
|
-
end
|
151
|
+
Rexle.new("<root>#{s}</root>").root\
|
152
|
+
.map {|x| x.is_a?(String) ? block.call(x) : x}.join
|
153
|
+
end
|
152
154
|
|
153
155
|
def ordered_list_to_html(s)
|
154
156
|
list_to_html s, '#'
|
@@ -174,9 +176,8 @@ class Martile
|
|
174
176
|
end
|
175
177
|
end
|
176
178
|
end
|
177
|
-
|
179
|
+
|
178
180
|
r = Rexle.new(a).xml pretty: true, declaration: false
|
179
|
-
puts 'r : ' + r.inspect
|
180
181
|
r
|
181
182
|
end
|
182
183
|
return s
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: martile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
YF3JmVOebtMx3b9sXkLX1YyX0fsg59FXvg9CVfAoaG6qjG2Y/okBwMSqqMLQiiao
|
32
32
|
aRfEuwOkM9Z+zA==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2014-03
|
34
|
+
date: 2014-04-03 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rexle-builder
|
metadata.gz.sig
CHANGED
Binary file
|