private string GenerateErrorHtml(string html, string error) { error = LaTeXUtils.TextToHtml(error ?? string.Empty); return(html + string.Format(LaTeXConst.Html.LaTeXError, error)); }
private IEnumerable <(bool success, string imgHtmlOrError, string originalHtml)> GenerateImages( LaTeXTag tag, MatchCollection matches) { List <(bool, string, string)> ret = new List <(bool, string, string)>(); foreach (Match match in matches) { string originalHtml = match.Groups[0].Value; string latexCode = match.Groups[1].Value; try { latexCode = LaTeXUtils.PlainText(latexCode); var(success, imgHtmlOrError) = LaTeXUtils.GenerateDviFile(Config, tag, latexCode); if (success == false) { ret.Add((false, imgHtmlOrError, originalHtml)); continue; } (success, imgHtmlOrError) = LaTeXUtils.GenerateImgFile(Config); if (success && string.IsNullOrWhiteSpace(imgHtmlOrError)) { ret.Add((false, "An unknown error occured, make sure your TeX installation has all the required packages, " + "or set it to install missing packages on-the-fly", originalHtml)); } imgHtmlOrError = GenerateImgHtml(imgHtmlOrError, tag.SurroundTexWith(latexCode)); ret.Add((success, imgHtmlOrError, originalHtml)); } catch (Exception ex) { ret.Add((false, ex.Message, originalHtml)); } } return(ret); }