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

Position coincident page marks in the correct order #1274

Merged
merged 3 commits into from
Nov 19, 2023

Conversation

windymilla
Copy link
Collaborator

If Pg123 and Pg124 were at the same location in the file, usually because Pg123 is blank, then when the page locations are loaded from the bin file and positioned in the text widget using "marks", the mark for Pg124 was inserted at the location where Pg123's mark was, and ended up before it in the text widget's internal list of marks.

Loading the marks in reverse order means that coincident marks appear in alphanumeric order, which is preferable.

This was assumed to be the case by the HTML generation code when set to skip coincident pagenum spans. So this fixes #1272

If Pg123 and Pg124 were at the same location in the file,
usually because Pg123 is blank, then when the page locations
are loaded from the bin file and positioned in the text widget
using "marks", the mark for Pg124 was inserted at the location
where Pg123's mark was, and ended up before it in the text
widget's internal list of marks.

Loading the marks in reverse order means that coincident
marks appear in alphanumeric order,  which is preferable.

This was assumed to be the case by the HTML generation
code when set to skip coincident pagenum spans. So this
fixes DistributedProofreaders#1272
@windymilla windymilla requested review from cpeel and srjfoo November 7, 2023 20:18
Although `markNext` iterates through the marks in order of their
location, it does not guarantee an order when two marks have the
same location. This could lead to some page numbers that directly
followed blank pages not being output to the HTML file.

To resolve it, just sort a list of page markers and use that, rather
than iterating through the markers in the file.

Fixes DistributedProofreaders#1272
@windymilla
Copy link
Collaborator Author

Apologies - although the previous commit appeared to fix the problem, it only fixed some coincident page markers and broke others. The order of coincident marks does not appear to be well defined in Tk, regardless of the order they were created or their "gravity" setting. This commit just gets all the marks and sorts them by png name, so the list is guaranteed to be in page order.

@windymilla windymilla requested a review from cpeel November 8, 2023 19:17
@@ -1245,20 +1245,19 @@ sub html_convert_sidenotes {
sub html_convert_pageanchors {
my $textwindow = $::textwindow;
::working("Inserting Page Number Markup");
$|++;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this even do? (perl, you are weird)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also known as $OUTPUT_AUTOFLUSH it apparently forces immediate flushing on every write or print. I did wonder (given the relative infrequency that I would have thought it is needed) why someone though it necessary to have $| as a short version of the full variable name. At the bottom of the docs, it had this explanation:

Mnemonic: when you want your pipes to be piping hot.

As you say, perl is weird 🤣

@windymilla
Copy link
Collaborator Author

Testing notes for @srjfoo
Probably Charlie's test file in the linked issue is as good as anything. Without this PR, HTML autogenerate would leave you with broken links (check with HTML->Link Checker)

@windymilla windymilla merged commit 4de77c1 into DistributedProofreaders:master Nov 19, 2023
1 check passed
@windymilla windymilla deleted the pagenums branch November 19, 2023 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The HTML Generator is omitting some pagenums
3 participants