Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 06-06-2025, 01:57 AM   #1
AxaRu
Member
AxaRu will become famous soon enoughAxaRu will become famous soon enoughAxaRu will become famous soon enoughAxaRu will become famous soon enoughAxaRu will become famous soon enoughAxaRu will become famous soon enough
 
Posts: 24
Karma: 624
Join Date: May 2013
Location: Moscow
Device: Kobo Aura H2o, Kobo Aura One, Kobo Forma
sigil ignores the pre-wrap tag and clears the document formatting

Bug.
Present in versions 2.5.0, 2.5.1, 2.5.2

Curent cersion: 2.5.2
Loaded Qt: 6.4.2

Tested on
OS: Linux Mint 22.1
Release: 22.1
Codename: xia

Bug description.

I have this class in my CSS file
Code:
p.function {
  white-space: pre-wrap;
  margin-top: 1.5em;
  font-family: listing;
  font-size: 0.9em;
  font-weight: normal;
  font-style: italic;
  text-align: left;
  color: darkblue;
  background-color: #CCFFFF;
  border-top: #00CCCC solid 2px;
}

In XHTML, I manually did the following formatting

Code:
    <p class="function">esp_err_t <span class="function_name">i2c_new_master_bus</span>(
        const i2c_master_bus_config_t *bus_config,
        i2c_master_bus_handle_t *ret_bus_handle)</p>
The resulting document looks like this
Click image for larger version

Name:	sigil_21_05_001.png
Views:	48
Size:	13.1 KB
ID:	216029

After I ran the Mend and Prettify All HTML Files command, Sigil removed all white space


Code:
    <p class="function">esp_err_t <span class="function_name">i2c_new_master_bus</span>( const i2c_master_bus_config_t *bus_config, i2c_master_bus_handle_t *ret_bus_handle)</p>
Аnd the resulting document looks like this
Click image for larger version

Name:	sigil_21_05_002.png
Views:	39
Size:	12.5 KB
ID:	216030
AxaRu is offline   Reply With Quote
Old 06-06-2025, 04:24 AM   #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: 8,759
Karma: 5706256
Join Date: Nov 2009
Device: many
It works as designed. You used no pre-wrap (pre) tag. Prettify assumes you want to actually change xhtml whitespace to prettify the layout. Prettifying has no idea about your css, it is run on xhtml source. If you want to preserve your pre-wrapped code, through the prettifying process you need to use the pre and code xhtml tags and not assume css is doing anything here as css can and does change independently of your xhtml. It was designed to do that.

So either use pre/code tags in your xhtml source before running Prettify or don't choose to Prettify the xhtml code.

Last edited by KevinH; 06-06-2025 at 12:57 PM.
KevinH is offline   Reply With Quote
Advert
Old 06-06-2025, 06:10 PM   #3
AxaRu
Member
AxaRu will become famous soon enoughAxaRu will become famous soon enoughAxaRu will become famous soon enoughAxaRu will become famous soon enoughAxaRu will become famous soon enoughAxaRu will become famous soon enough
 
Posts: 24
Karma: 624
Join Date: May 2013
Location: Moscow
Device: Kobo Aura H2o, Kobo Aura One, Kobo Forma
KevinH, thank you for your reply.

Here is a detailed explanation of how the tag works.
https://developer.mozilla.org/en-US/...SS/white-space

I understand how prettify works. I consider this behavior to be a bug.
In my case, instead of returning the carriage and inserting a series of spaces, I use the following code as a workaround:
Code:
<br/>\&\#160; \&\#160; \&\#160; \&\#160;
(No backslash needed)
This gives the desired result, but it's not very convenient.

Last edited by AxaRu; 06-06-2025 at 06:14 PM.
AxaRu is offline   Reply With Quote
Old 06-06-2025, 06:30 PM   #4
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: 8,759
Karma: 5706256
Join Date: Nov 2009
Device: many
Again, not a bug. Prettify works on xhtml content as designed. You need to add xhtml pre tag if you want to protect its contents from having whitespace modified and to be semantically correct you should probably be adding the code tag given your contents.

Again css can be used to pre-wrap whitspace, make an inline tag block, or make a block tag inline. The Prettify routine in Sigil ***ignores*** all css on purpose since css can change how normal tags are defined. So use the "pre" and "code" tags in xhtml to protect regions from whitespace being changed in Prettify, or just use Mend without Prettify.

There are other ways to deal with it but if all you want to do is indent a line, then define css for that line and provide a suitable text margin.

I personally would consider a series of non-breaking spaces to be a poor solution when pre tags and css exist to handle your case properly if you feel you must run Mend and Prettify instead of just running Mend.

Last edited by KevinH; 06-06-2025 at 06:37 PM.
KevinH is offline   Reply With Quote
Old 06-06-2025, 06:58 PM   #5
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: 46,155
Karma: 168983734
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Perhaps you could use a CSS based solution to your indent requirement which does involve replacing your spaces with a <br/> and using some CSS that I normally use to fake a list.

Code:
p.function {
  margin-top: 1.5em;
  font-family: listing;
  font-size: 0.9em;
  font-weight: normal;
  font-style: italic;
  text-align: left;
  color: darkblue;
  background-color: #CCFFFF;
  border-top: #00CCCC solid 2px;
  text-indent: -2.5em;
  margin-left: 2.5em;
  margin-right: 1.25em;
}
Code:
<p class="function">esp_err_t <span class="function_name">i2c_new_master_bus</span>(
<br/>const i2c_master_bus_config_t *bus_config,
<br/>i2c_master_bus_handle_t *ret_bus_handle)</p>
Please note that this will wrap to a single line when prettified and you will need to play with the alignment of the top border since the 2.5em margin will affect it.
DNSB is offline   Reply With Quote
Advert
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sigil Formating? Text won't wrap. StephanMatson Sigil 6 08-04-2016 11:43 PM
Sigil ignores some CSS-specified fonts tetrault Sigil 12 01-29-2016 10:43 AM
Using PRE tag San Zamoyski Kindle Formats 8 06-16-2015 06:13 AM
TABS DISAPPEAR FROM DOCUMENT - REVERT TO NO FORMATTING mibtp Sigil 20 02-20-2014 07:24 PM
Pre-formatting questions... Dahak LRF 4 06-25-2009 01:35 PM


All times are GMT -4. The time now is 05:54 AM.


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