lib/maruku/ext/math/to_html.rb in maruku-0.5.9 vs lib/maruku/ext/math/to_html.rb in maruku-0.6.0

- old
+ new

@@ -88,11 +88,11 @@ style += "vertical-align: -#{depth_in_ex}ex;" if use_depth style += "height: #{total_height_in_ex}ex;" img = Element.new 'img' img.attributes['src'] = src img.attributes['style'] = style - img.attributes['alt'] = "equation" + img.attributes['alt'] = "$#{self.math.strip}$" img end def to_html_inline_math mathml = get_setting(:html_math_output_mathml) && render_mathml(:inline, self.math) @@ -101,11 +101,11 @@ span = create_html_element 'span' add_class_to(span, 'maruku-inline') if mathml add_class_to(mathml, 'maruku-mathml') - span << mathml + return mathml end if png img = adjust_png(png, use_depth=true) add_class_to(img, 'maruku-png') @@ -119,19 +119,10 @@ mathml = get_setting(:html_math_output_mathml) && render_mathml(:equation, self.math) png = get_setting(:html_math_output_png) && render_png(:equation, self.math) div = create_html_element 'div' add_class_to(div, 'maruku-equation') - if self.label # then numerate - span = Element.new 'span' - span.attributes['class'] = 'maruku-eq-number' - num = self.num - span << Text.new("(#{num})") - div << span - div.attributes['id'] = "eq:#{self.label}" - end - if mathml add_class_to(mathml, 'maruku-mathml') div << mathml end @@ -139,16 +130,25 @@ img = adjust_png(png, use_depth=false) add_class_to(img, 'maruku-png') div << img end - source_div = Element.new 'div' - add_class_to(source_div, 'maruku-eq-tex') - code = convert_to_mathml_none(:equation, self.math) - code.attributes['style'] = 'display: none' - source_div << code - div << source_div + source_span = Element.new 'span' + add_class_to(source_span, 'maruku-eq-tex') + code = convert_to_mathml_none(:equation, self.math.strip) + code.attributes['style'] = 'display: none' + source_span << code + div << source_span + + if self.label # then numerate + span = Element.new 'span' + span.attributes['class'] = 'maruku-eq-number' + num = self.num + span << Text.new("(#{num})") + div << span + div.attributes['id'] = "eq:#{self.label}" + end div end def to_html_eqref if eq = self.doc.eqid2eq[self.eqid] @@ -162,9 +162,26 @@ maruku_error "Cannot find equation #{self.eqid.inspect}" Text.new "(eq:#{self.eqid})" end end + def to_html_divref + ref= nil + self.doc.refid2ref.each_value { |h| + ref = h[self.refid] if h.has_key?(self.refid) + } + if ref + num = ref.num + a = Element.new 'a' + a.attributes['class'] = 'maruku-ref' + a.attributes['href'] = "#" + self.refid + a << Text.new(num.to_s) + a + else + maruku_error "Cannot find div #{self.refid.inspect}" + Text.new "\\ref{#{self.refid}}" + end + end end end end