private string GetEncoding(USFMDocument input) { var encodingSearch = input.GetChildMarkers <IDEMarker>(); if (encodingSearch.Count > 0) { return(encodingSearch[0].Encoding); } return(null); }
/// <summary> /// Write the contents of the usfm document to a CSV /// </summary> /// <param name="document">The document whose contents to write</param> /// <param name="csv">The CSV writer to write the content to</param> private static void WriteContent(USFMDocument document, CsvWriter csv) { var book = document.GetChildMarkers <TOC3Marker>().First().BookAbbreviation; var chapters = document.GetChildMarkers <CMarker>(); foreach (var chapter in chapters) { var verses = chapter.GetChildMarkers <VMarker>(); foreach (var verse in verses) { var textBlocks = verse.GetChildMarkers <TextBlock>() .Where(m => !document.GetHierarchyToMarker(m).Any(i => i is FMarker)); var text = string.Join(string.Empty, textBlocks.Select(b => b.Text)); csv.WriteField(book); csv.WriteField(chapter.Number); csv.WriteField(verse.VerseNumber); csv.WriteField(text.TrimEnd()); csv.NextRecord(); } } }
public List <LinterResult> Lint(USFMDocument input) { List <LinterResult> output = new List <LinterResult>(); foreach (Marker marker in input.GetChildMarkers <TCMarker>()) { LinterResult tmp = ValidateTable(marker, input); if (tmp != null) { output.Add(tmp); } } foreach (Marker marker in input.GetChildMarkers <TCRMarker>()) { LinterResult tmp = ValidateTable(marker, input); if (tmp != null) { output.Add(tmp); } } foreach (Marker marker in input.GetChildMarkers <THMarker>()) { LinterResult tmp = ValidateTable(marker, input); if (tmp != null) { output.Add(tmp); } } foreach (Marker marker in input.GetChildMarkers <THRMarker>()) { LinterResult tmp = ValidateTable(marker, input); if (tmp != null) { output.Add(tmp); } } return(output); }
public List <LinterResult> Lint(USFMDocument input) { List <LinterResult> output = new List <LinterResult>(); LinterResult tmp; foreach (var verse in input.GetChildMarkers <VMarker>()) { tmp = ValidateVerse(verse); if (tmp != null) { output.Add(tmp); } } return(output); }
public List <LinterResult> Lint(USFMDocument input) { List <LinterResult> output = new List <LinterResult>(); foreach (var marker in input.GetChildMarkers <UnknownMarker>()) { output.Add(new LinterResult() { Level = LinterLevel.Warning, Position = marker.Position, Message = $"The marker {marker.ParsedIdentifier} is unknown" } ); } return(output); }