![]() |
#1 |
Connoisseur
![]() Posts: 67
Karma: 10
Join Date: Jul 2023
Device: none
|
Another small Sigil bug
The preview seems to get out of sync with the code window when I use the float option with a picture. In the attached epub, if I scroll past the picture in line 348 and click on a paragraph in the preview window, the code window highlights a paragraph generally two paragraphs before the correct one.
|
![]() |
![]() |
![]() |
#2 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,439
Karma: 5702578
Join Date: Nov 2009
Device: many
|
Which direction? Are you clicking on CodeView to get Preview to sync too it. Or are you clicking on Preview to get CodeView to sync on it?
If the latter, CodeView should move to the start of that paragraph. |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,439
Karma: 5702578
Join Date: Nov 2009
Device: many
|
Okay, Your html code is invalid. You have an img nested inside a block element div inside a span inside a p tag with none of the closing tags being properly present.
This leads to tag paths being different since Preview fixes all of that whereas CodeView can not. So there is no way to actually sync anything between that image and anything following it. Simply run MendHTML by right clicking on the CodeView window. Then syncing with Preview will work just as expected. Last edited by KevinH; 08-22-2023 at 01:47 PM. |
![]() |
![]() |
![]() |
#4 | |
Connoisseur
![]() Posts: 67
Karma: 10
Join Date: Jul 2023
Device: none
|
Quote:
SOLVED - I changed the div to span and now it works. Last edited by jwes; 08-22-2023 at 02:35 PM. |
|
![]() |
![]() |
![]() |
#5 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,439
Karma: 5702578
Join Date: Nov 2009
Device: many
|
A div is a block element and can not be inside a p element.
It is important to note that just because a browser shows something does not make it valid xhtml / html. Most browsers including Preview will silently fix broken html on the fly. This leads to a disconnect between locations specified in Preview (that autofixes) and the "broken" code in CodeView. Which is why MendHTML exists as a tool as it builds the CodeView code up from the autofixed version of the DOM tree built by Preview or in this case the gumbo parser. Last edited by KevinH; 08-22-2023 at 02:41 PM. |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,439
Karma: 5702578
Join Date: Nov 2009
Device: many
|
FWIW, that code also has empty sup tags and other anomalies that should be cleaned up.
|
![]() |
![]() |
![]() |
#7 |
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 517
Karma: 8500000
Join Date: Aug 2013
Location: Hamden, CT
Device: Kindle Paperwhite (11th gen), Scribe, Kindle 4 Touch
|
Although the HTML presented was malformed, HTML 5 and XHTML 1.1 have removed the "p cannot contain a div" restriction...both are semantically identical as far as document structure is concerned.
Except for user-agent stylesheet differences between div and p (like p often having non-zero margin-top and margin-bottom), putting one inside the other generally renders the same, and doesn't generate a parsing error (Sigil's view accepts it fine). Also, div is only a block element by default (just like p, so the following lines render identically on almost every platform: Code:
<p>Testing <div style="display:inline">a div</div> inside a p</p> <div>Testing <p style="display:inline">a p</p> inside a div</div> |
![]() |
![]() |
![]() |
#8 | |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,439
Karma: 5702578
Join Date: Nov 2009
Device: many
|
As I tried to explain, how they render on browsers does not make it compliant. The browser parser itself will split that code and inject an ending p tag to prevent the issues when building its internal DOM - just like you can not embed a p tag inside another p tag.
That is what I meant by autofixing. See the current whatwg parsing code algorithm for details of when closing p tags are injected and why. See https://html.spec.whatwg.org/multipa...ng-main-inbody When the next thing to parse is: Quote:
This makes the code in CodeView be different from the code in Preview (as Preview follows these rules). The gumbo parser we use also follows these rules autofixing the code to match. That is what Mend HTML does. Last edited by KevinH; 08-23-2023 at 01:02 PM. |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Small Sigil bug | jwes | Sigil | 8 | 09-06-2023 12:48 PM |
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 html/css bug | twaits | Calibre | 5 | 01-12-2010 10:26 AM |