def stem node
if (idx = node.subs.index :specialcharacters)
node.subs.delete_at idx
equation = node.content
idx > 0 ? (node.subs.insert idx, :specialcharacters) : (node.subs.unshift :specialcharacters)
else
equation = node.content
end
if node.style == 'asciimath'
if ((defined? ::AsciiMath) || ((defined? @asciimath_available) ? @asciimath_available :
(@asciimath_available = Helpers.require_library 'asciimath', true, :warn)))
equation_data = (::AsciiMath.parse equation).to_mathml 'mml:', 'xmlns:mml' => 'http://www.w3.org/1998/Math/MathML'
else
equation_data = %(<mathphrase><![CDATA[#{equation}]]></mathphrase>)
end
else
equation_data = %(<alt><![CDATA[#{equation}]]></alt>
<mathphrase><![CDATA[#{equation}]]></mathphrase>)
end
if node.title?
%(<equation#{common_attributes node.id, node.role, node.reftext}>
<title>#{node.title}</title>
#{equation_data}
</equation>)
else
%(<informalequation#{common_attributes node.id, node.role, node.reftext}>
#{equation_data}
</informalequation>)
end
end