Repository navigation
Fix crash and misplacement from unclosed style markers - #536
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Co-authored-by: Eli C. Lowry <83078660+Enkidu93@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #536 +/- ##
=======================================
Coverage 74.35% 74.36%
=======================================
Files 456 456
Lines 38283 38292 +9
Branches 5245 5251 +6
=======================================
+ Hits 28467 28474 +7
- Misses 8666 8667 +1
- Partials 1150 1151 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| else | ||
| { | ||
| targetSentence += element.Tokens[0].ToUsfm(); | ||
| targetSentence += element.GetText(); |
There was a problem hiding this comment.
FYI: F2. Only the last row's alignment applies: targetSentence now joins every row in the block, but AdvanceRows (UpdateUsfmParserHandler.cs:562) keeps only the last matching row's alignment_info. A verse range with a separate alignment per row will place markers against the wrong text. This matches machine.py and the new test shares one alignment, so it is a caller contract to document. Unverified.
| return string.Concat(Tokens.Select(t => t.ToUsfm())); | ||
| } | ||
|
|
||
| public bool IsPlaceable(UpdateUsfmMarkerBehavior paragraphBehavior, UpdateUsfmMarkerBehavior styleBehavior) |
There was a problem hiding this comment.
FYI: F3. This adds public API to a netstandard2.0 package: IsPlaceable and GetText are public on UsfmUpdateBlockElement, and the paragraph single-token rule belongs to PlaceMarkersUsfmUpdateBlockHandler. internal keeps the parity with machine.py without making that rule part of the contract.
This comment has been minimized.
This comment has been minimized.
Enkidu93
left a comment
There was a problem hiding this comment.
@Enkidu93 reviewed 5 files and all commit messages, and made 1 comment.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on claude).
tests/SIL.Machine.Tests/Corpora/PlaceMarkersUsfmUpdateBlockHandlerTests.cs line 1042 at r1 (raw file):
"; AssertUsfmEquals(target, result); }
@claude I believe you missed porting a few of the tests here. Please finish porting the tests and confirm they pass.
|
Claude finished @Enkidu93's task in 1m 39s —— View job Ported the two missing tests
The two tests are in The filtered run of I only compared the placement-handler tests. I did not check the parser-handler tests against machine.py again. Pushed as 3829a43. |
Co-authored-by: Eli C. Lowry <83078660+Enkidu93@users.noreply.github.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Public API: adds Findings: F1 addressed, unverified; F2 open, unverified; F3 open. Reviewed at 3829a43 |
Enkidu93
left a comment
There was a problem hiding this comment.
@Enkidu93 reviewed 1 file and all commit messages, made 1 comment, and resolved 1 discussion.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on claude).
Ports sillsdev/machine.py#364. An unclosed character style no longer swallows the next paragraph marker, and the place-markers handler no longer crashes on a block with nothing to place.
Changes
UpdateUsfmParserHandler.EndCharonly touches tokens when the style was explicitly closed.EndNoteskips the end marker in a duplicate verse, mirroringStartNote.PlaceMarkersUsfmUpdateBlockHandlerreturns the block when nothing is left to insert, treatsOtherelements like embeds at end of block, and reads all tokens of a text element (GetText) so verse ranges update fully.UsfmUpdateBlockElement.IsPlaceable, which excludes elements marked for removal.UpdateUsfm_VerseRangesnow uses one row spanning the range, as in machine.py; the old six duplicate rows only passed because extra tokens were ignored.Not ported
Moving the behavior enums into
update_usfm_behavior.pyfixes a Python circular import and has no C# counterpart. Two tests were left out: the milestone/embed placement test and the behavior-disagrees test.Validation
./local_check.sh --agent-strict: comment hygiene clean, build succeeded, all tests passed.Closes #502
🤖 Generated with Claude Code
This change is