maruku 0.2.9 → 0.2.10
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/maruku/parse_span.rb +16 -4
- data/lib/maruku/string_utils.rb +21 -4
- data/lib/maruku/version.rb +1 -1
- metadata +2 -2
data/lib/maruku/parse_span.rb
CHANGED
@@ -47,14 +47,16 @@ class Maruku
|
|
47
47
|
# search for ``code`` markers
|
48
48
|
span.match_couple_of('``') { |children, match1, match2|
|
49
49
|
e = create_md_element(:inline_code)
|
50
|
-
|
50
|
+
# this is now opaque to processing
|
51
|
+
e.meta[:raw_code] = children.join('').it_was_a_code_block
|
51
52
|
e
|
52
53
|
}
|
53
54
|
|
54
55
|
# Search for `single tick` code markers
|
55
56
|
span.match_couple_of('`') { |children, match1, match2|
|
56
57
|
e = create_md_element(:inline_code)
|
57
|
-
|
58
|
+
# this is now opaque to processing
|
59
|
+
e.meta[:raw_code] = children.join('').it_was_a_code_block
|
58
60
|
# this is now opaque to processing
|
59
61
|
e
|
60
62
|
}
|
@@ -167,11 +169,13 @@ class Maruku
|
|
167
169
|
" # closing
|
168
170
|
}x
|
169
171
|
|
170
|
-
# (http://www.google.com "Google.com"),
|
172
|
+
# [bah](http://www.google.com "Google.com"),
|
173
|
+
# [bah](http://www.google.com),
|
174
|
+
# [empty]()
|
171
175
|
reg_url_and_title = %r{
|
172
176
|
\( # opening
|
173
177
|
\s* # whitespace
|
174
|
-
#{reg_url} # url = 1
|
178
|
+
#{reg_url}? # url = 1 might be empty
|
175
179
|
(?:\s+["'](.*)["'])? # optional title = 2
|
176
180
|
\s* # whitespace
|
177
181
|
\) # closing
|
@@ -234,6 +238,7 @@ class Maruku
|
|
234
238
|
}
|
235
239
|
|
236
240
|
# Detect any link with immediate url: [Google](http://www.google.com)
|
241
|
+
# XXX Note that the url can be empty: [Empty]()
|
237
242
|
# a dummy ref is created and put in the symbol table
|
238
243
|
span.match_couple_of('[', # opening bracket
|
239
244
|
%r{\] # closing bracket
|
@@ -265,6 +270,13 @@ class Maruku
|
|
265
270
|
|
266
271
|
|
267
272
|
# And now the easy stuff
|
273
|
+
|
274
|
+
# search for ***strong and em***
|
275
|
+
span.match_couple_of('***') { |children,m1,m2|
|
276
|
+
create_md_element(:strong, [create_md_element(:emphasis, children)] ) }
|
277
|
+
|
278
|
+
span.match_couple_of('___') { |children,m1,m2|
|
279
|
+
create_md_element(:strong, [create_md_element(:emphasis, children)] ) }
|
268
280
|
|
269
281
|
# search for **strong**
|
270
282
|
span.match_couple_of('**') { |children,m1,m2| create_md_element(:strong, children) }
|
data/lib/maruku/string_utils.rb
CHANGED
@@ -193,7 +193,7 @@ class Maruku
|
|
193
193
|
# line that were mistaken for raw_html
|
194
194
|
return :text if l=~EMailAddress or l=~ URL
|
195
195
|
return :raw_html if l =~ %r{^[ ]?[ ]?[ ]?</?\s*\w+}
|
196
|
-
return :ulist if l =~ /^\s?(
|
196
|
+
return :ulist if l =~ /^\s?([\*-\+])\s+.*\w+/
|
197
197
|
return :olist if l =~ /^\s?\d\..*\w+/
|
198
198
|
return :empty if l.strip.size == 0
|
199
199
|
return :header1 if l =~ /^(=)+/
|
@@ -274,16 +274,16 @@ class Maruku
|
|
274
274
|
end
|
275
275
|
|
276
276
|
class String
|
277
|
-
S =
|
277
|
+
S = 230
|
278
278
|
MarkdownEscaped =
|
279
|
-
[["\\",S+0],
|
279
|
+
[["\\",S+0],
|
280
280
|
['`',S+1],
|
281
281
|
['*',S+2],
|
282
282
|
['_',S+3],['{',S+4],['}',S+5],['[',S+6],[']',S+7],
|
283
283
|
['(',S+8],[')',S+9],['#',S+10],['.',S+11],
|
284
284
|
['!',S+12],
|
285
285
|
# PHP Markdown extra
|
286
|
-
['|',S+13],[':',S+14]]
|
286
|
+
['|',S+13],[':',S+14], ["+",S+15], ["-",S+16], [">",S+17]]
|
287
287
|
|
288
288
|
MarkdownAdd = 200
|
289
289
|
|
@@ -314,6 +314,23 @@ class String
|
|
314
314
|
end
|
315
315
|
self
|
316
316
|
end
|
317
|
+
|
318
|
+
def it_was_a_code_block
|
319
|
+
s = ""; tmp =" "
|
320
|
+
each_byte do |b|
|
321
|
+
tmp[0] = b
|
322
|
+
found = false
|
323
|
+
for e in MarkdownEscaped
|
324
|
+
if b == e[1]
|
325
|
+
s << '\\'
|
326
|
+
s << e[0]
|
327
|
+
found = true
|
328
|
+
end
|
329
|
+
end
|
330
|
+
s << tmp if not found
|
331
|
+
end
|
332
|
+
s
|
333
|
+
end
|
317
334
|
|
318
335
|
def unescape_md_special; dup.unescape_md_special! end
|
319
336
|
def escape_md_special; dup. escape_md_special! end
|
data/lib/maruku/version.rb
CHANGED
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: maruku
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.2.
|
7
|
-
date: 2006-12-
|
6
|
+
version: 0.2.10
|
7
|
+
date: 2006-12-28 00:00:00 +01:00
|
8
8
|
summary: A Markdown interpreter in Ruby
|
9
9
|
require_paths:
|
10
10
|
- lib
|