Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 01-14-2021, 04:40 PM   #76
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,582
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
You also might find the Blitz CSS template useful for testing purposes.
Doitsu is offline   Reply With Quote
Old 01-14-2021, 06:19 PM   #77
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,506
Karma: 5433350
Join Date: Nov 2009
Device: many
Interesting ...

FWIW, that stylesheet uses things beyond the css 3.0 spec including @supports like the following:

Code:
@supports (height: 100vh) {
  /* Can be used for containers and images 
     but Should be used in combination with .portrait if used for img */
  .h-100 {
    height: 99vh;
    /* Trying to avoid blank page after */
  }
  .h-90 {
    height: 90vh;
  }
  .h-80 {
    height: 80vh;
  }
  .h-70 {
    height: 70vh;
  }
  .h-60 {
    height: 60vh;
  }
  .h-50 {
    height: 50vh;
  }
  .h-40 {
    height: 40vh;
  }
  .h-30 {
    height: 30vh;
  }
  .h-20 {
    height: 20vh;
  }
  .h-10 {
    height: 10vh;
  }
}
@supports is still considered experimental.

I will have to add support for it to the cssparser as it only supports css 3.0.
KevinH is offline   Reply With Quote
Old 01-14-2021, 10:00 PM   #78
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,506
Karma: 5433350
Join Date: Nov 2009
Device: many
Okay it turned out to be easy to add @supports to qcssparser (and to fix a typo in nestlevels). These changes were pushed to master.
KevinH is offline   Reply With Quote
Old 01-15-2021, 02:42 PM   #79
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,506
Karma: 5433350
Join Date: Nov 2009
Device: many
Okay as of today's master in Sigil/src/Query:

- added a way to catch exceptions and report parser errors in the resulting CSelection so it can be checked by the caller (so hopefully no more aborts or segfaults)

- fixed a bug in the *of-type related selectors

- added support for :root pseudo selector

- added support for :lang() which properly groks inheritance rules.

- filtered out psuedoelements that do not actually help select a node or that require user intervention like :hover, :before, :after, etc

So hopefully Query is now in a much better place than it started.

It passes all my basic tests now but I am going to create a standalone testing app to stress test my version of gumbo query and remove the simple testing added to main.cpp in Sigil.

That will probably take a while but should prove useful in finding bugs and query limitations.

I have added @supports and fixed a few bugs in cssparser2 and qcssparser. If anyone wants me to post these improved versions, just let me know.



Quote:
Originally Posted by wrCisco View Post
I played a little with the Sigil/gumbo-query integration. Seems nice, but I got it to crash with a number of selectors:
Code:
p:nth-of-type(2n-1)
p:lang(it)
p.flush::first-letter
p:focus
I thought it could have a problem with pseudo classes with function-like syntax as
Code:
nth-of-type(2n-1)
but then I tried
Code:
:not(.someclass)
and not only it didn't cause a crash, but it also correctly found a match.
(and since ::first-letter and :focus will never match anything, it will be mostly a problem for the css parser to filter them out).

At the same time, just for the sake of it, I started experimenting with integrating the cssRemoveUnusedSelectors plugin in the Sigil reports tool. I succeeded in report back to the "CSS Classes" widget in the Reports dialog all the usages of the selectors (with the complete list of the number of matches per html file).
I'm not sure how best to proceed about the deletion functionality: I thought maybe keeping around the parsed css rules as PyObjectPtr when the selector usages are reported, and then passing it back to python to perform the deletion, would be a good approach (but how could I pass a PyObjectPtr to a python function through the embeddedpython::runInPython interface?). Or maybe it might be better to execute twice the parsing of the stylesheets - once for the reporting and once for the deletion - and to pass back and forth only the indices of the enumerated rules and selectors?
KevinH is offline   Reply With Quote
Old 01-19-2021, 04:58 PM   #80
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,506
Karma: 5433350
Join Date: Nov 2009
Device: many
Hi All,

I have assembled a decent Selector test set and found many bugs and created a number of fixes in the gumbo query code. I also made minor changes to the cssparser code.

To make these more generally available, I have created two new Sigil-Ebook github repos
with both source sets and reverted them to their original licenses so they can more easily exchange bug fixes and changes with their original projects.

cssparser
- Is now available at: https://github.com/Sigil-Ebook/cssparser
- It is now under its original LGPL v2.1 license

and

sigil-query
- It is now available at: https://github.com/Sigil-Ebook/sigil-query
- It is now under its original MIT License

Both are pure C++ that does not need or use Qt.
KevinH is offline   Reply With Quote
Old 01-23-2021, 08:22 PM   #81
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,506
Karma: 5433350
Join Date: Nov 2009
Device: many
Okay, to at least test different approaches to solving this, I have the code to use the newly included qCSSParser and GumboQuery to determine if all CSS Selectors (not just classes) are used or not.

I loaded up your test case (see below) and Sigil will now properly remove just the selectors it should.

We still need to test if there are specific selectors in common use the will confuse either the qCSSParser or the Query code or cause them problems.

I have my fingers crossed, that this approach will be robust, if not, we will either just remove that feature and point people at wrCisco's current plugin or wait and try to integrate his code internal to Sigil.

Either way by the next release, this bug will be fixed one way of the other.

For now, I strongly recommend wrCisco's plugin for handling DeleteUnusedStyles in Sigil 1.4.3 (and all earlier versions of Sigil as well) if your style sheet uses pseudo classes, psuedo elements, and/or combinators.

Hope this helps.


Quote:
Originally Posted by AlanHK View Post
I was looking at an ePub with these styles:
(passes ePubCheck , no warnings).

Code:
.width-auto-rw .pc-rw { width: auto; }
.width-10-rw { width: 9%; }
.pc-rw { margin: 0; padding: 0; }
.pc-rw img { width: 100%; margin: 0; padding: 0; }
.pc-rw table { width: 100%; margin: 0; padding: 0; }
.pc-rw p { text-align: left; }
Used e.g. here to display an ornament:

Code:
<div class="width-10-rw">
               <div class="pc-rw"><img alt="" src="../Images/orncenter.gif"/></div>
            </div>

I run "Delete unused stylesheet classes" and the styles are reduced to

Code:
.width-auto-rw .pc-rw { width: auto; }
.width-10-rw { width: 9%; }
.pc-rw { margin: 0; padding: 0; }

The display of the image using the code above is now messed up, as it is not constrained by "width: 100%;".

It's very confusing to me all the definitions of "pc-rw" and it seems it also confused "Delete unused stylesheet classes".

I understand that
.a, .b, .c {margin: 0;}
means three identical styles. And
table.a {color: red;}
p.a {color:blue;}

makes two different styles, one for each of the base styles named.
But what does omitting the comma do?


Also, after doing the "Remove", the display in Sigil was unchanged.
I opened a few chapters to check and they all looked unchanged, so I felt safe to commit and saved the file. Then the image size went whacky.

Fortunately I had a backup of the file to restore the missing styles and try to work out what had gone wrong.

I know that the CSS is bizarre, but it is valid.
Trying to simplify it is why I start with "Remove".
KevinH is offline   Reply With Quote
Old 01-24-2021, 04:01 AM   #82
Frenzie
Wizard
Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.
 
Posts: 1,611
Karma: 724945
Join Date: Oct 2014
Location: Antwerp
Device: Kobo Aura H2O
Quote:
Originally Posted by KevinH View Post
I have assembled a decent Selector test set and found many bugs and created a number of fixes in the gumbo query code. I also made minor changes to the cssparser code.
Is the selector test suite also available somewhere?
Frenzie is offline   Reply With Quote
Old 01-24-2021, 11:10 AM   #83
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,506
Karma: 5433350
Join Date: Nov 2009
Device: many
Yes, in the sigil-query repo on our Github site.

https://github.com/Sigil-Ebook/sigil-query

If you build that project in the querytest folder you will build a querytester executable that groks the test_data.dat file and runs all of those tests. Note there are differences in case handling between xthml and html when it comes to attribute names and attribute values. We do case sensitive testing in those cases which xhtml requires.

Let me know if you need help understanding the format.

If you have any good testcases, I would be happy to add them.

Last edited by KevinH; 01-24-2021 at 01:06 PM.
KevinH is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
alphabetizing stylesheet, check book, and remove unused styles rjwse@aol.com Calibre 9 01-29-2020 06:48 PM
Pseudo classes to be deleted as unused classes Leonatus Sigil 2 09-23-2018 09:12 AM
"unused stylesheet class" is actually used AlanHK Sigil 6 06-20-2017 04:42 PM
Search and Replace; delete "author" name from "serie" roosten Library Management 6 12-17-2015 11:38 AM
Cleaning a stylesheet of unused styles roger64 Sigil 49 06-13-2012 05:23 AM


All times are GMT -4. The time now is 07:33 AM.


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