10-30-2019, 11:03 PM | #1 |
Zealot
Posts: 100
Karma: 10
Join Date: Aug 2019
Device: none
|
Problem of sigil's html reformat
When I use sigil's html reformat function, it cause problem. It changes format in <pre></pre>, which should not be changed.
|
10-30-2019, 11:34 PM | #2 |
Grand Sorcerer
Posts: 27,606
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Must be a fairly old version, then. Sigil's Mend/Prettify has preserved the whitespace inside of pre tags for quite some time now.
Just ran a test on some pre formatted sections and Reformat Html didn't touch them. Do you have a small sample we can use to try to reproduce your issue (provided you verify you're using a recent version of Sigil)? Last edited by DiapDealer; 10-30-2019 at 11:41 PM. |
Advert | |
|
10-31-2019, 02:21 AM | #3 | |
Zealot
Posts: 100
Karma: 10
Join Date: Aug 2019
Device: none
|
Quote:
|
|
10-31-2019, 06:22 AM | #4 |
Grand Sorcerer
Posts: 27,606
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Yes. The prettify function is not infallible. If there's a lot of nested html inside a pre section, there's bound to be some line-break alteration. It's probably best not to prettify in those rare situations. The use of pre tags in epubs should be pretty judicious to begin with. It's too easy to create scenarios where content can overflow screen boundaries if not very careful.
|
10-31-2019, 07:42 AM | #5 | |
Groupie
Posts: 183
Karma: 266070
Join Date: Dec 2010
Device: Win7,Win10,Lubuntu,smartphone
|
Workaround
Quote:
Code:
code, pre {white-space: pre-wrap;} -- the stylesheet of any ebook containing code (manuals...) -- my user stylesheet in the viewer (calibre) and everything behaves, without preventing past©... If other viewers don't respect it, I feel strongly that they should... |
|
Advert | |
|
10-31-2019, 08:40 AM | #6 | |
Grand Sorcerer
Posts: 27,606
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
But regardless ... this isn't an issue of respecting or rendering. Sigil's Preview handles (and correctly honors) pre code-wrapped content sections just fine (including the pre-wrap css attribute you mentioned). The issue is whether Sigil's Prettyify html feature (found under the Reformat HTML menu) can potentially alter how that same content renders. And the answer is yes... it sometimes can. Luckily, though; un-Prettified xhtml renders just as correctly in Sigil's Preview. If you have complex pre/code sections with nested html inside that renders precisely how you want it to, it's in your best interest NOT to try and "Prettify" it with any kind of automatic tool. This kind of situation is exactly why we made "Reformat HTML" an optional, manual choice, rather than the continuously running process it used to be: so people could always choose "correct" over "pretty." Last edited by DiapDealer; 10-31-2019 at 08:44 AM. |
|
10-31-2019, 09:07 AM | #7 |
Zealot
Posts: 100
Karma: 10
Join Date: Aug 2019
Device: none
|
I understand. Thanks.
|
10-31-2019, 09:16 AM | #8 |
Groupie
Posts: 183
Karma: 266070
Join Date: Dec 2010
Device: Win7,Win10,Lubuntu,smartphone
|
Sorry--maybe there is some misunderstanding.
My comment was meant just for the quoted paragraph, which read 'almost' as a warning against <pre></pre> and <code></code>--or a hint towards some heavy manual editing. For my part, the only issues I have ever encountered came from the lack of {withespace: pre-wrap}--no more editing seems necessary. As I am just making manuals from some downloaded html pages, I would appreciate to known in advance if I happen to be wrong... Last edited by carmenchu; 10-31-2019 at 09:17 AM. Reason: change wording |
10-31-2019, 10:37 AM | #9 |
Sigil Developer
Posts: 7,736
Karma: 5446592
Join Date: Nov 2009
Device: many
|
The problem is the semantic only code tag wrapping the entire contents of the pre tag including text. I will look into modifying the Sigil source prettify to treat code tags just like pre. Or alternatively change the order so that the code wraps the pre tag since it is only a semantic marker.
|
10-31-2019, 11:28 AM | #10 | |
Grand Sorcerer
Posts: 27,606
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
But Sigil will allow you to use it and it will render it all correctly. You just might not be able to Prettify the code without altering how it renders (depending on if Kevin can make Prettify contend with the semantic-only code tags or not). |
|
10-31-2019, 12:03 PM | #11 |
Grand Sorcerer
Posts: 6,566
Karma: 84810789
Join Date: Nov 2011
Location: Tampa Bay, Florida
Device: Kindles
|
Of course someone is eventually going to come along with a book that uses the “white-space: pre” style on a div and complain that making it pretty messes up the rendering.
|
10-31-2019, 12:22 PM | #12 |
Grand Sorcerer
Posts: 27,606
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
INDD is notorious for inflicting “white-space: pre” on huge swathes of body content. Essentially making every line-break in the code relevant and thus unalterable.
|
11-04-2019, 11:51 AM | #13 |
Sigil Developer
Posts: 7,736
Karma: 5446592
Join Date: Nov 2009
Device: many
|
This should now be fixed in master as changing whitespace of anything inside a "code" tag whether wrapped in a pre or not really makes no sense.
|
11-12-2019, 05:05 PM | #14 | |
Guru
Posts: 668
Karma: 929286
Join Date: Apr 2014
Device: PW-3, iPad, Android phone
|
Quote:
There was some ascii art I did as a "p" style, which worked until Pretty trashed it. I made it a "pre" style and that worked. So I learned that Pretty did not parse CSS, only respected default tags. |
|
11-12-2019, 06:19 PM | #15 |
Sigil Developer
Posts: 7,736
Karma: 5446592
Join Date: Nov 2009
Device: many
|
Yes, the inheritance rules of css make it hard to easily determine which rules will impact which tags and in what way without doing a complete browser layout andparsing. Since users can change what css is active by changing the css file, it is never perfectly clear when to prettify, so we only use the tags.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Refresh files in Sigil when html files have changed outside Sigil | Echeban | Sigil | 43 | 10-29-2021 08:29 PM |
converting from HTML in Sigil | ralphiedee | Workshop | 4 | 03-23-2016 05:07 PM |
After changes to HTML in Sigil... | Education | Sigil | 24 | 03-18-2014 10:39 AM |
Problem with html -> Mobi conversion - html tags visible. | khromov | Calibre | 9 | 08-06-2011 11:25 AM |
Sigil freezes when I + HTML ebook. | Anarel | Sigil | 4 | 08-16-2010 11:13 AM |