Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 08-08-2023, 06:55 PM   #1
jwes
Enthusiast
jwes began at the beginning.
 
Posts: 39
Karma: 10
Join Date: Jul 2023
Device: none
Small Sigil bug

I have been converting scanned texts to epubs and it occurred to me that if I put the original page numbers in a html comment, it would make finding the source of the text easier. There is one minor problem. If the comment appears in the middle of a paragraph and I click after the comment, it syncs the preview window to the top of the file. I have attached a small file to show the problem. Rename to .html and load the file into sigil and click on the word 'always' at the end of the file.
Attached Files
File Type: txt Section0001.txt (3.1 KB, 56 views)
jwes is offline   Reply With Quote
Old 08-08-2023, 07:10 PM   #2
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,676
Karma: 5433388
Join Date: Nov 2009
Device: many
Not a bug but expected behaviour. XHTML comments are not part of the parsed DOM tree. They are stripped out during parsing by the Chrome/Blink engine used by Preview so there is nothing in Preview to navigate to and visa-versa.

The correct way to indicate page numbers is with either an empty span with id to the upcoming page, or with the span wrapping the first word of a page with an id to that page. Not with xhtml comments. These in turn can be used to build actual page list links for the ncx or nav. I have seen people use "a" tags as well with no contents, just an id to act as the link destination.

And the best way to exactly sync Preview's location to CodeView and the reverse is to click on visible text shared by both.

Last edited by KevinH; 08-08-2023 at 07:31 PM.
KevinH is online now   Reply With Quote
Advert
Old 08-08-2023, 10:51 PM   #3
jwes
Enthusiast
jwes began at the beginning.
 
Posts: 39
Karma: 10
Join Date: Jul 2023
Device: none
I must not have explained myself very well. The page numbers are only for proofreading, so I can find the scanned image that goes with the text in Sigil, and the problem occurs when I click on visible text that is after the html comment, but in the same paragraph.
jwes is offline   Reply With Quote
Old 08-09-2023, 01:01 AM   #4
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 35,917
Karma: 145678910
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Forma, Clara HD, Lenovo M8 FHD, Paperwhite 4, Tolino epos
I can't duplicate your results here. If I open the preview window and click on the 'always' after the comment, that line is highlighted in CodeView. If I click on the text before the comment, CodeView highlights the line that starts the paragraph. See attached images.
Attached Thumbnails
Click image for larger version

Name:	before_comment.png
Views:	74
Size:	222.0 KB
ID:	203068   Click image for larger version

Name:	after_comment.png
Views:	63
Size:	225.7 KB
ID:	203069  

Last edited by DNSB; 08-09-2023 at 01:05 AM.
DNSB is offline   Reply With Quote
Old 08-09-2023, 09:12 AM   #5
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,676
Karma: 5433388
Join Date: Nov 2009
Device: many
I also tried your test case and I am seeing the exact same things as DNSB. If I click on the first "always" in Preview I get the start that paragraph in CodeView. In Preview if I click on the second "always" I get that line highlighted in CodeView.

Going the reverse direction, In CodeView if I click on the first "always": Preview moves to show it. If I click on the second "always", I do see Preview flick to the top. But I can still see that final line. Is that what you are referring to?

If additional tags with text exist after the xhtml-comment then Preview will properly reposition itself if you click on that text.

Again, the issue is that the xhtml comment does not have a node or position in the parsed DOM tree. So anything appended to the end of that missing node simply does not have a valid position to make Preview scroll to. It is effectivly attached to the end of the previous node's contents. A new tag pair after that will allow Preview to find things again as it has a node in the parsed DOM tree.

You just can not scroll Preview to something that does not exist. This is how all web browsers work. I can not change that.

To make Preview scroll you have to tell it which "node" in its internal DOM tree to scroll to. A node is a valid tag not an inline xhtml comment that gets stripped out.

As I explained before, If you want something unseen to mark places in your text instead of using xhtml comments use an empty span with a page number as the id, or an empty "a" tag with an id for the page number, or wrap the first word on the new page with a span tag and id based on page number instead of using xhtml comments. This has the added advantage of actually allowing you to jump directly to specific pages in final PageLists in the ncx and nav.

It is easy with TagMechanic or even Sigil using find and replace to find empty span tags with specific id formats and remove them if you no longer want them after editing.

Hope this explains things more clearly.

Last edited by KevinH; 08-09-2023 at 10:31 AM.
KevinH is online now   Reply With Quote
Advert
Old 08-09-2023, 10:43 AM   #6
jwes
Enthusiast
jwes began at the beginning.
 
Posts: 39
Karma: 10
Join Date: Jul 2023
Device: none
Quote:
Originally Posted by DNSB View Post
I can't duplicate your results here. If I open the preview window and click on the 'always' after the comment, that line is highlighted in CodeView. If I click on the text before the comment, CodeView highlights the line that starts the paragraph. See attached images.
Sorry, I over-simplified my example. It only happens when the preview shows a scrollbar and your screen resolution is greater than mine. Try this one.
Attached Files
File Type: txt Section0001.txt (5.2 KB, 50 views)
jwes is offline   Reply With Quote
Old 08-09-2023, 12:49 PM   #7
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,676
Karma: 5433388
Join Date: Nov 2009
Device: many
Okay from looking at your new test case:

1. clicking in Preview to sync CodeView works just fine as DNSB reported.

2. But clicking in CodeView to sync Preview, the command to scroll Preview will not be able to reach text immediately past an inline xhtml comment as the xhtml comment just does not exist in the Preview DOM tree.

I was able to "fix" this by ignoring inline xhtml comments when figuring out where to scroll Preview to. With this change, clicking in CodeView on the first "always" and clicking in CodeView on the second "always" will tell Preview to scroll to the parent p tag and not a missing inline xhtml comment. That way Preview will not skip to the "top" which is what it is supposed to do when the sync location fails.

I have pushed this change to master. It will appear in the upcoming release Sigil-2.0.0.
KevinH is online now   Reply With Quote
Old 09-06-2023, 12:35 PM   #8
jwes
Enthusiast
jwes began at the beginning.
 
Posts: 39
Karma: 10
Join Date: Jul 2023
Device: none
Quote:
Originally Posted by KevinH View Post
Okay from looking at your new test case:

1. clicking in Preview to sync CodeView works just fine as DNSB reported.

2. But clicking in CodeView to sync Preview, the command to scroll Preview will not be able to reach text immediately past an inline xhtml comment as the xhtml comment just does not exist in the Preview DOM tree.

I was able to "fix" this by ignoring inline xhtml comments when figuring out where to scroll Preview to. With this change, clicking in CodeView on the first "always" and clicking in CodeView on the second "always" will tell Preview to scroll to the parent p tag and not a missing inline xhtml comment. That way Preview will not skip to the "top" which is what it is supposed to do when the sync location fails.

I have pushed this change to master. It will appear in the upcoming release Sigil-2.0.0.
Running 2.0.0, if I have the code below in my HTML and click on the <hr line, it does not sync preview correctly.

<!-- Page 96 -->
<hr style="width:10%;text-align:left; margin-top: 1em;margin-left:0"/>
jwes is offline   Reply With Quote
Old 09-06-2023, 12:48 PM   #9
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,676
Karma: 5433388
Join Date: Nov 2009
Device: many
Again clicking on Text shown in both not void tags is the best way to sync back and forth.
KevinH is online now   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Small bug report Turtle91 Sigil 10 07-21-2017 07:15 PM
very small bug report cybmole Calibre Companion 10 05-22-2014 06:21 AM
Small cosmetic 'bug' At_Libitum Marvin 3 09-27-2013 05:10 PM
Small bug? Case-insensitive tags. Arrghus Calibre 9 07-12-2011 01:03 AM
Small html/css bug twaits Calibre 5 01-12-2010 10:26 AM


All times are GMT -4. The time now is 02:22 PM.


MobileRead.com is a privately owned, operated and funded community.