Exemplo n.º 1
0
 public static LatexDocument Parse(FileInfo file)
 {
     var lines = File.ReadAllLines(file.FullName);
     var document = new LatexDocument();
     bool inPreamble = true;
     foreach (var _e in lines)
     {
         var e = _e + "\r\n";
         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;
     }
     document.ModificationTime = file.LastWriteTime;
     document.OriginalFile = file;
     return document;
 }
Exemplo n.º 2
0
 public static FileInfo Compile(LatexDocument document, DirectoryInfo environmentDirectory)
 {
     var tempLatexFile = PrepareSeparateSource(document, environmentDirectory);
     if (!StartLatex(tempLatexFile)) return null;
     //StartLatex(tempLatexFile);
     return new FileInfo(Path.Combine(environmentDirectory.FullName, pdfFileName));
 }
Exemplo n.º 3
0
 public static FileInfo PrepareSeparateSource(LatexDocument document, DirectoryInfo environmentDirectory)
 {
     var tempLatexFile = new FileInfo(Path.Combine(environmentDirectory.FullName, temporalFileName));
     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());
     return tempLatexFile;
 }