/// <summary> /// Performs the conversion procedure. /// </summary> /// <param name="expr">The expression to convert.</param> /// <returns>The conversion result.</returns> public override string Convert(LatexExpression expr) { var bodyBuilder = new StringBuilder(); // Convert the {document} block LatexExpression documentExpression = expr.FindDocument(); if (documentExpression != null) { try { bodyBuilder.Append(documentExpression.Convert()); } // ReSharper disable RedundantCatchClause #pragma warning disable 168 catch (Exception e) #pragma warning restore 168 { #if DEBUG throw; #else Log.Error("Failed to convert the document block", e); #endif } // ReSharper restore RedundantCatchClause // ReSharper restore RedundantCatchClause } return(bodyBuilder.ToString()); }
public string ConvertToMathMLTree(string latexExpression) { //string prefixLatex = @"\begin{document}"; //string postfixLatex = @"\end{document}"; //string resultLatexExpression = string.Format("{0}{1}{2}", prefixLatex, latexExpression, postfixLatex); string resultLatexExpression = latexExpression; var parser = new LatexParser(resultLatexExpression, this); try { LatexExpression root = parser.Root; CallEventHandler(AfterDocumentWasParsed); String linkToMMLDDT = "<!DOCTYPE math SYSTEM 'http://www.w3.org/Math/DTD/mathml1/mathml.dtd'>"; StringBuilder sb = new StringBuilder(linkToMMLDDT); Output = root.Convert(); return(Output); } catch (Exception exp) { return(exp.Message); } }
/// <summary> /// Performs the conversion procedure. /// </summary> /// <param name="expr">The expression to convert.</param> /// <returns>The conversion result.</returns> public override string Convert(LatexExpression expr) { expr.ExprType = ExpressionType.BlockMath; expr.Expressions.Add(new List <LatexExpression> { new LatexExpression("equation", expr, 1, 0, expr.Customization) }); return(expr.Convert()); }
/// <summary> /// Performs the conversion procedure. /// </summary> /// <param name="expr">The expression to convert.</param> /// <returns>The conversion result.</returns> public override string Convert(LatexExpression expr) { expr.ExprType = ExpressionType.BlockMath; expr.Expressions.Add(new List<LatexExpression> {new LatexExpression("equation", expr, 1, 0, expr.Customization)}); return expr.Convert(); }