Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle coincident page marks better #1277

Merged
merged 1 commit into from
Nov 27, 2023

Conversation

windymilla
Copy link
Collaborator

The ReplaceSelectionsWith function handles keeping page marks in approximately the same location when a Search/Replace operation spans a page boundary (by maintaining the relative proportion of text each side of the page boundary).

This did not cope correctly when there were two or more page marks at the same location (i.e. blank pages). The page marks could get reversed, so that 015 came before 014, for example (although still both at the same location).

Avoiding changing the mark gravity (whether the mark goes left or right of text inserted at the mark) fixes this for marks within the S/R region. Temporarily setting "right" gravity for page marks that immediately follow the S/R region keeps those page marks correct.

The `ReplaceSelectionsWith` function handles keeping page marks
in approximately the same location when a Search/Replace
operation spans a page boundary (by maintaining the relative
proportion of text each side of the page boundary).

This did not cope correctly when there were two or more
page marks at the same location (i.e. blank pages). The page
marks could get reversed, so that 015 came before 014, for
example (although still both at the same location).

Avoiding changing the mark gravity (whether the mark goes
left or right of text inserted at the mark) fixes this for marks within
the S/R region. Temporarily setting "right" gravity for page marks
that immediately follow the S/R region keeps those page marks
correct.
@windymilla
Copy link
Collaborator Author

Testing notes: Charlie's example in the linked issue shows the problem - you can right-click the Img label to show/hide where the page marks are. Around line 420 the page marks 014 and 015 are in the correct order, but without this PR, HTML->Generator, Autogenerate causes those to be swapped. They should now remain in the correct order.

The initial attempt at fixing this broke S/R across page boundaries. You can test this out by doing regex replaces, like replacing
</p>\n<hr
with something the same length, longer, and shorter. The page marks should stay in the correct position proportionally, and of course no text should end up duplicated unexpectedly.

@windymilla windymilla merged commit 26e3f25 into DistributedProofreaders:master Nov 27, 2023
1 check passed
@windymilla windymilla deleted the pagenum-bug branch November 27, 2023 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants