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

Commit

Permalink
Fix Uninitialized eq2eqid Hash
Browse files Browse the repository at this point in the history
Thanks to Adeel Khan for reporting.
Fixes Instiki Issue #52.
  • Loading branch information
distler committed Oct 10, 2017
1 parent 3385bd5 commit e912cc0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
1 change: 0 additions & 1 deletion lib/maruku/ext/math/elements.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ def md_equation(math, label, numerate)
math = math.gsub(reglabel, '') if label = math[reglabel, 1]
num = nil
if (label || numerate) && @doc # take number
@doc.eqid2eq ||= {}
num = @doc.eqid2eq.size + 1
label = "eq#{num}" unless label # TODO do id for document
end
Expand Down
4 changes: 4 additions & 0 deletions lib/maruku/ext/math/parsing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ class MDDocument
# @return [String => MDElement]
attr_accessor :eqid2eq

def eqid2eq
@eqid2eq || {}
end

def is_math_enabled?
get_setting :math_enabled
end
Expand Down
21 changes: 21 additions & 0 deletions spec/block_docs/math/Instiki_Issue_52.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Fixes Uninitialized eq2eqid hash
*** Parameters: ***
require 'maruku/ext/math';{:html_math_engine => 'itex2mml'}
*** Markdown input: ***
This is an unresolved equation reference (eq:xyz).

*** Output of inspect ***
md_el(:document, md_par([
"This is an unresolved equation reference ",
md_el(:eqref, [], {:eqid=>"xyz"}),
"."
]))
*** Output of to_html ***
<p>This is an unresolved equation reference (eq:xyz).</p>

*** Output of to_latex ***
This is an unresolved equation reference \eqref{xyz}.
*** Output of to_md ***

*** Output of to_s ***

0 comments on commit e912cc0

Please sign in to comment.