public LatexDocument Parse(FileInfo file) { var lines = File.ReadAllLines(file.FullName); var document = new LatexDocument(); bool inPreamble = true; foreach (var e in lines) { if (e.Contains("\\begin{document}")) { inPreamble = false; continue; } if (inPreamble) { document.Preamble += e; continue; } if (e.Contains("\\section")) { document.Sections.Add(new LatexSection { Name = e }); continue; } if (e.Contains("\\begin{frame}")) { document.LastSection.Slides.Add(new LatexSlide { Content = e }); continue; } if (document.LastSection != null && document.LastSection.LastSlide != null) document.LastSection.LastSlide.Content += e; } return document; }
public FileInfo Compile(LatexDocument document, DirectoryInfo environmentDirectory) { var tempLatexFile = new FileInfo(Path.Combine(environmentDirectory.FullName, "temp.tex")); var builder = new StringBuilder(); builder.Append(document.Preamble); builder.Append("\\begin{document}\r\n"); foreach (var e in document.Sections) { builder.Append(e.Name); foreach (var s in e.Slides) builder.Append(s.Content); } builder.Append("\\end{document}"); File.WriteAllText(tempLatexFile.FullName, builder.ToString()); StartLatex(tempLatexFile); //StartLatex(tempLatexFile); return new FileInfo(Path.Combine(environmentDirectory.FullName, "temp.pdf")); }
public FileInfo Compile(LatexDocument document, DirectoryInfo environmentDirectory) { var tempLatexFile = new FileInfo(Path.Combine(environmentDirectory.FullName, "temp.tex")); var builder = new StringBuilder(); builder.Append(document.Preamble); builder.Append("\\begin{document}\r\n"); foreach (var e in document.Sections) { builder.Append(e.Name); foreach (var s in e.Slides) { builder.Append(s.Content); } } builder.Append("\\end{document}"); File.WriteAllText(tempLatexFile.FullName, builder.ToString()); StartLatex(tempLatexFile); //StartLatex(tempLatexFile); return(new FileInfo(Path.Combine(environmentDirectory.FullName, "temp.pdf"))); }
public LatexDocument Parse(FileInfo file) { var lines = File.ReadAllLines(file.FullName); var document = new LatexDocument(); bool inPreamble = true; foreach (var e in lines) { if (e.Contains("\\begin{document}")) { inPreamble = false; continue; } if (inPreamble) { document.Preamble += e; continue; } if (e.Contains("\\section")) { document.Sections.Add(new LatexSection { Name = e }); continue; } if (e.Contains("\\begin{frame}")) { document.LastSection.Slides.Add(new LatexSlide { Content = e }); continue; } if (document.LastSection != null && document.LastSection.LastSlide != null) { document.LastSection.LastSlide.Content += e; } } return(document); }