maruku 0.5.9 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/maruku +6 -1
- data/bin/marutest +25 -18
- data/lib/maruku.rb +3 -0
- data/lib/maruku/ext/div.rb +39 -6
- data/lib/maruku/ext/math/latex_fix.rb +1 -0
- data/lib/maruku/ext/math/mathml_engines/blahtex.rb +9 -8
- data/lib/maruku/ext/math/parsing.rb +15 -1
- data/lib/maruku/ext/math/to_html.rb +34 -17
- data/lib/maruku/ext/math/to_latex.rb +4 -0
- data/lib/maruku/helpers.rb +3 -3
- data/lib/maruku/input/charsource.rb +1 -1
- data/lib/maruku/input/parse_block.rb +1 -0
- data/lib/maruku/input/parse_doc.rb +12 -5
- data/lib/maruku/input/parse_span_better.rb +24 -10
- data/lib/maruku/output/s5/to_s5.rb +14 -1
- data/lib/maruku/output/to_html.rb +20 -1
- data/lib/maruku/output/to_latex.rb +27 -0
- data/lib/maruku/output/to_latex_entities.rb +2 -2
- data/lib/maruku/output/to_s.rb +5 -2
- data/lib/maruku/string_utils.rb +2 -2
- data/lib/maruku/structures.rb +2 -0
- data/lib/maruku/tests/new_parser.rb +5 -2
- data/lib/maruku/version.rb +1 -1
- data/tests/bugs/code_in_links.md +85 -0
- data/tests/bugs/complex_escaping.md +34 -0
- data/tests/unittest/abbreviations.md +2 -10
- data/tests/unittest/alt.md +2 -3
- data/tests/unittest/attributes/att2.md +2 -4
- data/tests/unittest/attributes/att3.md +2 -7
- data/tests/unittest/attributes/attributes.md +2 -15
- data/tests/unittest/attributes/circular.md +2 -7
- data/tests/unittest/attributes/default.md +2 -6
- data/tests/unittest/blank.md +2 -5
- data/tests/unittest/blanks_in_code.md +2 -21
- data/tests/unittest/bug_def.md +2 -3
- data/tests/unittest/bug_table.md +2 -11
- data/tests/unittest/code.md +2 -9
- data/tests/unittest/code2.md +2 -8
- data/tests/unittest/code3.md +2 -21
- data/tests/unittest/data_loss.md +2 -7
- data/tests/unittest/divs/div1.md +32 -57
- data/tests/unittest/divs/div2.md +6 -7
- data/tests/unittest/divs/div3_nest.md +8 -13
- data/tests/unittest/easy.md +2 -3
- data/tests/unittest/email.md +2 -3
- data/tests/unittest/encoding/iso-8859-1.md +2 -5
- data/tests/unittest/encoding/utf-8.md +2 -5
- data/tests/unittest/entities.md +2 -20
- data/tests/unittest/escaping.md +2 -12
- data/tests/unittest/extra_dl.md +2 -10
- data/tests/unittest/extra_header_id.md +2 -13
- data/tests/unittest/extra_table1.md +2 -8
- data/tests/unittest/footnotes.md +2 -19
- data/tests/{bugs/html.md → unittest/hang.md} +9 -9
- data/tests/unittest/headers.md +2 -7
- data/tests/unittest/hex_entities.md +2 -3
- data/tests/unittest/hrule.md +2 -11
- data/tests/unittest/html2.md +2 -6
- data/tests/unittest/html3.md +2 -6
- data/tests/unittest/html4.md +2 -7
- data/tests/unittest/html5.md +2 -5
- data/tests/unittest/ie.md +2 -23
- data/tests/unittest/images.md +2 -14
- data/tests/unittest/images2.md +2 -5
- data/tests/unittest/inline_html.md +6 -102
- data/tests/unittest/inline_html2.md +2 -5
- data/tests/unittest/links.md +17 -50
- data/tests/unittest/links2.md +2 -3
- data/tests/unittest/list1.md +2 -10
- data/tests/unittest/list12.md +2 -5
- data/tests/unittest/list2.md +2 -10
- data/tests/unittest/list3.md +2 -14
- data/tests/unittest/list4.md +2 -17
- data/tests/unittest/lists.md +2 -39
- data/tests/unittest/lists10.md +2 -7
- data/tests/unittest/lists11.md +2 -5
- data/tests/unittest/lists6.md +2 -3
- data/tests/unittest/lists9.md +2 -11
- data/tests/unittest/lists_after_paragraph.md +3 -51
- data/tests/unittest/lists_ol.md +2 -52
- data/tests/unittest/loss.md +2 -3
- data/tests/unittest/math/equations.md +54 -37
- data/tests/unittest/math/inline.md +4 -12
- data/tests/unittest/math/math2.md +4 -57
- data/tests/unittest/math/notmath.md +2 -5
- data/tests/unittest/math/table.md +5 -11
- data/tests/unittest/math/table2.md +2 -8
- data/tests/unittest/misc_sw.md +2 -80
- data/tests/unittest/notyet/escape.md +2 -5
- data/tests/unittest/notyet/header_after_par.md +2 -13
- data/tests/unittest/notyet/ticks.md +2 -3
- data/tests/unittest/notyet/triggering.md +2 -39
- data/tests/unittest/olist.md +2 -9
- data/tests/unittest/one.md +2 -3
- data/tests/unittest/paragraph.md +2 -3
- data/tests/unittest/paragraph_rules/dont_merge_ref.md +2 -5
- data/tests/unittest/paragraph_rules/tab_is_blank.md +2 -5
- data/tests/unittest/paragraphs.md +2 -10
- data/tests/unittest/pending/amps.md +2 -4
- data/tests/unittest/pending/empty_cells.md +2 -6
- data/tests/unittest/pending/link.md +2 -21
- data/tests/unittest/pending/ref.md +2 -3
- data/tests/unittest/recover/recover_links.md +7 -8
- data/tests/{bugs → unittest/red_tests}/abbrev.md +12 -103
- data/tests/unittest/{lists7.md → red_tests/lists7.md} +2 -13
- data/tests/unittest/{lists7b.md → red_tests/lists7b.md} +2 -10
- data/tests/unittest/{lists8.md → red_tests/lists8.md} +2 -9
- data/tests/unittest/red_tests/xml.md +70 -0
- data/tests/unittest/references/long_example.md +2 -7
- data/tests/unittest/references/spaces_and_numbers.md +2 -3
- data/tests/unittest/smartypants.md +2 -47
- data/tests/unittest/syntax_hl.md +2 -18
- data/tests/unittest/table_attributes.md +2 -8
- data/tests/unittest/test.md +2 -3
- data/tests/unittest/underscore_in_words.md +27 -0
- data/tests/unittest/wrapping.md +2 -11
- data/tests/unittest/xml2.md +2 -5
- data/tests/unittest/xml3.md +2 -8
- data/tests/unittest/xml_instruction.md +2 -10
- data/unit_test_span.sh +2 -1
- metadata +242 -241
- data/docs/changelog.html +0 -490
- data/docs/entity_test.html +0 -258
- data/docs/exd.html +0 -307
- data/docs/index.html +0 -332
- data/docs/markdown_syntax.html +0 -690
- data/docs/maruku.html +0 -332
- data/docs/proposal.html +0 -326
- data/docs/tmp.md +0 -2
- data/lib/sort_prof.rb +0 -22
- data/tests/bugs/links.md +0 -47
- data/tests/diagrams/diagrams.md +0 -302
- data/tests/s5/a.md +0 -13
- data/tests/s5/instiki+s5.md +0 -105
- data/tests/unittest/xml.md +0 -54
data/bin/maruku
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'maruku'
|
4
4
|
require 'optparse'
|
5
5
|
|
6
|
+
|
6
7
|
def cli_puts(s)
|
7
8
|
$stderr.puts(s) if MaRuKu::Globals[:verbose]
|
8
9
|
end
|
@@ -57,6 +58,10 @@ opt = OptionParser.new do |opts|
|
|
57
58
|
puts "Maruku #{MaRuKu::Version}"; exit
|
58
59
|
end
|
59
60
|
|
61
|
+
opts.on_tail("--ext EXTENSIONS", "Use maruku extensions (comma separated)" ) do |s|
|
62
|
+
s.split(",").each do |e| require "maruku/ext/#{e}"; end
|
63
|
+
end
|
64
|
+
|
60
65
|
opts.on_tail("-h", "--help", "Show this message") do
|
61
66
|
puts opts
|
62
67
|
exit
|
@@ -131,7 +136,7 @@ inputs.each do |f, input|
|
|
131
136
|
suffix='.pretty_md'
|
132
137
|
out = doc.to_markdown
|
133
138
|
when :s5
|
134
|
-
suffix='_s5slides.
|
139
|
+
suffix='_s5slides.html'
|
135
140
|
out = doc.to_s5({:content_only => false})
|
136
141
|
end
|
137
142
|
|
data/bin/marutest
CHANGED
@@ -189,27 +189,34 @@ def run_test(filename, its_ok, verbose=true)
|
|
189
189
|
end
|
190
190
|
|
191
191
|
|
192
|
-
|
192
|
+
if false
|
193
|
+
md_pl = markdown_pl(markdown)
|
193
194
|
|
194
|
-
|
195
|
-
|
195
|
+
f.write "\n*** Output of Markdown.pl ***\n"
|
196
|
+
f.write md_pl
|
196
197
|
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
198
|
+
f.write "\n*** Output of Markdown.pl (parsed) ***\n"
|
199
|
+
begin
|
200
|
+
doc = REXML::Document.new("<div>#{md_pl}</div>",{
|
201
|
+
:compress_whitespace=>['div','p'],
|
202
|
+
:ignore_whitespace_nodes=>['div','p'],
|
203
|
+
:respect_whitespace=>['pre','code']
|
204
|
+
})
|
205
|
+
div = doc.root
|
206
|
+
xml =""
|
207
|
+
div.write_children(xml,indent=1,transitive=true,ie_hack=false)
|
208
|
+
f.write xml
|
209
|
+
rescue Exception=>e
|
210
|
+
f.puts "Error: #{e.inspect}"
|
211
|
+
end
|
212
|
+
f.close
|
213
|
+
else
|
214
|
+
f.write "\n*** Output of Markdown.pl ***\n"
|
215
|
+
f.write "(not used anymore)"
|
212
216
|
|
217
|
+
f.write "\n*** Output of Markdown.pl (parsed) ***\n"
|
218
|
+
f.write "(not used anymore)"
|
219
|
+
end
|
213
220
|
|
214
221
|
return failed, relaxed, crashed
|
215
222
|
end
|
data/lib/maruku.rb
CHANGED
data/lib/maruku/ext/div.rb
CHANGED
@@ -1,7 +1,20 @@
|
|
1
1
|
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
#+-----------------------------------{.warning}------
|
4
|
+
#| this is the last warning!
|
5
|
+
#|
|
6
|
+
#| please, go away!
|
7
|
+
#|
|
8
|
+
#| +------------------------------------- {.menace} --
|
9
|
+
#| | or else terrible things will happen
|
10
|
+
#| +--------------------------------------------------
|
11
|
+
#+---------------------------------------------------
|
12
|
+
|
13
|
+
OpenDiv = /^[ ]{0,3}\+\-\-+\s*(\{([^{}]*|".*"|'.*')*\})?\s*\-*\s*$/
|
14
|
+
CloseDiv = /^[ ]{0,3}\=\-\-+\s*(\{([^{}]*|".*"|'.*')*\})?\s*\-*\s*$/
|
15
|
+
# note these are not enough for parsing the above example:
|
16
|
+
#OpenDiv = /^[ ]{0,3}\+\-\-+\s*(.*)$/
|
17
|
+
#CloseDiv = /^[ ]{0,3}\=\-\-+\s*(.*)$/
|
5
18
|
StartPipe = /^[ ]{0,3}\|(.*)$/ # $1 is rest of line
|
6
19
|
DecorativeClosing = OpenDiv
|
7
20
|
|
@@ -67,7 +80,7 @@ MaRuKu::In::Markdown::register_block_extension(
|
|
67
80
|
al_string = ial_at_beginning || ial_at_end
|
68
81
|
al = nil
|
69
82
|
|
70
|
-
if al_string =~ /^\{(.*)\}
|
83
|
+
if al_string =~ /^\{(.*)\}\s*$/
|
71
84
|
inside = $1
|
72
85
|
cs = MaRuKu::In::Markdown::SpanLevelParser::CharSource
|
73
86
|
al = al_string &&
|
@@ -84,8 +97,28 @@ MaRuKu::In::Markdown::register_block_extension(
|
|
84
97
|
|
85
98
|
module MaRuKu; class MDElement
|
86
99
|
|
87
|
-
def md_div(children,
|
88
|
-
|
100
|
+
def md_div(children, al=nil)
|
101
|
+
type = label = num = nil
|
102
|
+
doc.refid2ref ||= {}
|
103
|
+
if al
|
104
|
+
al.each do |k, v|
|
105
|
+
case k
|
106
|
+
when :class
|
107
|
+
type = $1 if v =~ /^num_(\w*)/
|
108
|
+
when :id
|
109
|
+
label = v
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
if type
|
114
|
+
doc.refid2ref[type] ||= {}
|
115
|
+
num = doc.refid2ref[type].length + 1 || 1
|
116
|
+
end
|
117
|
+
e = self.md_el(:div, children, meta={:label => label, :type => type, :num => num}, al)
|
118
|
+
if type && label
|
119
|
+
doc.refid2ref[type].update({label => e})
|
120
|
+
end
|
121
|
+
e
|
89
122
|
end
|
90
123
|
|
91
124
|
end end
|
@@ -97,4 +130,4 @@ module MaRuKu; module Out; module HTML
|
|
97
130
|
add_ws wrap_as_element('div')
|
98
131
|
end
|
99
132
|
|
100
|
-
end end end
|
133
|
+
end end end
|
@@ -10,23 +10,24 @@ module MaRuKu; module Out; module HTML
|
|
10
10
|
|
11
11
|
def convert_to_png_blahtex(kind, tex)
|
12
12
|
begin
|
13
|
-
FileUtils::mkdir_p
|
13
|
+
FileUtils::mkdir_p get_setting(:html_png_dir)
|
14
14
|
|
15
15
|
# first, we check whether this image has already been processed
|
16
16
|
md5sum = Digest::MD5.hexdigest(tex+" params: ")
|
17
|
-
result_file = File.join(
|
17
|
+
result_file = File.join(get_setting(:html_png_dir), md5sum+".txt")
|
18
18
|
|
19
19
|
if not File.exists?(result_file)
|
20
20
|
tmp_in = Tempfile.new('maruku_blahtex')
|
21
|
-
|
21
|
+
f = tmp_in.open
|
22
22
|
f.write tex
|
23
23
|
f.close
|
24
24
|
|
25
25
|
resolution = get_setting(:html_png_resolution)
|
26
26
|
|
27
|
-
options = "--png --use-preview-package --shell-dvipng '
|
28
|
-
options +=
|
29
|
-
options += ("--
|
27
|
+
options = "--png --use-preview-package --shell-dvipng 'dvipng -D #{resolution}' "
|
28
|
+
options += "--displaymath " if kind == :equation
|
29
|
+
options += ("--temp-directory '%s' " % get_setting(:html_png_dir))
|
30
|
+
options += ("--png-directory '%s'" % get_setting(:html_png_dir))
|
30
31
|
|
31
32
|
cmd = "blahtex #{options} < #{tmp_in.path} > #{result_file}"
|
32
33
|
#$stderr.puts "$ #{cmd}"
|
@@ -52,7 +53,7 @@ module MaRuKu; module Out; module HTML
|
|
52
53
|
height = height.text.to_f # XXX check != 0
|
53
54
|
md5 = md5.text
|
54
55
|
|
55
|
-
dir_url =
|
56
|
+
dir_url = get_setting(:html_png_url)
|
56
57
|
return PNG.new("#{dir_url}#{md5}.png", depth, height)
|
57
58
|
rescue Exception => e
|
58
59
|
maruku_error "Error: #{e}"
|
@@ -62,7 +63,7 @@ module MaRuKu; module Out; module HTML
|
|
62
63
|
|
63
64
|
|
64
65
|
def convert_to_mathml_blahtex(kind, tex)
|
65
|
-
@@BlahtexCache = PStore.new(
|
66
|
+
@@BlahtexCache = PStore.new(get_setting(:latex_cache_file))
|
66
67
|
|
67
68
|
begin
|
68
69
|
@@BlahtexCache.transaction do
|
@@ -2,7 +2,7 @@ module MaRuKu
|
|
2
2
|
|
3
3
|
class MDDocument
|
4
4
|
# Hash equation id (String) to equation element (MDElement)
|
5
|
-
|
5
|
+
safe_attr_accessor :eqid2eq, Hash
|
6
6
|
|
7
7
|
def is_math_enabled?
|
8
8
|
get_setting :math_enabled
|
@@ -103,3 +103,17 @@ end
|
|
103
103
|
true
|
104
104
|
}
|
105
105
|
)
|
106
|
+
|
107
|
+
# This adds support for \ref
|
108
|
+
RegRef = /\\ref\{(\w*)\}/
|
109
|
+
MaRuKu::In::Markdown::register_span_extension(
|
110
|
+
:chars => [?\\, ?(],
|
111
|
+
:regexp => RegRef,
|
112
|
+
:handler => lambda { |doc, src, con|
|
113
|
+
return false if not doc.is_math_enabled?
|
114
|
+
refid = src.read_regexp(RegRef).captures.compact.first
|
115
|
+
r = doc.md_el(:divref, [], meta={:refid=>refid})
|
116
|
+
con.push r
|
117
|
+
true
|
118
|
+
}
|
119
|
+
)
|
@@ -90,7 +90,7 @@ module MaRuKu; module Out; module HTML
|
|
90
90
|
img = Element.new 'img'
|
91
91
|
img.attributes['src'] = src
|
92
92
|
img.attributes['style'] = style
|
93
|
-
img.attributes['alt'] = "
|
93
|
+
img.attributes['alt'] = "$#{self.math.strip}$"
|
94
94
|
img
|
95
95
|
end
|
96
96
|
|
@@ -103,7 +103,7 @@ module MaRuKu; module Out; module HTML
|
|
103
103
|
|
104
104
|
if mathml
|
105
105
|
add_class_to(mathml, 'maruku-mathml')
|
106
|
-
|
106
|
+
return mathml
|
107
107
|
end
|
108
108
|
|
109
109
|
if png
|
@@ -121,15 +121,6 @@ module MaRuKu; module Out; module HTML
|
|
121
121
|
|
122
122
|
div = create_html_element 'div'
|
123
123
|
add_class_to(div, 'maruku-equation')
|
124
|
-
if self.label # then numerate
|
125
|
-
span = Element.new 'span'
|
126
|
-
span.attributes['class'] = 'maruku-eq-number'
|
127
|
-
num = self.num
|
128
|
-
span << Text.new("(#{num})")
|
129
|
-
div << span
|
130
|
-
div.attributes['id'] = "eq:#{self.label}"
|
131
|
-
end
|
132
|
-
|
133
124
|
if mathml
|
134
125
|
add_class_to(mathml, 'maruku-mathml')
|
135
126
|
div << mathml
|
@@ -141,12 +132,21 @@ module MaRuKu; module Out; module HTML
|
|
141
132
|
div << img
|
142
133
|
end
|
143
134
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
div <<
|
135
|
+
source_span = Element.new 'span'
|
136
|
+
add_class_to(source_span, 'maruku-eq-tex')
|
137
|
+
code = convert_to_mathml_none(:equation, self.math.strip)
|
138
|
+
code.attributes['style'] = 'display: none'
|
139
|
+
source_span << code
|
140
|
+
div << source_span
|
141
|
+
|
142
|
+
if self.label # then numerate
|
143
|
+
span = Element.new 'span'
|
144
|
+
span.attributes['class'] = 'maruku-eq-number'
|
145
|
+
num = self.num
|
146
|
+
span << Text.new("(#{num})")
|
147
|
+
div << span
|
148
|
+
div.attributes['id'] = "eq:#{self.label}"
|
149
|
+
end
|
150
150
|
div
|
151
151
|
end
|
152
152
|
|
@@ -164,6 +164,23 @@ module MaRuKu; module Out; module HTML
|
|
164
164
|
end
|
165
165
|
end
|
166
166
|
|
167
|
+
def to_html_divref
|
168
|
+
ref= nil
|
169
|
+
self.doc.refid2ref.each_value { |h|
|
170
|
+
ref = h[self.refid] if h.has_key?(self.refid)
|
171
|
+
}
|
172
|
+
if ref
|
173
|
+
num = ref.num
|
174
|
+
a = Element.new 'a'
|
175
|
+
a.attributes['class'] = 'maruku-ref'
|
176
|
+
a.attributes['href'] = "#" + self.refid
|
177
|
+
a << Text.new(num.to_s)
|
178
|
+
a
|
179
|
+
else
|
180
|
+
maruku_error "Cannot find div #{self.refid.inspect}"
|
181
|
+
Text.new "\\ref{#{self.refid}}"
|
182
|
+
end
|
183
|
+
end
|
167
184
|
|
168
185
|
end end end
|
169
186
|
|
data/lib/maruku/helpers.rb
CHANGED
@@ -91,10 +91,10 @@ module Helpers
|
|
91
91
|
raw_html = "<marukuwrap>#{raw_html}</marukuwrap>"
|
92
92
|
e.instance_variable_set :@parsed_html,
|
93
93
|
REXML::Document.new(raw_html)
|
94
|
-
rescue
|
94
|
+
rescue REXML::ParseException => ex
|
95
95
|
e.instance_variable_set :@parsed_html, nil
|
96
|
-
|
97
|
-
|
96
|
+
maruku_recover "REXML cannot parse this block of HTML/XML:\n"+
|
97
|
+
add_tabs(raw_html,1,'|') + "\n"+ex.inspect
|
98
98
|
# " #{raw_html.inspect}\n\n"+ex.inspect
|
99
99
|
end
|
100
100
|
e
|
@@ -198,14 +198,17 @@ Disabled by default because of security concerns.
|
|
198
198
|
XPath.match(doc, "//*[attribute::markdown]" ).each do |e|
|
199
199
|
# puts "Found #{e}"
|
200
200
|
# should we parse block-level or span-level?
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
201
|
+
|
202
|
+
how = e.attributes['markdown']
|
203
|
+
parse_blocks = (how == 'block') || block_tags.include?(e.name)
|
204
|
+
|
205
205
|
# Select all text elements of e
|
206
206
|
XPath.match(e, "//text()" ).each { |original_text|
|
207
207
|
s = original_text.value.strip
|
208
208
|
if s.size > 0
|
209
|
+
|
210
|
+
# puts "Parsing #{s.inspect} as blocks: #{parse_blocks} (#{e.name}, #{e.attributes['markdown']}) "
|
211
|
+
|
209
212
|
el = md_el(:dummy,
|
210
213
|
parse_blocks ? parse_text_as_markdown(s) :
|
211
214
|
parse_lines_as_span([s]) )
|
@@ -217,7 +220,11 @@ Disabled by default because of security concerns.
|
|
217
220
|
|
218
221
|
end
|
219
222
|
}
|
220
|
-
|
223
|
+
|
224
|
+
|
225
|
+
# remove 'markdown' attribute
|
226
|
+
e.delete_attribute 'markdown'
|
227
|
+
|
221
228
|
end
|
222
229
|
|
223
230
|
end
|
@@ -185,15 +185,27 @@ module MaRuKu; module In; module Markdown; module SpanLevelParser
|
|
185
185
|
maruku_recover "Threating as literal", src, con
|
186
186
|
con.push_char src.shift_char
|
187
187
|
else
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
188
|
+
# we don't want "mod_ruby" to start an emphasis
|
189
|
+
# so we start one only if
|
190
|
+
# 1) there's nothing else in the span (first char)
|
191
|
+
# or 2) the last char was a space
|
192
|
+
# or 3) the current string is empty
|
193
|
+
#if con.elements.empty? ||
|
194
|
+
if (con.cur_string =~ /\s\Z/) || (con.cur_string.size == 0)
|
195
|
+
# also, we check the next characters
|
196
|
+
follows = src.cur_chars(4)
|
197
|
+
if follows =~ /^\_\_\_[^\s\_]/
|
198
|
+
con.push_element read_emstrong(src,'___')
|
199
|
+
elsif follows =~ /^\_\_[^\s\_]/
|
200
|
+
con.push_element read_strong(src,'__')
|
201
|
+
elsif follows =~ /^\_[^\s\_]/
|
202
|
+
con.push_element read_em(src,'_')
|
203
|
+
else # _ is just a normal char
|
204
|
+
con.push_char src.shift_char
|
205
|
+
end
|
206
|
+
else
|
207
|
+
# _ is just a normal char
|
208
|
+
con.push_char src.shift_char
|
197
209
|
end
|
198
210
|
end
|
199
211
|
when ?{ # extension
|
@@ -430,7 +442,8 @@ module MaRuKu; module In; module Markdown; module SpanLevelParser
|
|
430
442
|
SPACE = ?\ # = 32
|
431
443
|
|
432
444
|
# R_REF_ID = Regexp.compile(/([^\]\s]*)(\s*\])/)
|
433
|
-
R_REF_ID = Regexp.compile(/([^\]\s]*)(\s*\])/)
|
445
|
+
# R_REF_ID = Regexp.compile(/([^\]\s]*)(\s*\])/)
|
446
|
+
R_REF_ID = Regexp.compile(/([^\]]*)\]/)
|
434
447
|
|
435
448
|
# Reads a bracketed id "[refid]". Consumes also both brackets.
|
436
449
|
def read_ref_id(src, con)
|
@@ -696,6 +709,7 @@ module MaRuKu; module In; module Markdown; module SpanLevelParser
|
|
696
709
|
end
|
697
710
|
end
|
698
711
|
end
|
712
|
+
|
699
713
|
def push_string_if_present
|
700
714
|
if @cur_string.size > 0
|
701
715
|
@elements << @cur_string
|