Skip to content
This repository was archived by the owner on Jan 5, 2025. It is now read-only.

Commit ec44b27

Browse files
authored
Merge pull request #142 from distler/master
Fix Uninitialized eq2eqid Hash
2 parents 0b0b430 + 167d845 commit ec44b27

File tree

4 files changed

+65
-1
lines changed

4 files changed

+65
-1
lines changed

lib/maruku/ext/math/elements.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ def md_equation(math, label, numerate)
99
math = math.gsub(reglabel, '') if label = math[reglabel, 1]
1010
num = nil
1111
if (label || numerate) && @doc # take number
12-
@doc.eqid2eq ||= {}
1312
num = @doc.eqid2eq.size + 1
1413
label = "eq#{num}" unless label # TODO do id for document
1514
end

lib/maruku/ext/math/parsing.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ class MDDocument
55
# @return [String => MDElement]
66
attr_accessor :eqid2eq
77

8+
def eqid2eq
9+
@eqid2eq ||= {}
10+
end
11+
812
def is_math_enabled?
913
get_setting :math_enabled
1014
end
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Fixes Uninitialized eq2eqid hash
2+
*** Parameters: ***
3+
require 'maruku/ext/math';{:html_math_engine => 'itex2mml'}
4+
*** Markdown input: ***
5+
This is an unresolved equation reference (eq:xyz).
6+
7+
*** Output of inspect ***
8+
md_el(:document, md_par([
9+
"This is an unresolved equation reference ",
10+
md_el(:eqref, [], {:eqid=>"xyz"}),
11+
"."
12+
]))
13+
*** Output of to_html ***
14+
<p>This is an unresolved equation reference (eq:xyz).</p>
15+
16+
*** Output of to_latex ***
17+
This is an unresolved equation reference \eqref{xyz}.
18+
*** Output of to_md ***
19+
20+
*** Output of to_s ***
21+
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Fixes Uninitialized eq2eqid hash
2+
*** Parameters: ***
3+
require 'maruku/ext/math';{:html_math_engine => 'itex2mml'}
4+
*** Markdown input: ***
5+
Here is an equation
6+
\[\label{xxx}
7+
\sin(\theta)
8+
\]
9+
Here we refer back to it (eq:xxx). Or \eqref{xxx}.
10+
*** Output of inspect ***
11+
md_el(:document, [
12+
md_par("Here is an equation"),
13+
md_el(:equation, [], {:math=>"\n\\sin(\\theta)\n\n", :label=>"xxx", :num=>1}),
14+
md_par([
15+
"Here we refer back to it ",
16+
md_el(:eqref, [], {:eqid=>"xxx"}),
17+
". Or ",
18+
md_el(:eqref, [], {:eqid=>"xxx"}),
19+
"."
20+
])
21+
])
22+
*** Output of to_html ***
23+
<p>Here is an equation</p>
24+
<div class='maruku-equation' id='eq:xxx'><span class='maruku-eq-number'>(1)</span><math class='maruku-mathml' display='block' xmlns='http://www.w3.org/1998/Math/MathML'><semantics><mrow><mi>sin</mi><mo stretchy='false'>(</mo><mi>θ</mi><mo stretchy='false'>)</mo></mrow><annotation encoding='application/x-tex'>
25+
\sin(\theta)
26+
27+
</annotation></semantics></math></div>
28+
<p>Here we refer back to it <a class='maruku-eqref' href='#eq:xxx'>(1)</a>. Or <a class='maruku-eqref' href='#eq:xxx'>(1)</a>.</p>
29+
30+
*** Output of to_latex ***
31+
Here is an equation
32+
33+
\begin{equation}
34+
\sin(\theta)
35+
\label{xxx}\end{equation}
36+
Here we refer back to it \eqref{xxx}. Or \eqref{xxx}.
37+
*** Output of to_md ***
38+
39+
*** Output of to_s ***
40+

0 commit comments

Comments
 (0)