Method: MaRuKu::Out::HTML#to_html_equation

Defined in:
lib/maruku/ext/math/to_html.rb

#to_html_equationObject



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/maruku/ext/math/to_html.rb', line 116

def to_html_equation
  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 = xelem('div')
  div['class'] = 'maruku-equation'
  if mathml
    if self.label  # then numerate
      span = xelem('span')
      span['class'] = 'maruku-eq-number'
      span << xtext("(#{self.num})")
      div << span
      div['id'] = "eq:#{self.label}"
    end
    mathml.add_class('maruku-mathml')
    div << mathml.to_html
  end

  if png
    img = adjust_png(png, false)
    div << img
    if self.label  # then numerate
      span = xelem('span')
      span['class'] = 'maruku-eq-number'
      span << xtext("(#{self.num})")
      div << span
      div['id'] = "eq:#{self.label}"
    end
  end

  source_span = xelem('span')
  add_class_to(source_span, 'maruku-eq-tex')
  code = convert_to_mathml_none(:equation, self.math.strip)
  code['style'] = 'display: none'
  source_span << code
  div << source_span

  div
end