/// <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 bld = new StringBuilder(); ReadDocumentInfo(expr.Expressions[0]); var bodyBuilder = bld; // 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 } return bld.ToString(); }
/// <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 bld = new StringBuilder(); //bld.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"); //bld.Append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN\" "); //bld.Append("\"http://www.w3.org/Math/DTD/mathml2/xhtml-math11-f.dtd\">\n"); //bld.Append("<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xml:lang=\""); //bld.Append(expr.Customization.Localization); //bld.Append("\">\n"); ReadDocumentInfo(expr.Expressions[0]); //WriteHead(expr, bld); //bld.Append("<body>\n"); //MakeTitle(bld); var bodyBuilder = expr.Customization.PlacementOfTableOfContents == TableOfContentsPlacement.Top ? new StringBuilder() : bld; // 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 } //if (expr.Customization.PlacementOfTableOfContents != TableOfContentsPlacement.None) //{ // MakeTableOfContents(bld, expr.Customization.SectionContents, expr.Customization.TableOfContentsTitle, // expr.Customization.TocSectionFormat, expr.Customization.TocSubsectionFormat); //} if (expr.Customization.PlacementOfTableOfContents != TableOfContentsPlacement.Bottom) { bld.Append(bodyBuilder.ToString()); } if (expr.Customization.Bibliography != null && expr.Customization.Bibliography.Count > 0) { MakeBibliography(bld, expr.Customization.BibliographyTitle, expr.Customization.BibliographyRecordFormat, expr.Customization.Bibliography); } //bld.Append("</body>\n</html>"); return bld.ToString(); }