maruku 0.5.3 → 0.5.4
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.
- data/bin/maruku +14 -6
- data/bin/marutest +19 -10
- data/docs/changelog.html +49 -8
- data/docs/changelog.md +26 -1
- data/docs/entity_test.html +1 -1
- data/docs/exd.html +43 -24
- data/docs/index.html +4 -6
- data/docs/markdown_syntax.html +81 -170
- data/docs/maruku.html +4 -6
- data/docs/maruku.md +1 -1
- data/docs/proposal.html +21 -41
- data/lib/maruku.rb +5 -0
- data/lib/maruku/attributes.rb +3 -2
- data/lib/maruku/defaults.rb +3 -1
- data/lib/maruku/ext/math.rb +30 -0
- data/lib/maruku/ext/math/elements.rb +3 -2
- data/lib/maruku/ext/math/parsing.rb +81 -58
- data/lib/maruku/ext/math/to_html.rb +5 -5
- data/lib/maruku/helpers.rb +2 -0
- data/lib/maruku/input/charsource.rb +1 -1
- data/lib/maruku/input/extensions.rb +6 -5
- data/lib/maruku/input/parse_block.rb +7 -8
- data/lib/maruku/input/parse_doc.rb +1 -1
- data/lib/maruku/input/parse_span_better.rb +4 -4
- data/lib/maruku/input_textile2/t2_parser.rb +163 -0
- data/lib/maruku/maruku.rb +1 -1
- data/lib/maruku/output/s5/fancy.rb +756 -0
- data/lib/maruku/output/s5/to_s5.rb +104 -0
- data/lib/maruku/output/to_html.rb +103 -49
- data/lib/maruku/string_utils.rb +1 -1
- data/lib/maruku/textile2.rb +1 -0
- data/lib/maruku/version.rb +3 -1
- data/maruku_gem.rb +33 -0
- data/tests/s5/s5profiling.md +48 -0
- data/tests/unittest/blanks_in_code.md +6 -12
- data/tests/unittest/code3.md +3 -5
- data/tests/unittest/data_loss.md +53 -0
- data/tests/unittest/email.md +2 -2
- data/tests/unittest/entities.md +3 -5
- data/tests/unittest/footnotes.md +5 -5
- data/tests/unittest/ie.md +1 -1
- data/tests/unittest/images.md +2 -2
- data/tests/unittest/inline_html.md +6 -10
- data/tests/unittest/links.md +1 -1
- data/tests/unittest/list2.md +5 -5
- data/tests/unittest/lists.md +13 -13
- data/tests/unittest/lists_ol.md +13 -13
- data/tests/unittest/math/math2.md +84 -0
- data/tests/unittest/math/notmath.md +48 -0
- data/tests/unittest/syntax_hl.md +3 -5
- metadata +11 -2
data/docs/maruku.html
CHANGED
@@ -13,7 +13,7 @@
|
|
13
13
|
<p><a href='http://maruku.rubyforge.org/'>Maruku</a> is a Markdown interpreter written in <a href='http://www.ruby-lang.org'>Ruby</a>.</p>
|
14
14
|
|
15
15
|
<blockquote id='news'>
|
16
|
-
<p><a href='#release_notes'>Last release</a> is version 0.5.
|
16
|
+
<p><a href='#release_notes'>Last release</a> is version 0.5.4 – 2007-02-18.</p>
|
17
17
|
|
18
18
|
<p>Use this command to update:</p>
|
19
19
|
|
@@ -134,8 +134,7 @@
|
|
134
134
|
|
135
135
|
<pre><code>BlueCloth (to_html): parsing 0.01 sec + rendering 1.87 sec = 1.88 sec (1.00x)
|
136
136
|
Maruku (to_html): parsing 0.66 sec + rendering 0.43 sec = 1.09 sec (1.73x)
|
137
|
-
Maruku (to_latex): parsing 0.67 sec + rendering 0.23 sec = 0.90 sec (2.10x)
|
138
|
-
</code></pre>
|
137
|
+
Maruku (to_latex): parsing 0.67 sec + rendering 0.23 sec = 0.90 sec (2.10x)</code></pre>
|
139
138
|
|
140
139
|
<p>Please note that Maruku has a lot more features and therefore is looking for much more patterns in the file.</p>
|
141
140
|
|
@@ -233,8 +232,7 @@ Content of the document</code></pre>
|
|
233
232
|
<p>If you create a list, and then set the <code>toc</code> attribute, when rendering Maruku will create an auto-generated table of contents.</p>
|
234
233
|
|
235
234
|
<pre><code>* This will become a table of contents (this text will be scraped).
|
236
|
-
{:toc}
|
237
|
-
</code></pre>
|
235
|
+
{:toc}</code></pre>
|
238
236
|
|
239
237
|
<p>You can see an example of this at the beginning of this document.</p>
|
240
238
|
|
@@ -323,4 +321,4 @@ I would love to have an equivalent in Ruby.
|
|
323
321
|
|
324
322
|
--><div class='footnotes'><hr /><ol><li id='fn:1'>
|
325
323
|
<p>I really was missing those.</p>
|
326
|
-
<a href='#fnref:1' rev='footnote'>↩</a></li></ol></div><div class='maruku_signature'><hr /><span style='font-size: small; font-style: italic'>Created by <a href='http://maruku.rubyforge.org' title='Maruku: a Markdown-superset interpreter for Ruby'>Maruku</a> at
|
324
|
+
<a href='#fnref:1' rev='footnote'>↩</a></li></ol></div><div class='maruku_signature'><hr /><span style='font-size: small; font-style: italic'>Created by <a href='http://maruku.rubyforge.org' title='Maruku: a Markdown-superset interpreter for Ruby'>Maruku</a> at 13:32 on Sunday, February 18th, 2007.</span></div></body></html>
|
data/docs/maruku.md
CHANGED
@@ -13,7 +13,7 @@ Mar**u**k**u**: a Markdown-superset interpreter
|
|
13
13
|
|
14
14
|
[Maruku] is a Markdown interpreter written in [Ruby].
|
15
15
|
|
16
|
-
> [Last release](#release_notes) is version 0.5.
|
16
|
+
> [Last release](#release_notes) is version 0.5.4 -- 2007-02-18.
|
17
17
|
>
|
18
18
|
> Use this command to update:
|
19
19
|
>
|
data/docs/proposal.html
CHANGED
@@ -20,20 +20,17 @@
|
|
20
20
|
|
21
21
|
<p>The first character in the curly braces must be a colon, optionally followed by a space:</p>
|
22
22
|
|
23
|
-
<pre><code>{: ref .class #id}
|
24
|
-
</code></pre>
|
23
|
+
<pre><code>{: ref .class #id}</code></pre>
|
25
24
|
|
26
25
|
<p>The old syntax was <code>{ref .class #id}</code>.</p>
|
27
26
|
|
28
27
|
<p>For ALDs, the new syntax is:</p>
|
29
28
|
|
30
|
-
<pre><code>{:ref_id: key=val .class #id }
|
31
|
-
</code></pre>
|
29
|
+
<pre><code>{:ref_id: key=val .class #id }</code></pre>
|
32
30
|
|
33
31
|
<p>instead of:</p>
|
34
32
|
|
35
|
-
<pre><code>{ref_id}: key=val .class #id
|
36
|
-
</code></pre>
|
33
|
+
<pre><code>{ref_id}: key=val .class #id </code></pre>
|
37
34
|
|
38
35
|
<p>Converters that don’t use this syntax may just ignore everything which is in curly braces and starts with ”:”.</p>
|
39
36
|
</li>
|
@@ -44,8 +41,7 @@
|
|
44
41
|
<pre><code>Paragraph 1
|
45
42
|
|
46
43
|
{:par2}
|
47
|
-
Paragraph 2
|
48
|
-
</code></pre>
|
44
|
+
Paragraph 2</code></pre>
|
49
45
|
|
50
46
|
<p>is equivalent to:</p>
|
51
47
|
|
@@ -88,8 +84,7 @@ Paragraph 2
|
|
88
84
|
|
89
85
|
Paragraph *with emphasis*{: class=c1}
|
90
86
|
second line of paragraph
|
91
|
-
{: class=c1}
|
92
|
-
</code></pre>
|
87
|
+
{: class=c1}</code></pre>
|
93
88
|
|
94
89
|
<p>In this example, the three IALs refer to the header, the emphasis span, and the entire paragraph, respectively.</p>
|
95
90
|
|
@@ -101,15 +96,13 @@ Paragraph *with emphasis*{:c1}
|
|
101
96
|
second line of paragraph
|
102
97
|
{:c1}
|
103
98
|
|
104
|
-
{:c1: class=c1}
|
105
|
-
</code></pre>
|
99
|
+
{:c1: class=c1}</code></pre>
|
106
100
|
|
107
101
|
<h2 id='attribute_lists'><span class='maruku_section_number'>2. </span>Attribute lists</h2>
|
108
102
|
|
109
103
|
<p>This is an example attribute list, which shows everything you can put inside:</p>
|
110
104
|
|
111
|
-
<pre><code>{: key1=val key2="long val" #myid .class1 .class2 ref1 ref2}
|
112
|
-
</code></pre>
|
105
|
+
<pre><code>{: key1=val key2="long val" #myid .class1 .class2 ref1 ref2}</code></pre>
|
113
106
|
|
114
107
|
<p>More in particular, an attribute list is a whitespace-separated list of elements of 4 different kinds:</p>
|
115
108
|
|
@@ -147,8 +140,7 @@ second line of paragraph
|
|
147
140
|
<pre><code>{: #myid .class1 .class2}
|
148
141
|
{: id=myid class=class1 .class2}
|
149
142
|
{: id=myid class="class1 class2"}
|
150
|
-
{: id=myid class="will be overridden" class=class1 .class2}
|
151
|
-
</code></pre>
|
143
|
+
{: id=myid class="will be overridden" class=class1 .class2}</code></pre>
|
152
144
|
|
153
145
|
<h2 id='where_to_put_inline_attribute_lists'><span class='maruku_section_number'>3. </span>Where to put inline attribute lists</h2>
|
154
146
|
|
@@ -162,16 +154,14 @@ Line 2 of the paragraph.
|
|
162
154
|
|
163
155
|
A quote with a citation url:
|
164
156
|
> Who said that?
|
165
|
-
{: cite=google.com}
|
166
|
-
</code></pre>
|
157
|
+
{: cite=google.com}</code></pre>
|
167
158
|
|
168
159
|
<p>Note: empty lines between the block and the IAL are not tolerated. So this is not legal:</p>
|
169
160
|
|
170
161
|
<pre><code>This is a paragraph.
|
171
162
|
Line 2 of the paragraph.
|
172
163
|
|
173
|
-
{: #myid .myclass}
|
174
|
-
</code></pre>
|
164
|
+
{: #myid .myclass}</code></pre>
|
175
165
|
|
176
166
|
<p>Attribute lists may be indented up to 3 spaces:</p>
|
177
167
|
|
@@ -191,8 +181,7 @@ Paragraph2
|
|
191
181
|
<pre><code>### Header ### {: #myid}
|
192
182
|
|
193
183
|
Header {: #myid .myclass}
|
194
|
-
|
195
|
-
</code></pre>
|
184
|
+
------</code></pre>
|
196
185
|
|
197
186
|
<p>or, as like other block-level elements, on the line below:</p>
|
198
187
|
|
@@ -201,8 +190,7 @@ Header {: #myid .myclass}
|
|
201
190
|
|
202
191
|
Header
|
203
192
|
------
|
204
|
-
{: #myid .myclass}
|
205
|
-
</code></pre>
|
193
|
+
{: #myid .myclass}</code></pre>
|
206
194
|
|
207
195
|
<h3 id='for_spanlevel_elements'><span class='maruku_section_number'>3.3. </span>For span-level elements</h3>
|
208
196
|
|
@@ -217,18 +205,15 @@ Header
|
|
217
205
|
|
218
206
|
<p>This works also for links, like this:</p>
|
219
207
|
|
220
|
-
<pre><code>This is [a link][ref]{:#myid rel=abc rev=abc}
|
221
|
-
</code></pre>
|
208
|
+
<pre><code>This is [a link][ref]{:#myid rel=abc rev=abc}</code></pre>
|
222
209
|
|
223
210
|
<p>For images, this:</p>
|
224
211
|
|
225
|
-
<pre><code>This is 
|
226
|
-
</code></pre>
|
212
|
+
<pre><code>This is </code></pre>
|
227
213
|
|
228
214
|
<p>is equivalent to:</p>
|
229
215
|
|
230
|
-
<pre><code>This is {:title="fresh carrots"}
|
231
|
-
</code></pre>
|
216
|
+
<pre><code>This is {:title="fresh carrots"}</code></pre>
|
232
217
|
|
233
218
|
<h2 id='using_tags'><span class='maruku_section_number'>4. </span>Using attributes lists definition</h2>
|
234
219
|
|
@@ -248,8 +233,7 @@ Header
|
|
248
233
|
|
249
234
|
Blah blah blah.
|
250
235
|
|
251
|
-
{:ref: #myhead .myclass lang=fr}
|
252
|
-
</code></pre>
|
236
|
+
{:ref: #myhead .myclass lang=fr}</code></pre>
|
253
237
|
|
254
238
|
<p>Of course, more than one IAL can reference the same ALD:</p>
|
255
239
|
|
@@ -257,9 +241,7 @@ Blah blah blah.
|
|
257
241
|
...
|
258
242
|
# Header 2 # {:1}
|
259
243
|
|
260
|
-
{:1: .myclass lang=fr}
|
261
|
-
|
262
|
-
</code></pre>
|
244
|
+
{:1: .myclass lang=fr}</code></pre>
|
263
245
|
|
264
246
|
<h2 id='the_rules'><span class='maruku_section_number'>5. </span>The rules</h2>
|
265
247
|
|
@@ -271,7 +253,7 @@ Blah blah blah.
|
|
271
253
|
</li>
|
272
254
|
|
273
255
|
<li>
|
274
|
-
<p>Everywhere else, <strong>all</strong> PUNCTUATION characters <strong>can</strong> be escaped, and <strong>must</strong> be escaped when they could trigger links, tables, etc
|
256
|
+
<p>Everywhere else, <strong>all</strong> PUNCTUATION characters <strong>can</strong> be escaped, and <strong>must</strong> be escaped when they could trigger links, tables, etc.</p>
|
275
257
|
|
276
258
|
<p>A punctuation character is anything not a letter, a number, or whitespace (<code>[^a-zA-Z0-9\s\n]</code>).</p>
|
277
259
|
</li>
|
@@ -301,8 +283,7 @@ Blah blah blah.
|
|
301
283
|
<li>
|
302
284
|
<p>There is an exception for backward compatibility, in links/images titles:</p>
|
303
285
|
|
304
|
-
<pre><code>[text](url "title"with"quotes")
|
305
|
-
</code></pre>
|
286
|
+
<pre><code>[text](url "title"with"quotes")</code></pre>
|
306
287
|
|
307
288
|
<p>The exception is not valid for attribute lists and in other contexts, where you have to use the canonical syntax.</p>
|
308
289
|
</li>
|
@@ -334,8 +315,7 @@ s.gsub(r, '') # ignore metadata</code></pre>
|
|
334
315
|
{: skipped="\}" val=\} bar}
|
335
316
|
|
336
317
|
for me
|
337
|
-
{: also this}
|
338
|
-
</code></pre>
|
318
|
+
{: also this} </code></pre>
|
339
319
|
|
340
320
|
<p>the result is:</p>
|
341
321
|
|
@@ -343,4 +323,4 @@ for me
|
|
343
323
|
|
344
324
|
|
345
325
|
for me </code></pre>
|
346
|
-
<div class='maruku_signature'><hr /><span style='font-size: small; font-style: italic'>Created by <a href='http://maruku.rubyforge.org' title='Maruku: a Markdown-superset interpreter for Ruby'>Maruku</a> at
|
326
|
+
<div class='maruku_signature'><hr /><span style='font-size: small; font-style: italic'>Created by <a href='http://maruku.rubyforge.org' title='Maruku: a Markdown-superset interpreter for Ruby'>Maruku</a> at 13:32 on Sunday, February 18th, 2007.</span></div></body></html>
|
data/lib/maruku.rb
CHANGED
@@ -126,8 +126,13 @@ require 'maruku/output/to_latex_entities'
|
|
126
126
|
# Pretty print
|
127
127
|
require 'maruku/output/to_markdown'
|
128
128
|
|
129
|
+
# S5 slides
|
130
|
+
require 'maruku/output/s5/to_s5'
|
131
|
+
require 'maruku/output/s5/fancy'
|
132
|
+
|
129
133
|
# Exporting to text: strips all formatting (not complete)
|
130
134
|
require 'maruku/output/to_s'
|
131
135
|
|
132
136
|
# class Maruku is the global interface
|
133
137
|
require 'maruku/maruku'
|
138
|
+
|
data/lib/maruku/attributes.rb
CHANGED
@@ -192,9 +192,10 @@ module MaRuKu; module In; module Markdown; module SpanLevelParser
|
|
192
192
|
end
|
193
193
|
|
194
194
|
|
195
|
+
# We need a helper
|
196
|
+
def is_ial(e); e.kind_of? MDElement and e.node_type == :ial end
|
197
|
+
|
195
198
|
def merge_ial(elements, src, con)
|
196
|
-
# We need a helper
|
197
|
-
def is_ial(e); e.kind_of? MDElement and e.node_type == :ial end
|
198
199
|
|
199
200
|
# Apply each IAL to the element before
|
200
201
|
elements.each_with_index do |e, i|
|
data/lib/maruku/defaults.rb
CHANGED
@@ -31,8 +31,10 @@ Globals = {
|
|
31
31
|
:maruku_signature => true,
|
32
32
|
:code_background_color => '#fef',
|
33
33
|
:code_show_spaces => false,
|
34
|
+
:html_math_output_mathml => true, # also set :html_math_engine
|
34
35
|
:html_math_engine => 'none', #ritex, itex2mml
|
35
36
|
|
37
|
+
:html_math_output_png => false,
|
36
38
|
:html_png_engine => 'none',
|
37
39
|
:html_png_dir => 'pngs',
|
38
40
|
:html_png_url => 'pngs/',
|
@@ -44,7 +46,7 @@ Globals = {
|
|
44
46
|
:latex_cjk => false,
|
45
47
|
|
46
48
|
:debug_keep_ials => false,
|
47
|
-
|
49
|
+
:doc_prefix => ''
|
48
50
|
}
|
49
51
|
|
50
52
|
class MDElement
|
data/lib/maruku/ext/math.rb
CHANGED
@@ -9,3 +9,33 @@ require 'maruku/ext/math/mathml_engines/none'
|
|
9
9
|
require 'maruku/ext/math/mathml_engines/ritex'
|
10
10
|
require 'maruku/ext/math/mathml_engines/itex2mml'
|
11
11
|
require 'maruku/ext/math/mathml_engines/blahtex'
|
12
|
+
|
13
|
+
|
14
|
+
=begin maruku_doc
|
15
|
+
Attribute: math_enabled
|
16
|
+
Scope: global, document
|
17
|
+
Summary: Enables parsing of LaTeX math
|
18
|
+
|
19
|
+
To explicitly disable the math parsing:
|
20
|
+
|
21
|
+
Maruku.new(string, {:math_enabled => false})
|
22
|
+
{:ruby}
|
23
|
+
|
24
|
+
=end
|
25
|
+
|
26
|
+
MaRuKu::Globals[:math_enabled] = true
|
27
|
+
|
28
|
+
|
29
|
+
=begin maruku_doc
|
30
|
+
Attribute: math_numbered
|
31
|
+
Scope: global, document
|
32
|
+
Summary: Math openings which should be numerated
|
33
|
+
|
34
|
+
Array containing any of `'\\['`, `'\\begin{equation}'`, `'$$'`.
|
35
|
+
|
36
|
+
MaRuKu::Globals[math_numbered] = ['\\[']
|
37
|
+
|
38
|
+
=end
|
39
|
+
|
40
|
+
|
41
|
+
MaRuKu::Globals[:math_numbered] = []
|
@@ -4,7 +4,7 @@ module MaRuKu; class MDElement
|
|
4
4
|
self.md_el(:inline_math, [], meta={:math=>math})
|
5
5
|
end
|
6
6
|
|
7
|
-
def md_equation(math, label
|
7
|
+
def md_equation(math, label, numerate)
|
8
8
|
reglabel= /\\label\{(\w+)\}/
|
9
9
|
if math =~ reglabel
|
10
10
|
label = $1
|
@@ -12,9 +12,10 @@ module MaRuKu; class MDElement
|
|
12
12
|
end
|
13
13
|
# puts "Found label = #{label} math #{math.inspect} "
|
14
14
|
num = nil
|
15
|
-
if label && @doc #take number
|
15
|
+
if (label || numerate) && @doc #take number
|
16
16
|
@doc.eqid2eq ||= {}
|
17
17
|
num = @doc.eqid2eq.size + 1
|
18
|
+
label = "eq#{num}" if not label # FIXME do id for document
|
18
19
|
end
|
19
20
|
e = self.md_el(:equation, [], meta={:math=>math, :label=>label,:num=>num})
|
20
21
|
if label && @doc #take number
|
@@ -1,70 +1,90 @@
|
|
1
1
|
module MaRuKu
|
2
|
+
|
2
3
|
class MDDocument
|
3
4
|
# Hash equation id (String) to equation element (MDElement)
|
4
5
|
attr_accessor :eqid2eq
|
6
|
+
|
7
|
+
def is_math_enabled?
|
8
|
+
get_setting :math_enabled
|
9
|
+
end
|
5
10
|
end
|
6
11
|
end
|
7
12
|
|
8
13
|
|
9
|
-
# At least one slash inside
|
10
|
-
#RegInlineMath1 = /\$([^\$]*[\\][^\$]*)\$/
|
11
|
-
# No spaces around the delimiters
|
12
|
-
#RegInlineMath2 = /\$([^\s\$](?:[^\$]*[^\s\$])?)\$/
|
13
|
-
#RegInlineMath = Regexp::union(RegInlineMath1,RegInlineMath2)
|
14
|
-
|
15
14
|
# Everything goes; takes care of escaping the "\$" inside the expression
|
16
15
|
RegInlineMath = /\${1}((?:[^\$]|\\\$)+)\$/
|
17
16
|
|
18
|
-
MaRuKu::In::Markdown::
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
17
|
+
MaRuKu::In::Markdown::register_span_extension(
|
18
|
+
:chars => ?$,
|
19
|
+
:regexp => RegInlineMath,
|
20
|
+
:handler => lambda { |doc, src, con|
|
21
|
+
return false if not doc.is_math_enabled?
|
22
|
+
|
23
|
+
if m = src.read_regexp(RegInlineMath)
|
24
|
+
math = m.captures.compact.first
|
25
|
+
con.push doc.md_inline_math(math)
|
26
|
+
true
|
27
|
+
else
|
28
|
+
#puts "not math: #{src.cur_chars 10}"
|
29
|
+
false
|
30
|
+
end
|
31
|
+
}
|
32
|
+
)
|
33
|
+
|
30
34
|
|
31
|
-
|
35
|
+
MathOpen1 = Regexp.escape('\\begin{equation}')
|
36
|
+
MathClose1 = Regexp.escape('\\end{equation}')
|
37
|
+
MathOpen2 = Regexp.escape('\\[')
|
38
|
+
MathClose2 = Regexp.escape('\\]')
|
39
|
+
MathOpen3 = Regexp.escape('$$')
|
40
|
+
MathClose3 = Regexp.escape('$$')
|
32
41
|
|
33
42
|
EqLabel = /(?:\((\w+)\))/
|
34
|
-
|
35
|
-
|
43
|
+
EquationOpen = /#{MathOpen1}|#{MathOpen2}|#{MathOpen3}/
|
44
|
+
EquationClose = /#{MathClose1}|#{MathClose2}|#{MathClose3}/
|
45
|
+
|
46
|
+
# $1 is opening, $2 is tex
|
47
|
+
EquationStart = /^[ ]{0,3}(#{EquationOpen})(.*)$/
|
48
|
+
# $1 is tex, $2 is closing, $3 is tex
|
49
|
+
EquationEnd = /^(.*)(#{EquationClose})\s*#{EqLabel}?\s*$/
|
50
|
+
# $1 is opening, $2 is tex, $3 is closing, $4 is label
|
51
|
+
OneLineEquation = /^[ ]{0,3}(#{EquationOpen})(.*)(#{EquationClose})\s*#{EqLabel}?\s*$/
|
36
52
|
|
37
|
-
MaRuKu::In::Markdown::
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
53
|
+
MaRuKu::In::Markdown::register_block_extension(
|
54
|
+
:regexp => EquationStart,
|
55
|
+
:handler => lambda { |doc, src, con|
|
56
|
+
return false if not doc.is_math_enabled?
|
57
|
+
first = src.shift_line
|
58
|
+
if first =~ OneLineEquation
|
59
|
+
opening, tex, closing, label = $1, $2, $3, $4
|
60
|
+
numerate = doc.get_setting(:math_numbered).include?(opening)
|
61
|
+
con.push doc.md_equation(tex, label, numerate)
|
62
|
+
else
|
63
|
+
first =~ EquationStart
|
64
|
+
opening, tex = $1, $2
|
65
|
+
|
66
|
+
numerate = doc.get_setting(:math_numbered).include?(opening)
|
67
|
+
label = nil
|
68
|
+
while true
|
69
|
+
if not src.cur_line
|
70
|
+
doc.maruku_error("Stream finished while reading equation\n\n"+
|
71
|
+
doc.add_tabs(tex,1,'$> '), src, con)
|
72
|
+
break
|
73
|
+
end
|
74
|
+
line = src.shift_line
|
75
|
+
if line =~ EquationEnd
|
76
|
+
tex_line, closing = $1, $2
|
77
|
+
label = $3 if $3
|
78
|
+
tex += tex_line + "\n"
|
79
|
+
break
|
80
|
+
else
|
81
|
+
tex += line + "\n"
|
82
|
+
end
|
62
83
|
end
|
84
|
+
con.push doc.md_equation(tex, label, numerate)
|
63
85
|
end
|
64
|
-
|
65
|
-
|
66
|
-
true
|
67
|
-
end
|
86
|
+
true
|
87
|
+
})
|
68
88
|
|
69
89
|
|
70
90
|
# This adds support for \eqref
|
@@ -72,11 +92,14 @@ end
|
|
72
92
|
RegEqPar = /\(eq:(\w+)\)/
|
73
93
|
RegEqref = Regexp::union(RegEqrefLatex, RegEqPar)
|
74
94
|
|
75
|
-
MaRuKu::In::Markdown::
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
95
|
+
MaRuKu::In::Markdown::register_span_extension(
|
96
|
+
:chars => [?\\, ?(],
|
97
|
+
:regexp => RegEqref,
|
98
|
+
:handler => lambda { |doc, src, con|
|
99
|
+
return false if not doc.is_math_enabled?
|
100
|
+
eqid = src.read_regexp(RegEqref).captures.compact.first
|
101
|
+
r = doc.md_el(:eqref, [], meta={:eqid=>eqid})
|
102
|
+
con.push r
|
103
|
+
true
|
104
|
+
}
|
105
|
+
)
|