Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/SIL.Machine/Corpora/ParatextProjectTextUpdaterBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public string UpdateUsfm(
UpdateUsfmMarkerBehavior paragraphBehavior = UpdateUsfmMarkerBehavior.Preserve,
UpdateUsfmMarkerBehavior embedBehavior = UpdateUsfmMarkerBehavior.Preserve,
UpdateUsfmMarkerBehavior styleBehavior = UpdateUsfmMarkerBehavior.Strip,
IReadOnlyCollection<string> preserveParagraphStyles = null
IReadOnlyCollection<string> preserveParagraphStyles = null,
IEnumerable<string> remarks = null
)
{
string fileName = _settings.GetBookFileName(bookId);
Expand All @@ -47,7 +48,8 @@ public string UpdateUsfm(
paragraphBehavior,
embedBehavior,
styleBehavior,
preserveParagraphStyles
preserveParagraphStyles,
remarks
);
try
{
Expand Down
21 changes: 16 additions & 5 deletions src/SIL.Machine/Corpora/UpdateUsfmParserHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class UpdateUsfmParserHandler : ScriptureRefUsfmParserHandlerBase
private readonly UpdateUsfmMarkerBehavior _embedBehavior;
private readonly UpdateUsfmMarkerBehavior _styleBehavior;
private readonly HashSet<string> _preserveParagraphStyles;
private readonly List<string> _remarks;
private readonly Stack<bool> _replace;
private int _rowIndex;
private int _tokenIndex;
Expand All @@ -47,7 +48,8 @@ public UpdateUsfmParserHandler(
UpdateUsfmMarkerBehavior paragraphBehavior = UpdateUsfmMarkerBehavior.Preserve,
UpdateUsfmMarkerBehavior embedBehavior = UpdateUsfmMarkerBehavior.Preserve,
UpdateUsfmMarkerBehavior styleBehavior = UpdateUsfmMarkerBehavior.Strip,
IReadOnlyCollection<string> preserveParagraphStyles = null
IReadOnlyCollection<string> preserveParagraphStyles = null,
IEnumerable<string> remarks = null
)
{
_rows = rows ?? Array.Empty<(IReadOnlyList<ScriptureRef>, string)>();
Expand All @@ -60,10 +62,11 @@ public UpdateUsfmParserHandler(
_paragraphBehavior = paragraphBehavior;
_embedBehavior = embedBehavior;
_styleBehavior = styleBehavior;
if (preserveParagraphStyles == null)
_preserveParagraphStyles = new HashSet<string> { "r", "rem" };
else
_preserveParagraphStyles = new HashSet<string>(preserveParagraphStyles);
_preserveParagraphStyles =
preserveParagraphStyles == null
? new HashSet<string> { "r", "rem" }
: new HashSet<string>(preserveParagraphStyles);
_remarks = remarks == null ? new List<string>() : remarks.ToList();
_embedUpdated = false;
_embedRowTexts = new List<string>();
}
Expand All @@ -82,6 +85,14 @@ public override void StartBook(UsfmParserState state, string marker, string code
var startBookTokens = new List<UsfmToken>();
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);
Expand Down
Loading