redel 3.0.0

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.
@@ -0,0 +1,164 @@
1
+ # Please see the LICENSE file for copyright and distribution information
2
+ require 'strscan'
3
+
4
+ module Redel
5
+ class OpenTag
6
+ attr_reader :type, :level
7
+ attr_accessor :data, :close
8
+ def initialize(type,level)
9
+ @type = type
10
+ @data = nil
11
+ @close = -1
12
+ @level = level
13
+ end
14
+ end
15
+ class CloseTag
16
+ attr_reader :type, :open, :position_in_markup, :level
17
+ def initialize(type,open,position_in_markup,level)
18
+ @type = type
19
+ @open = open
20
+ @position_in_markup = position_in_markup # in bytes
21
+ @level = level
22
+ end
23
+ end
24
+
25
+ class TagError < StandardError; end
26
+ class TagSkipError < StandardError; end
27
+ class TagContentSkipError < StandardError; end
28
+
29
+ class Output
30
+ def finish_prepare
31
+ end
32
+ def finish_output
33
+ ''
34
+ end
35
+ def string(data)
36
+ data
37
+ end
38
+ end
39
+
40
+ class Grammar
41
+ attr_reader :tree # a list which pretends to be a tree :-)
42
+
43
+ class Pattern
44
+ attr_reader :type, :pstart, :pend, :bol
45
+ def initialize(type, pstart, pend, bol=false)
46
+ @type = type
47
+ @pstart = pstart
48
+ @pend = pend
49
+ @bol = bol
50
+ end
51
+ end
52
+
53
+ def initialize
54
+ @tree = []
55
+ end
56
+
57
+ def self::parse(text)
58
+ new.parse(text)
59
+ end
60
+
61
+ def parse(text) #{{{
62
+ gparse(text,grammar('ROOT'))
63
+ self
64
+ end #}}}
65
+
66
+ # outputs either create text from opening and closing tags (Output), or have a
67
+ # method render that gets the tree
68
+ def output(output) #{{{
69
+ return output.render(@tree) if output.respond_to?(:render)
70
+ out = +''
71
+ skip = {}
72
+ @tree.each_with_index do |c,i|
73
+ next if skip[i]
74
+ begin
75
+ name, data = case c
76
+ when String; ['string',c]
77
+ when OpenTag; ['mO' + c.type,c.data]
78
+ when CloseTag; ['mC' + c.type,@tree[c.open].data]
79
+ end
80
+ next unless output.respond_to?(name,true)
81
+ met = output.method(name)
82
+ out << case met.arity
83
+ when 1; met.call(data)
84
+ when 2; met.call(c,data)
85
+ when 4; met.call(c,i,@tree,data)
86
+ else ''
87
+ end.to_s
88
+ rescue TagSkipError
89
+ skip[c.close] = true if c.is_a?(OpenTag)
90
+ rescue TagContentSkipError
91
+ (i + 1).upto(c.close-1) { |j| skip[j] = true } if c.is_a?(OpenTag)
92
+ end
93
+ end
94
+ out << output.finish_output.to_s
95
+ end #}}}
96
+
97
+ def prepare(output) #{{{
98
+ @tree.each do |c|
99
+ next unless c.is_a?(OpenTag) && output.respond_to?('mP' + c.type,true)
100
+ begin
101
+ output.send('mP' + c.type,c.data)
102
+ rescue TagSkipError, TagContentSkipError
103
+ end
104
+ end
105
+ output.finish_prepare
106
+ self
107
+ end #}}}
108
+
109
+ private
110
+
111
+ def grammar(name) #{{{
112
+ self.class.const_defined?(name) ? self.class.const_get(name) : []
113
+ end #}}}
114
+
115
+ def gparse(text,grammar,position_in_markup=0,level=0) #{{{
116
+ return if text.nil?
117
+ s = StringScanner.new(text)
118
+ until s.eos?
119
+ success = false
120
+ grammar.each do |pat|
121
+ next unless s.match?(pat.pstart)
122
+ pos = s.pos
123
+ bol = s.beginning_of_line?
124
+ ts = s.scan(pat.pstart)
125
+ te = if s.eos?
126
+ '' =~ pat.pend ? '' : nil
127
+ else
128
+ (pat.bol && !bol) ? nil : s.scan_until(pat.pend)
129
+ end
130
+
131
+ if te.nil?
132
+ s.pos = pos
133
+ next
134
+ end
135
+
136
+ ti = te.sub(pat.pend,'')
137
+ te = te[ti.length..-1]
138
+ @tree << ot = OpenTag.new(pat.type,level)
139
+ tpos = @tree.length-1
140
+ begin
141
+ inner = respond_to?('m' + pat.type,true) ? send('m' + pat.type,ts,ti,te) : ti
142
+ rescue TagError
143
+ @tree.pop
144
+ s.pos = pos
145
+ next
146
+ rescue TagSkipError
147
+ @tree.pop
148
+ success = true
149
+ next
150
+ end
151
+ gparse(inner,grammar('G' + pat.type),position_in_markup+pos+ts.bytesize,level+1)
152
+ @tree << CloseTag.new(pat.type,tpos,position_in_markup+s.pos,level)
153
+ ot.close = @tree.length-1
154
+ success = true
155
+ break
156
+ end
157
+ unless success
158
+ @tree << +'' unless @tree.last.is_a?(String)
159
+ @tree.last << s.getch
160
+ end
161
+ end
162
+ end #}}}
163
+ end
164
+ end
@@ -0,0 +1,296 @@
1
+ module Redel; module XHTML
2
+ def unweb(string) XHTML::unweb(string) end
3
+ def web(string) XHTML::web(string) end
4
+ def amp(string) XHTML::amp(string) end
5
+ def ent2ncr(string) XHTML::ent2ncr(string) end
6
+
7
+ def XHTML::unwebxml(string)
8
+ "#{string}".gsub(/&quot;/,"\"").gsub(/&gt;/,">").gsub(/&lt;/,"<").gsub(/&apos;/,"'").gsub(/&amp;/,"&").gsub(/ /,' ').gsub(/\r/,'')
9
+ end
10
+ def XHTML::unweb(string)
11
+ tstring = string.dup
12
+ "#{tstring}".gsub!(/&amp;(amp;)+/,'&amp;')
13
+ "#{tstring}".gsub!(/&amp;(gt;)+/,'&gt;')
14
+ "#{tstring}".gsub!(/&amp;(lt;)+/,'&lt;')
15
+ "#{tstring}".gsub!(/&amp;(apos;)+/,'&apos;')
16
+ "#{tstring}".gsub!(/&amp;(quot;)+/,'&quot;')
17
+ "#{tstring}".gsub(/&quot;/,"\"").gsub(/&gt;/,">").gsub(/&lt;/,"<").gsub(/&apos;/,"'").gsub(/&amp;/,"&").gsub(/ /,' ').gsub(/\r/,'')
18
+ end
19
+ def XHTML::webxml(string)
20
+ "#{string}".gsub(/\&/,"&amp;").gsub(/\"/,"&quot;").gsub(/>/,"&gt;").gsub(/</,"&lt;").gsub(/'/,"&apos;")
21
+ end
22
+ def XHTML::web(string)
23
+ "#{string}".gsub(/\&(?!amp;|quot;|apos;|gt;|lt;)/,"&amp;").gsub(/\"/,"&quot;").gsub(/>/,"&gt;").gsub(/</,"&lt;").gsub(/'/,"&apos;")
24
+ end
25
+ def XHTML::amp(string)
26
+ "#{string}".gsub(/\&(?!amp;)/,"&amp;")
27
+ end
28
+
29
+ def XHTML::ent2ncr(string)
30
+ reps = {
31
+ '&quot;' => '&#34;',
32
+ '&amp;' => '&#38;',
33
+ '&frasl;' => '&#47;',
34
+ '&lt;' => '&#60;',
35
+ '&gt;' => '&#62;',
36
+ '\|' => '&#166;',
37
+ '&nbsp;' => '&#160;',
38
+ '&iexcl;' => '&#161;',
39
+ '&cent;' => '&#162;',
40
+ '&pound;' => '&#163;',
41
+ '&curren;' => '&#164;',
42
+ '&yen;' => '&#165;',
43
+ '&brvbar;' => '&#166;',
44
+ '&brkbar;' => '&#166;',
45
+ '&sect;' => '&#167;',
46
+ '&uml;' => '&#168;',
47
+ '&die;' => '&#168;',
48
+ '&copy;' => '&#169;',
49
+ '&ordf;' => '&#170;',
50
+ '&laquo;' => '&#171;',
51
+ '&not;' => '&#172;',
52
+ '&shy;' => '&#173;',
53
+ '&reg;' => '&#174;',
54
+ '&macr;' => '&#175;',
55
+ '&hibar;' => '&#175;',
56
+ '&deg;' => '&#176;',
57
+ '&plusmn;' => '&#177;',
58
+ '&sup2;' => '&#178;',
59
+ '&sup3;' => '&#179;',
60
+ '&acute;' => '&#180;',
61
+ '&micro;' => '&#181;',
62
+ '&para;' => '&#182;',
63
+ '&middot;' => '&#183;',
64
+ '&cedil;' => '&#184;',
65
+ '&sup1;' => '&#185;',
66
+ '&ordm;' => '&#186;',
67
+ '&raquo;' => '&#187;',
68
+ '&frac14;' => '&#188;',
69
+ '&frac12;' => '&#189;',
70
+ '&frac34;' => '&#190;',
71
+ '&iquest;' => '&#191;',
72
+ '&Agrave;' => '&#192;',
73
+ '&Aacute;' => '&#193;',
74
+ '&Acirc;' => '&#194;',
75
+ '&Atilde;' => '&#195;',
76
+ '&Auml;' => '&#196;',
77
+ '&Aring;' => '&#197;',
78
+ '&AElig;' => '&#198;',
79
+ '&Ccedil;' => '&#199;',
80
+ '&Egrave;' => '&#200;',
81
+ '&Eacute;' => '&#201;',
82
+ '&Ecirc;' => '&#202;',
83
+ '&Euml;' => '&#203;',
84
+ '&Igrave;' => '&#204;',
85
+ '&Iacute;' => '&#205;',
86
+ '&Icirc;' => '&#206;',
87
+ '&Iuml;' => '&#207;',
88
+ '&ETH;' => '&#208;',
89
+ '&Ntilde;' => '&#209;',
90
+ '&Ograve;' => '&#210;',
91
+ '&Oacute;' => '&#211;',
92
+ '&Ocirc;' => '&#212;',
93
+ '&Otilde;' => '&#213;',
94
+ '&Ouml;' => '&#214;',
95
+ '&times;' => '&#215;',
96
+ '&Oslash;' => '&#216;',
97
+ '&Ugrave;' => '&#217;',
98
+ '&Uacute;' => '&#218;',
99
+ '&Ucirc;' => '&#219;',
100
+ '&Uuml;' => '&#220;',
101
+ '&Yacute;' => '&#221;',
102
+ '&THORN;' => '&#222;',
103
+ '&szlig;' => '&#223;',
104
+ '&agrave;' => '&#224;',
105
+ '&aacute;' => '&#225;',
106
+ '&acirc;' => '&#226;',
107
+ '&atilde;' => '&#227;',
108
+ '&auml;' => '&#228;',
109
+ '&aring;' => '&#229;',
110
+ '&aelig;' => '&#230;',
111
+ '&ccedil;' => '&#231;',
112
+ '&egrave;' => '&#232;',
113
+ '&eacute;' => '&#233;',
114
+ '&ecirc;' => '&#234;',
115
+ '&euml;' => '&#235;',
116
+ '&igrave;' => '&#236;',
117
+ '&iacute;' => '&#237;',
118
+ '&icirc;' => '&#238;',
119
+ '&iuml;' => '&#239;',
120
+ '&eth;' => '&#240;',
121
+ '&ntilde;' => '&#241;',
122
+ '&ograve;' => '&#242;',
123
+ '&oacute;' => '&#243;',
124
+ '&ocirc;' => '&#244;',
125
+ '&otilde;' => '&#245;',
126
+ '&ouml;' => '&#246;',
127
+ '&divide;' => '&#247;',
128
+ '&oslash;' => '&#248;',
129
+ '&ugrave;' => '&#249;',
130
+ '&uacute;' => '&#250;',
131
+ '&ucirc;' => '&#251;',
132
+ '&uuml;' => '&#252;',
133
+ '&yacute;' => '&#253;',
134
+ '&thorn;' => '&#254;',
135
+ '&yuml;' => '&#255;',
136
+ '&OElig;' => '&#338;',
137
+ '&oelig;' => '&#339;',
138
+ '&Scaron;' => '&#352;',
139
+ '&scaron;' => '&#353;',
140
+ '&Yuml;' => '&#376;',
141
+ '&fnof;' => '&#402;',
142
+ '&circ;' => '&#710;',
143
+ '&tilde;' => '&#732;',
144
+ '&Alpha;' => '&#913;',
145
+ '&Beta;' => '&#914;',
146
+ '&Gamma;' => '&#915;',
147
+ '&Delta;' => '&#916;',
148
+ '&Epsilon;' => '&#917;',
149
+ '&Zeta;' => '&#918;',
150
+ '&Eta;' => '&#919;',
151
+ '&Theta;' => '&#920;',
152
+ '&Iota;' => '&#921;',
153
+ '&Kappa;' => '&#922;',
154
+ '&Lambda;' => '&#923;',
155
+ '&Mu;' => '&#924;',
156
+ '&Nu;' => '&#925;',
157
+ '&Xi;' => '&#926;',
158
+ '&Omicron;' => '&#927;',
159
+ '&Pi;' => '&#928;',
160
+ '&Rho;' => '&#929;',
161
+ '&Sigma;' => '&#931;',
162
+ '&Tau;' => '&#932;',
163
+ '&Upsilon;' => '&#933;',
164
+ '&Phi;' => '&#934;',
165
+ '&Chi;' => '&#935;',
166
+ '&Psi;' => '&#936;',
167
+ '&Omega;' => '&#937;',
168
+ '&alpha;' => '&#945;',
169
+ '&beta;' => '&#946;',
170
+ '&gamma;' => '&#947;',
171
+ '&delta;' => '&#948;',
172
+ '&epsilon;' => '&#949;',
173
+ '&zeta;' => '&#950;',
174
+ '&eta;' => '&#951;',
175
+ '&theta;' => '&#952;',
176
+ '&iota;' => '&#953;',
177
+ '&kappa;' => '&#954;',
178
+ '&lambda;' => '&#955;',
179
+ '&mu;' => '&#956;',
180
+ '&nu;' => '&#957;',
181
+ '&xi;' => '&#958;',
182
+ '&omicron;' => '&#959;',
183
+ '&pi;' => '&#960;',
184
+ '&rho;' => '&#961;',
185
+ '&sigmaf;' => '&#962;',
186
+ '&sigma;' => '&#963;',
187
+ '&tau;' => '&#964;',
188
+ '&upsilon;' => '&#965;',
189
+ '&phi;' => '&#966;',
190
+ '&chi;' => '&#967;',
191
+ '&psi;' => '&#968;',
192
+ '&omega;' => '&#969;',
193
+ '&thetasym;' => '&#977;',
194
+ '&upsih;' => '&#978;',
195
+ '&piv;' => '&#982;',
196
+ '&ensp;' => '&#8194;',
197
+ '&emsp;' => '&#8195;',
198
+ '&thinsp;' => '&#8201;',
199
+ '&zwnj;' => '&#8204;',
200
+ '&zwj;' => '&#8205;',
201
+ '&lrm;' => '&#8206;',
202
+ '&rlm;' => '&#8207;',
203
+ '&ndash;' => '&#8211;',
204
+ '&mdash;' => '&#8212;',
205
+ '&lsquo;' => '&#8216;',
206
+ '&rsquo;' => '&#8217;',
207
+ '&sbquo;' => '&#8218;',
208
+ '&ldquo;' => '&#8220;',
209
+ '&rdquo;' => '&#8221;',
210
+ '&bdquo;' => '&#8222;',
211
+ '&dagger;' => '&#8224;',
212
+ '&Dagger;' => '&#8225;',
213
+ '&bull;' => '&#8226;',
214
+ '&hellip;' => '&#8230;',
215
+ '&permil;' => '&#8240;',
216
+ '&prime;' => '&#8242;',
217
+ '&Prime;' => '&#8243;',
218
+ '&lsaquo;' => '&#8249;',
219
+ '&rsaquo;' => '&#8250;',
220
+ '&oline;' => '&#8254;',
221
+ '&frasl;' => '&#8260;',
222
+ '&euro;' => '&#8364;',
223
+ '&image;' => '&#8465;',
224
+ '&weierp;' => '&#8472;',
225
+ '&real;' => '&#8476;',
226
+ '&trade;' => '&#8482;',
227
+ '&alefsym;' => '&#8501;',
228
+ '&crarr;' => '&#8629;',
229
+ '&lArr;' => '&#8656;',
230
+ '&uArr;' => '&#8657;',
231
+ '&rArr;' => '&#8658;',
232
+ '&dArr;' => '&#8659;',
233
+ '&hArr;' => '&#8660;',
234
+ '&forall;' => '&#8704;',
235
+ '&part;' => '&#8706;',
236
+ '&exist;' => '&#8707;',
237
+ '&empty;' => '&#8709;',
238
+ '&nabla;' => '&#8711;',
239
+ '&isin;' => '&#8712;',
240
+ '&notin;' => '&#8713;',
241
+ '&ni;' => '&#8715;',
242
+ '&prod;' => '&#8719;',
243
+ '&sum;' => '&#8721;',
244
+ '&Sum;' => '&#8721;',
245
+ '&minus;' => '&#8722;',
246
+ '&lowast;' => '&#8727;',
247
+ '&radic;' => '&#8730;',
248
+ '&prop;' => '&#8733;',
249
+ '&infin;' => '&#8734;',
250
+ '&ang;' => '&#8736;',
251
+ '&and;' => '&#8743;',
252
+ '&or;' => '&#8744;',
253
+ '&cap;' => '&#8745;',
254
+ '&cup;' => '&#8746;',
255
+ '&int;' => '&#8747;',
256
+ '&there4;' => '&#8756;',
257
+ '&sim;' => '&#8764;',
258
+ '&cong;' => '&#8773;',
259
+ '&asymp;' => '&#8776;',
260
+ '&ne;' => '&#8800;',
261
+ '&equiv;' => '&#8801;',
262
+ '&le;' => '&#8804;',
263
+ '&ge;' => '&#8805;',
264
+ '&sub;' => '&#8834;',
265
+ '&sup;' => '&#8835;',
266
+ '&nsub;' => '&#8836;',
267
+ '&sube;' => '&#8838;',
268
+ '&supe;' => '&#8839;',
269
+ '&oplus;' => '&#8853;',
270
+ '&otimes;' => '&#8855;',
271
+ '&perp;' => '&#8869;',
272
+ '&sdot;' => '&#8901;',
273
+ '&lceil;' => '&#8968;',
274
+ '&rceil;' => '&#8969;',
275
+ '&lfloor;' => '&#8970;',
276
+ '&rfloor;' => '&#8971;',
277
+ '&lang;' => '&#9001;',
278
+ '&rang;' => '&#9002;',
279
+ '&larr;' => '&#8592;',
280
+ '&uarr;' => '&#8593;',
281
+ '&rarr;' => '&#8594;',
282
+ '&darr;' => '&#8595;',
283
+ '&harr;' => '&#8596;',
284
+ '&loz;' => '&#9674;',
285
+ '&spades;' => '&#9824;',
286
+ '&clubs;' => '&#9827;',
287
+ '&hearts;' => '&#9829;',
288
+ '&diams;' => '&#9830;'
289
+ }
290
+ string.gsub(/\&\w+;/) do|m|
291
+ r = reps[m]
292
+ r.nil? ? m : r
293
+ end
294
+ end
295
+
296
+ end; end
data/lib/redel.rb ADDED
@@ -0,0 +1,4 @@
1
+ # Please see the LICENSE file for copyright and distribution information
2
+ require_relative 'redel/parser'
3
+ require_relative 'redel/grammar_simple'
4
+ require_relative 'redel/output_html'
data/redel.gemspec ADDED
@@ -0,0 +1,22 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "redel"
3
+ s.version = "3.0.0"
4
+ s.platform = Gem::Platform::RUBY
5
+ s.license = "GPL-3.0-or-later"
6
+ s.summary = "Recursive delimiter parser for markup languages"
7
+
8
+ s.description = "Base for grammars that consist of nested patterns with a start and an end, and for their outputs. Originally the wiki parser of CEWebS."
9
+
10
+ s.files = Dir['{lib/**/*}'] + %w(LICENSE Rakefile redel.gemspec README.md AUTHORS)
11
+ s.require_path = 'lib'
12
+ s.extra_rdoc_files = ['README.md']
13
+ s.test_files = Dir['test/tc_*.rb']
14
+
15
+ s.required_ruby_version = '>=3.2'
16
+
17
+ s.authors = ['Juergen eTM Mangler']
18
+ s.email = 'juergen.mangler@gmail.com'
19
+ s.homepage = 'https://github.com/etm/redel'
20
+
21
+ s.add_runtime_dependency 'markus', '~> 4.0'
22
+ end
data/test/tc_html.rb ADDED
@@ -0,0 +1,26 @@
1
+ require 'minitest/autorun'
2
+ require_relative '../lib/redel'
3
+
4
+ class TestHTML < Minitest::Test
5
+ def simple(text) Redel::Simple.parse(text).output(Redel::HTML.new); end
6
+
7
+ def test_inline
8
+ assert_equal "<div><strong>a</strong> <em>b</em> &lt;c&gt; &#8594;&#160;</div>", simple("'''a''' ''b'' &lt;c&gt; -&gt;")
9
+ assert_equal '<div><a href="http://a.b/c">d</a>&#160;</div>', simple('[http://a.b/c|d]')
10
+ end
11
+
12
+ def test_heading_and_paragraphs
13
+ assert_equal '<h1>A</h1><div>b&#160;</div><div>&#160;</div><div>c&#160;</div>', simple("== A\nb\n\nc")
14
+ end
15
+
16
+ def test_lists
17
+ out = simple("* a\n** b\n")
18
+ assert_equal 2, out.scan('<ul').length
19
+ assert_equal out.scan('<li').length, out.scan('</li>').length
20
+ assert_includes simple("# a\n# b"), 'counter-increment: item 1'
21
+ end
22
+
23
+ def test_code
24
+ assert_includes simple(" a &amp; b\n c"), '&#160;&#160;c</div>'
25
+ end
26
+ end
data/test/tc_parser.rb ADDED
@@ -0,0 +1,65 @@
1
+ require 'minitest/autorun'
2
+ require_relative '../lib/redel'
3
+
4
+ class TestParser < Minitest::Test
5
+ class Language < Redel::Grammar
6
+ P_STRONG = Pattern.new('P_STRONG', /\*/, /\*/)
7
+ P_EM = Pattern.new('P_EM', /_/, /_/)
8
+ P_LINE = Pattern.new('P_LINE', /> /, /\n|\z/, true)
9
+
10
+ ROOT = [ P_LINE, P_STRONG, P_EM ]
11
+ GP_STRONG = [ P_EM ]
12
+
13
+ def mP_LINE(ts,ti,te)
14
+ @tree.last.data = ti.length
15
+ ti
16
+ end
17
+ end
18
+
19
+ class Text < Redel::Output
20
+ attr_reader :lines
21
+ def mPP_LINE(data) (@lines ||= []) << data; end
22
+ def mOP_LINE(data) "<p #{data}>"; end
23
+ def mCP_LINE(data) '</p>'; end
24
+ def mOP_STRONG(data) '<b>'; end
25
+ def mCP_STRONG(data) '</b>'; end
26
+ def mOP_EM(data) '<i>'; end
27
+ def mCP_EM(data) '</i>'; end
28
+ end
29
+
30
+ class Tree
31
+ def render(tree) tree.length; end
32
+ end
33
+
34
+ def out(text) Language.parse(text).output(Text.new); end
35
+
36
+ def test_nested
37
+ assert_equal 'some <b>bold <i>and italic</i></b> text', out('some *bold _and italic_* text')
38
+ end
39
+
40
+ def test_not_allowed_inside
41
+ assert_equal '<i>a *b*</i>', out('_a *b*_')
42
+ end
43
+
44
+ def test_unfinished
45
+ assert_equal 'a * b', out('a * b')
46
+ end
47
+
48
+ def test_beginning_of_line
49
+ assert_equal "<p 1>a</p>b > c", out("> a\nb > c")
50
+ end
51
+
52
+ def test_prepare
53
+ output = Text.new
54
+ Language.parse("> a\n> bcd").prepare(output)
55
+ assert_equal [1,3], output.lines
56
+ end
57
+
58
+ def test_simple
59
+ assert_equal '<b>a</b> <i>b</i>', Redel::Simple.parse("'''a''' ''b''").output(Text.new)
60
+ end
61
+
62
+ def test_render
63
+ assert_equal 3, Language.parse('*a*').output(Tree.new)
64
+ end
65
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: redel
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Juergen eTM Mangler
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: markus
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '4.0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '4.0'
26
+ description: Base for grammars that consist of nested patterns with a start and an
27
+ end, and for their outputs. Originally the wiki parser of CEWebS.
28
+ email: juergen.mangler@gmail.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files:
32
+ - README.md
33
+ files:
34
+ - AUTHORS
35
+ - LICENSE
36
+ - README.md
37
+ - Rakefile
38
+ - lib/redel.rb
39
+ - lib/redel/grammar_simple.rb
40
+ - lib/redel/helpers.rb
41
+ - lib/redel/image.rb
42
+ - lib/redel/output_html.rb
43
+ - lib/redel/parser.rb
44
+ - lib/redel/xhtml.rb
45
+ - redel.gemspec
46
+ - test/tc_html.rb
47
+ - test/tc_parser.rb
48
+ homepage: https://github.com/etm/redel
49
+ licenses:
50
+ - GPL-3.0-or-later
51
+ metadata: {}
52
+ rdoc_options: []
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '3.2'
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ requirements: []
66
+ rubygems_version: 3.6.9
67
+ specification_version: 4
68
+ summary: Recursive delimiter parser for markup languages
69
+ test_files:
70
+ - test/tc_html.rb
71
+ - test/tc_parser.rb