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

Go Back   MobileRead Forums > E-Book Software > Calibre > Editor

Notices

Reply
 
Thread Tools Search this Thread
Old 01-24-2020, 03:00 PM   #1
Phssthpok
Evangelist
Phssthpok knows how to set a laser printer to stun.Phssthpok knows how to set a laser printer to stun.Phssthpok knows how to set a laser printer to stun.Phssthpok knows how to set a laser printer to stun.Phssthpok knows how to set a laser printer to stun.Phssthpok knows how to set a laser printer to stun.Phssthpok knows how to set a laser printer to stun.Phssthpok knows how to set a laser printer to stun.Phssthpok knows how to set a laser printer to stun.Phssthpok knows how to set a laser printer to stun.Phssthpok knows how to set a laser printer to stun.
 
Posts: 467
Karma: 95229
Join Date: Nov 2014
Device: Horrible Kindle
4.9 Check Book CSS warning

Since updating to 4.9, I get a warning ("You have 2 h1s defined") for CSS like this:
Code:
h1 { ... }
h1.chapter { ... }
Why should this be? What is wrong with doing this (defining rules for H1 in general, and additional rules for H1s with class="chapter")?

Edit: Also, it turns out, for rules "h1.a" and "h1.b".

Last edited by Phssthpok; 01-24-2020 at 03:03 PM.
Phssthpok is offline   Reply With Quote
Old 01-24-2020, 07:18 PM   #2
phossler
Guru
phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.
 
Posts: 864
Karma: 295056
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
Same here using 4.9.1 - didn't used to do that

I know it's only a warning, but I think it's a wrong warning since I think it's allowed by the CSS gods


From the 'detailed description' link

Quote:
Headings should only be defined once

Object-Oriented CSS (OOCSS) works by defining reusable objects that can be put into place anywhere on a site and appear exactly the same. The heading elements (h1-h6) are considered to be built-in objects that should look the same regardless of where they appear. As such, each heading should have exactly one rule defining its appearance. Multiple rules defining the same heading appearance can lead to objects that are hard to use because the context defines the appearance rather than being completely atomic.
Attached Thumbnails
Click image for larger version

Name:	Capture.JPG
Views:	33
Size:	96.7 KB
ID:	176638  
phossler is offline   Reply With Quote
Old 01-24-2020, 07:50 PM   #3
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 55,497
Karma: 51439670
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Aura H2O, Sony PRS-650, Sony PRS-T1, nook STR, iPad 4, iPhone 5
Yes it's allowed to have CSS like the example. But really, it's poor code.
JSWolf is offline   Reply With Quote
Old 01-24-2020, 08:02 PM   #4
hobnail
Running with scissors
hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.
 
Posts: 193
Karma: 1025332
Join Date: Nov 2019
Device: none
That "only defined once" rule seems bad to me. What I have in my standard stylesheet is like the following. All the common shared stuff in one rule and then the size stuff in separate rules. Following their rule would make maintenance a hassle since you'd have to duplicate stuff using copy and paste. As a programmer I learned that copy and paste was a bad "code smell".

Code:
h1, h2, h3, h4 {
    break-inside: avoid;
    break-after: avoid;
    font-weight: bold;
    hyphens: none;
    margin-bottom: 0em;
    margin-top: 1em;
    page-break-after: avoid;
    page-break-inside: avoid;
    text-align: center;
    text-indent: 0em;
}

h1 {
    font-size: 1.44em;
}

h2 {
    font-size: 1.3em;
}

h3 {
    font-size: 1.12em;
}

h4 {
    font-size: 1em;
}
hobnail is offline   Reply With Quote
Old 01-24-2020, 08:12 PM   #5
phossler
Guru
phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.
 
Posts: 864
Karma: 295056
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
@JSWolf -- Why is it 'poor code'?

@hobnail -- I agree. Easier to maintain, clearer, and less redundancy
phossler is offline   Reply With Quote
Old 01-24-2020, 09:18 PM   #6
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 55,497
Karma: 51439670
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Aura H2O, Sony PRS-650, Sony PRS-T1, nook STR, iPad 4, iPhone 5
@hobnail, when you have classes together like in your CSS, Calibre will not remove any of the unused classes.

Code:
h1 {
  font-size: 1.44em;
  font-weight: bold;
  hyphens: none;
  margin-bottom: 0;
  margin-top: 1em;
  page-break-after: avoid;
  page-break-inside: avoid;
  text-align: center;
  text-indent: 0;
}
h2 {
  font-size: 1.3em;
  font-weight: bold;
  hyphens: none;
  margin-bottom: 0;
  margin-top: 1em;
  page-break-after: avoid;
  page-break-inside: avoid;
  text-align: center;
  text-indent: 0;
}
h3 {
  font-size: 1.12em;
  font-weight: bold;
  hyphens: none;
  margin-bottom: 0;
  margin-top: 1em;
  page-break-after: avoid;
  page-break-inside: avoid;
  text-align: center;
  text-indent: 0;
}
h4 {
  font-size: 1em;
  font-weight: bold;
  hyphens: none;
  margin-bottom: 0;
  margin-top: 1em;
  page-break-after: avoid;
  page-break-inside: avoid;
  text-align: center;
  text-indent: 0;
}
That is much nicer code.
JSWolf is offline   Reply With Quote
Old 01-24-2020, 10:13 PM   #7
Tex2002ans
Wizard
Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.
 
Posts: 1,444
Karma: 7010529
Join Date: Jul 2012
Device: Kobo Forma, Nook
Quote:
Originally Posted by phossler View Post
Same here using 4.9.1 - didn't used to do that
Agreed. Perhaps it was some recent addition.

In the Calibre 4.9.1 release notes it mentions:

Quote:
Edit book: The Check book function has a new, improved CSS checker with support for CSS 3
Perhaps this was an accidental regression that was introduced.

Quote:
Originally Posted by phossler View Post
I know it's only a warning, but I think it's a wrong warning since I think it's allowed by the CSS gods

From the 'detailed description' link
Here's the exact URL the "detailed description" links to:

https://github.com/CSSLint/csslint/w...e-defined-once

... very odd. I don't agree with that at all.

I can understand Check Book pointing out an (accidental) duplicate in your CSS:

h1, h2, h3, h4 { }
h2 { }
h2 { }

but pointing out ones that aren't the same?

h2
h2.title
h2.author

Quote:
Originally Posted by JSWolf View Post
That is much nicer code.
No. I'll have to agree with phossler and hobnail on this one.

Sometimes it's easier to have a centralized location for shared CSS, and then specific overrides in a different location.

Side Note: And I would strongly recommend against adding hyphens: none though. Think big words ("Acknowledgements"), with big font, on tiny devices (cell phone). Just leave that setting up to user devices/preferences.

Last edited by Tex2002ans; 01-24-2020 at 10:18 PM.
Tex2002ans is offline   Reply With Quote
Old 01-24-2020, 10:27 PM   #8
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 18,415
Karma: 30697406
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by JSWolf View Post
@hobnail, when you have classes together like in your CSS, Calibre will not remove any of the unused classes.

Code:
h1 {
  font-size: 1.44em;
  font-weight: bold;
  hyphens: none;
  margin-bottom: 0;
  margin-top: 1em;
  page-break-after: avoid;
  page-break-inside: avoid;
  text-align: center;
  text-indent: 0;
}
h2 {
  font-size: 1.3em;
  font-weight: bold;
  hyphens: none;
  margin-bottom: 0;
  margin-top: 1em;
  page-break-after: avoid;
  page-break-inside: avoid;
  text-align: center;
  text-indent: 0;
}
h3 {
  font-size: 1.12em;
  font-weight: bold;
  hyphens: none;
  margin-bottom: 0;
  margin-top: 1em;
  page-break-after: avoid;
  page-break-inside: avoid;
  text-align: center;
  text-indent: 0;
}
h4 {
  font-size: 1em;
  font-weight: bold;
  hyphens: none;
  margin-bottom: 0;
  margin-top: 1em;
  page-break-after: avoid;
  page-break-inside: avoid;
  text-align: center;
  text-indent: 0;
}
That is much nicer code.
I so disagree with that. What you have means there means that if you want to change the overall style of the headers, say from centred to on the right, you have to do it in four places instead of one. Ugly, inefficient, a pain to maintain and prone to error.
davidfor is offline   Reply With Quote
Old 01-24-2020, 11:44 PM   #9
hobnail
Running with scissors
hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.
 
Posts: 193
Karma: 1025332
Join Date: Nov 2019
Device: none
Quote:
Originally Posted by JSWolf View Post
@hobnail, when you have classes together like in your CSS, Calibre will not remove any of the unused classes.
I can live with a few unused classes in the CSS when I have cleaner and easier to maintain CSS.
hobnail is offline   Reply With Quote
Old 01-24-2020, 11:47 PM   #10
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 36,107
Karma: 15014853
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You will have to argue with the developers of csslint as to why they make that recommendation. But I agree that check book in general should avoid stylistic checks, and I have already turned most of them off, must have missed that one.
kovidgoyal is offline   Reply With Quote
Old 01-25-2020, 07:35 AM   #11
Phssthpok
Evangelist
Phssthpok knows how to set a laser printer to stun.Phssthpok knows how to set a laser printer to stun.Phssthpok knows how to set a laser printer to stun.Phssthpok knows how to set a laser printer to stun.Phssthpok knows how to set a laser printer to stun.Phssthpok knows how to set a laser printer to stun.Phssthpok knows how to set a laser printer to stun.Phssthpok knows how to set a laser printer to stun.Phssthpok knows how to set a laser printer to stun.Phssthpok knows how to set a laser printer to stun.Phssthpok knows how to set a laser printer to stun.
 
Posts: 467
Karma: 95229
Join Date: Nov 2014
Device: Horrible Kindle
Quote:
Originally Posted by JSWolf View Post
Yes it's allowed to have CSS like the example. But really, it's poor code.
On the other hand, it also warns if you don't have a rule for h1, but just two rules for h1.a and h1.b. Changing them to .a and .b makes the warning go away. It seems wrong to be forced to reduce specificity like that.
Phssthpok is offline   Reply With Quote
Old 01-25-2020, 07:37 AM   #12
Phssthpok
Evangelist
Phssthpok knows how to set a laser printer to stun.Phssthpok knows how to set a laser printer to stun.Phssthpok knows how to set a laser printer to stun.Phssthpok knows how to set a laser printer to stun.Phssthpok knows how to set a laser printer to stun.Phssthpok knows how to set a laser printer to stun.Phssthpok knows how to set a laser printer to stun.Phssthpok knows how to set a laser printer to stun.Phssthpok knows how to set a laser printer to stun.Phssthpok knows how to set a laser printer to stun.Phssthpok knows how to set a laser printer to stun.
 
Posts: 467
Karma: 95229
Join Date: Nov 2014
Device: Horrible Kindle
Quote:
Originally Posted by kovidgoyal View Post
You will have to argue with the developers of csslint as to why they make that recommendation. But I agree that check book in general should avoid stylistic checks, and I have already turned most of them off, must have missed that one.
So... is there a way to turn it off? Please?
Phssthpok is offline   Reply With Quote
Old 01-25-2020, 10:22 AM   #13
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 24,613
Karma: 34133341
Join Date: Aug 2009
Location: The Central Coast of California
Device: K4NT(RIP), Galaxy Tab A, Kobo Aura2
I am not happy with the stylistic warnings...

BUT I am really unhappy that they (and others) pop a RED Error shield, when that, IMHO, should just be the older Yellow warning (fix me if you care )
theducks is online now   Reply With Quote
Old 01-25-2020, 10:42 AM   #14
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 36,107
Karma: 15014853
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Quote:
Originally Posted by Phssthpok View Post
So... is there a way to turn it off? Please?
Umm wait for the next release when I will disable it along with the rest of the stylistic checks that I have already disabled.
kovidgoyal is offline   Reply With Quote
Old 01-25-2020, 10:44 AM   #15
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 36,107
Karma: 15014853
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Quote:
Originally Posted by theducks View Post
I am not happy with the stylistic warnings...

BUT I am really unhappy that they (and others) pop a RED Error shield, when that, IMHO, should just be the older Yellow warning (fix me if you care )
Which stylistic warnings (apart from this one that I missed) give you errors rather than warnings?
kovidgoyal 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
Hyphens warning in "check book" Phssthpok Editor 5 12-08-2015 05:47 AM
Check non existent css styles Terisa de morgan Editor 15 06-15-2014 11:24 AM
Calibre Catalog CSS Warning phossler Library Management 2 03-11-2014 12:08 AM
Kindlegen warning about css sderrick Kindle Formats 1 04-17-2012 05:24 AM
Epub check warning, help! Janephew91 ePub 3 10-01-2011 02:23 PM


All times are GMT -4. The time now is 05:17 PM.


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