diff --git a/src/SIL.Machine/Corpora/ParatextProjectTextUpdaterBase.cs b/src/SIL.Machine/Corpora/ParatextProjectTextUpdaterBase.cs index 5e0d9dfd..06faf34a 100644 --- a/src/SIL.Machine/Corpora/ParatextProjectTextUpdaterBase.cs +++ b/src/SIL.Machine/Corpora/ParatextProjectTextUpdaterBase.cs @@ -27,7 +27,8 @@ public string UpdateUsfm( UpdateUsfmMarkerBehavior paragraphBehavior = UpdateUsfmMarkerBehavior.Preserve, UpdateUsfmMarkerBehavior embedBehavior = UpdateUsfmMarkerBehavior.Preserve, UpdateUsfmMarkerBehavior styleBehavior = UpdateUsfmMarkerBehavior.Strip, - IReadOnlyCollection preserveParagraphStyles = null + IReadOnlyCollection preserveParagraphStyles = null, + IEnumerable remarks = null ) { string fileName = _settings.GetBookFileName(bookId); @@ -47,7 +48,8 @@ public string UpdateUsfm( paragraphBehavior, embedBehavior, styleBehavior, - preserveParagraphStyles + preserveParagraphStyles, + remarks ); try { diff --git a/src/SIL.Machine/Corpora/UpdateUsfmParserHandler.cs b/src/SIL.Machine/Corpora/UpdateUsfmParserHandler.cs index 4ce564a0..532a89f0 100644 --- a/src/SIL.Machine/Corpora/UpdateUsfmParserHandler.cs +++ b/src/SIL.Machine/Corpora/UpdateUsfmParserHandler.cs @@ -33,6 +33,7 @@ public class UpdateUsfmParserHandler : ScriptureRefUsfmParserHandlerBase private readonly UpdateUsfmMarkerBehavior _embedBehavior; private readonly UpdateUsfmMarkerBehavior _styleBehavior; private readonly HashSet _preserveParagraphStyles; + private readonly List _remarks; private readonly Stack _replace; private int _rowIndex; private int _tokenIndex; @@ -47,7 +48,8 @@ public UpdateUsfmParserHandler( UpdateUsfmMarkerBehavior paragraphBehavior = UpdateUsfmMarkerBehavior.Preserve, UpdateUsfmMarkerBehavior embedBehavior = UpdateUsfmMarkerBehavior.Preserve, UpdateUsfmMarkerBehavior styleBehavior = UpdateUsfmMarkerBehavior.Strip, - IReadOnlyCollection preserveParagraphStyles = null + IReadOnlyCollection preserveParagraphStyles = null, + IEnumerable remarks = null ) { _rows = rows ?? Array.Empty<(IReadOnlyList, string)>(); @@ -60,10 +62,11 @@ public UpdateUsfmParserHandler( _paragraphBehavior = paragraphBehavior; _embedBehavior = embedBehavior; _styleBehavior = styleBehavior; - if (preserveParagraphStyles == null) - _preserveParagraphStyles = new HashSet { "r", "rem" }; - else - _preserveParagraphStyles = new HashSet(preserveParagraphStyles); + _preserveParagraphStyles = + preserveParagraphStyles == null + ? new HashSet { "r", "rem" } + : new HashSet(preserveParagraphStyles); + _remarks = remarks == null ? new List() : remarks.ToList(); _embedUpdated = false; _embedRowTexts = new List(); } @@ -82,6 +85,14 @@ public override void StartBook(UsfmParserState state, string marker, string code var startBookTokens = new List(); if (_idText != null) startBookTokens.Add(new UsfmToken(_idText + " ")); + if (_remarks.Count() > 0) + { + foreach (string remark in _remarks) + { + startBookTokens.Add(new UsfmToken(UsfmTokenType.Paragraph, "rem", null, null)); + startBookTokens.Add(new UsfmToken(remark)); + } + } PushNewTokens(startBookTokens); base.StartBook(state, marker, code);