public XWPFDocument renderDoc(string usfm) { USFMDocument markerTree = parser.ParseFromString(usfm); XWPFDocument testDoc = render.Render(markerTree); return(testDoc); }
private void txtInput_TextChanged(object sender, EventArgs e) { USFMParser parser = new USFMParser(); var output = parser.ParseFromString(txtInput.Text); trOutput.Nodes.Clear(); foreach (var marker in output.Contents) { trOutput.Nodes.Add(CreateTreeNode(marker)); } }
private void RenderHtml(string fileName) { // Does not parse through section headers yet var parser = new USFMParser(new List <string> { "s5" }); HTMLConfig configHTML = BuildHTMLConfig(); //Configure Settings -- Spacing ? 1, Column# ? 1, TextDirection ? L2R var renderer = new HtmlRenderer(configHTML); // Added ULB License and Page Number renderer.FrontMatterHTML = GetLicenseInfo(); renderer.InsertedFooter = GetFooterInfo(); var usfm = new USFMDocument(); var progress = fileDataGrid.RowCount - 1; var progressStep = 0; foreach (DataGridViewRow row in fileDataGrid.Rows) { var cell = row.Cells[0]; if (cell.Value == null) { continue; } var filename = cell.Value.ToString(); var text = File.ReadAllText(filename); usfm.Insert(parser.ParseFromString(text)); progressStep++; LoadingBar.Value = (int)(progressStep / (float)progress * 100); } var html = renderer.Render(usfm); File.WriteAllText(fileName, html); var dirname = Path.GetDirectoryName(fileName); filePathConversion = dirname; var cssFilename = Path.Combine(dirname, "style.css"); if (!File.Exists(cssFilename)) { File.Copy("style.css", cssFilename); } }
public static void ConvertFiles(string inputDirectory, string outputFileName) { USFMParser parser = new USFMParser(new List <string> { "s5" }); CsvRenderer renderer = new CsvRenderer(); List <USFMDocument> content = new List <USFMDocument>(); foreach (var f in Directory.EnumerateFiles(inputDirectory, "*.usfm", SearchOption.AllDirectories)) { content.Add(parser.ParseFromString(File.ReadAllText(f))); } var file = File.OpenWrite(outputFileName); renderer.Render(content, file); }
private async void BtnCheck_Click(object sender, EventArgs e) { Msg_Linter.ResetText(); BtnCheck.Enabled = false; BtnAddFiles.Enabled = false; var parser = new USFMParser(new List <string> { "s5" }); var usfm = new USFMDocument(); DataGridViewSelectedCellCollection SelectedFiles = fileDataGrid.SelectedCells; USFMLinter lint = new USFMLinter(); if (fileDataGrid.Rows.Count > 1) { foreach (DataGridViewCell SelectFile in SelectedFiles) { if (SelectFile.OwningRow.Index != fileDataGrid.RowCount - 1) { var cell = SelectFile.OwningRow.Cells[0]; if (cell.Value == null) { continue; } var filename = cell.Value.ToString(); var text = File.ReadAllText(filename); usfm.Insert(parser.ParseFromString(text)); List <LinterResult> linterResults = await lint.LintAsync(usfm); await DisplayErrors(linterResults, filename); usfm = new USFMDocument(); } } } BtnCheck.Enabled = true; BtnAddFiles.Enabled = true; }
private void RenderDocx(string fileName) { // Does not parse through section headers yet var parser = new USFMParser(new List <string> { "s5" }); var renderer = new DocxRenderer(BuildDocxConfig()); var usfm = new USFMDocument(); var progress = fileDataGrid.RowCount - 1; var progressStep = 0; foreach (DataGridViewRow row in fileDataGrid.Rows) { var cell = row.Cells[0]; if (cell.Value == null) { continue; } var filename = cell.Value.ToString(); var text = File.ReadAllText(filename); usfm.Insert(parser.ParseFromString(text)); progressStep++; LoadingBar.Value = (int)(progressStep / (float)progress * 100); } var output = renderer.Render(usfm); using (Stream outputStream = File.Create(fileName)) { output.Write(outputStream); } }
public void Run() { // Does not parse through section headers yet var parser = new USFMParser(new List <string> { "s5" }); configHTML = BuildConfig(); //Configure Settings -- Spacing ? 1, Column# ? 1, TextDirection ? L2R var renderer = new HtmlRenderer(configHTML); // Added ULB License and Page Number renderer.FrontMatterHTML = GetLicenseInfo(); renderer.InsertedFooter = GetFooterInfo(); var usfm = new USFMDocument(); if (folderName.Equals(string.Empty)) { return; } var dirinfo = new DirectoryInfo(folderName); if (!dirinfo.Exists) { Console.WriteLine("The input path doesn't exist. Make sure you spelled it correctly"); return; } if (!Directory.Exists(projectOutput)) { Console.WriteLine("The output path doesn't exist. Make sure you spelled it correctly"); return; } var allFiles = dirinfo.GetFiles("*.usfm", SearchOption.AllDirectories) .Union(dirinfo.GetFiles("*.txt", SearchOption.AllDirectories)).ToArray(); Array.Sort(allFiles, delegate(FileInfo a, FileInfo b) { return(a.FullName.CompareTo(b.FullName)); }); var progress = allFiles.Length; var progressStep = 0; foreach (FileInfo fileInfo in allFiles) { var text = File.ReadAllText(fileInfo.FullName); usfm.Insert(parser.ParseFromString(text)); progressStep++; Console.Write("\r[{0}%] ", (int)(progressStep / (float)progress * 100)); } var html = renderer.Render(usfm); var htmlFilename = Path.Combine(projectOutput, "out.html"); File.WriteAllText(htmlFilename, html); var dirname = Path.GetDirectoryName(htmlFilename); var cssFilename = Path.Combine(dirname, "style.css"); if (!File.Exists(cssFilename)) { File.Copy("style.css", cssFilename); } Console.WriteLine("Your project was successfully converted!"); }