コード例 #1
0
ファイル: LaTeXProcessor.cs プロジェクト: IvanSorokin/Tuto
 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;
 }
コード例 #2
0
ファイル: LaTeXProcessor.cs プロジェクト: IvanSorokin/Tuto
 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"));
 }
コード例 #3
0
ファイル: LaTeXProcessor.cs プロジェクト: jokalee/Tuto
        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")));
        }
コード例 #4
0
ファイル: LaTeXProcessor.cs プロジェクト: jokalee/Tuto
        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);
        }