From e912cc00f9a418d8e5235630bdc1a081ac9372f0 Mon Sep 17 00:00:00 2001 From: Jacques Distler Date: Tue, 10 Oct 2017 17:06:31 -0500 Subject: [PATCH] Fix Uninitialized eq2eqid Hash Thanks to Adeel Khan for reporting. Fixes Instiki Issue #52. --- lib/maruku/ext/math/elements.rb | 1 - lib/maruku/ext/math/parsing.rb | 4 ++++ spec/block_docs/math/Instiki_Issue_52.md | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 spec/block_docs/math/Instiki_Issue_52.md diff --git a/lib/maruku/ext/math/elements.rb b/lib/maruku/ext/math/elements.rb index b49b9c8..3f947f8 100644 --- a/lib/maruku/ext/math/elements.rb +++ b/lib/maruku/ext/math/elements.rb @@ -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 diff --git a/lib/maruku/ext/math/parsing.rb b/lib/maruku/ext/math/parsing.rb index 061e882..661fe91 100644 --- a/lib/maruku/ext/math/parsing.rb +++ b/lib/maruku/ext/math/parsing.rb @@ -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 diff --git a/spec/block_docs/math/Instiki_Issue_52.md b/spec/block_docs/math/Instiki_Issue_52.md new file mode 100644 index 0000000..70d3785 --- /dev/null +++ b/spec/block_docs/math/Instiki_Issue_52.md @@ -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 *** +

This is an unresolved equation reference (eq:xyz).

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