MobileRead Forums

MobileRead Forums (https://www.mobileread.com/forums/index.php)
-   Sigil (https://www.mobileread.com/forums/forumdisplay.php?f=203)
-   -   <div missing after splits (https://www.mobileread.com/forums/showthread.php?t=335455)

ghogsett 12-08-2020 10:25 AM

<div missing after splits
 
Given:

<body>
<div class=...>
<h1 chapter 1
<hr>
<h1 chapter 2
</div>
</body>

After splitting on markers, the <div> </div> pair were missing from all the files. Had to put them in manually

KevinH 12-08-2020 10:47 AM

Where was your split marker put?

KevinH 12-08-2020 10:48 AM

And did you have the h1 tags properly ended with '>' chars which does not appear above.

DiapDealer 12-08-2020 10:48 AM

I can duplicate this in the latest github master. For others: here's a complete file suitable for testing.

Code:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title></title>
</head>

<body>
<div class="whatever">
<h1> chapter 1</h1>
<hr class="sigil_split_marker" />
<h1> chapter 2</h1>
</div>
</body>
</html>

Split at Cursor (cursor placed before the hr or the 2nd h1) preserves the containing div in the newly created file. When using Split at Markers the containing div is NOT preserved in the newly created file.

KevinH 12-08-2020 11:04 AM

Hmmm ... split at cursor is handled almost entirely within CodeViewEditor.cpp code with some help from Book.cpp, where as "split at markers" is handled completely outside the file or editor as it is meant to be recursive and possibly apply across multiple files.

I will look into this but there will always be some nested structures that will not survive splitting at certain points when using Split at Markers as opposed to splitting only once inside of a file using Split at Cursor.

To be safest, split at marker split points should be chosen by the user to be a direct child of the body tag. In this case the split at marker is a direct child of the div which typically indicates that this block should not be broken there as div are used to physically and logically group things. Ie. you typically want to split the body into multiple parts.

DiapDealer 12-08-2020 11:08 AM

Quote:

Originally Posted by KevinH (Post 4066758)
I will look into this but there will always be some nested structures that will not survive splitting at certain points when using Split at Markers as opposed to splitting only once inside of a file using Split at Cursor.

I thought I remembered there being subtle difference between the two split features RE nested structures. The div container is essentially a second body tag in this case. Structurally and stylistically there would be no difference between this and giving the body tags of files different classes if need be. But that's neither here nor there. :)

KevinH 12-08-2020 11:10 AM

If anyone still uses Sigil-0.8.X I would love to know if it exhibits this same behaviour.

KevinH 12-08-2020 12:11 PM

Yes, after checking the code for split at markers, this is not a bug but expected behaviour if the split marker is inserted at a point that is not a direct child of the body.

If you want to make a split at some point not a direct child of the body tag, then open that file in CodeView and position your cursor to the split point and use Split At Cursor.

KevinH 12-08-2020 01:22 PM

All of that said, there really is no sound reason to not properly handle nesting (or at least try to).
My worry when doing this is that other attributes will be copied as well including id attributes which would and could mess up Anchor Updating after splitting is done.

I have copied the approach of Split at Cursor and tried implementing it with Split At Markers.
I will tentatively commit this change to master and we can test it to make sure that any id attributes on any nested tags at break points do not cause problems.

If they do end up causing issues, we will revert it and Split at Cursor will be the only way for you to handle this case on a one by one basis.

Thank you for your bug report.


All times are GMT -4. The time now is 10:34 PM.

Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.