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 04-18-2024, 06:49 AM   #1
skil-phil
Connoisseur
skil-phil is kind to children and small, furry animalsskil-phil is kind to children and small, furry animalsskil-phil is kind to children and small, furry animalsskil-phil is kind to children and small, furry animalsskil-phil is kind to children and small, furry animalsskil-phil is kind to children and small, furry animalsskil-phil is kind to children and small, furry animalsskil-phil is kind to children and small, furry animalsskil-phil is kind to children and small, furry animalsskil-phil is kind to children and small, furry animalsskil-phil is kind to children and small, furry animals
 
skil-phil's Avatar
 
Posts: 57
Karma: 6698
Join Date: Sep 2022
Location: South Africa
Device: kindle pw10
css question

Is it possible to include a text string into a css property?
For example:

p.break {
text-align: center;
text: "this is a break";
}

Then use:
<p class="break"></p>

Thanks
skil-phil is offline   Reply With Quote
Old 04-18-2024, 07:12 AM   #2
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: 74,666
Karma: 130140792
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by skil-phil View Post
Is it possible to include a text string into a css property?
For example:

p.break {
text-align: center;
text: "this is a break";
}

Then use:
<p class="break"></p>

Thanks
What you want is to add in comments to the CSS. Here is the corrected CSS with a comment.

Code:
/* This is a break */
p.break {
  text-align: center;
  text-indent: 0;
}
JSWolf is offline   Reply With Quote
Advert
Old 04-18-2024, 08:12 AM   #3
Brett Merkey
Not Quite Dead
Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.
 
Posts: 194
Karma: 654170
Join Date: Jul 2015
Device: Paperwhite 4; Galaxy Tab
Yes, it is possible to use CSS to insert text into content. Use a pseudo-element.

Example:
Quote:
p.scenebreak::before {
display: block;
content: "❖ This is a scenebreak ❖";
font-size: 1.5em;
margin: .2em auto;
text-align: center;
text-indent: 0;
color: midnightblue;
}
Then insert <p class="scenebreak"></p> in the desired place.

Last edited by Brett Merkey; 04-18-2024 at 08:14 AM.
Brett Merkey is offline   Reply With Quote
Old 04-18-2024, 08:48 AM   #4
Quoth
the rook, bossing Never.
Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.
 
Quoth's Avatar
 
Posts: 11,693
Karma: 87663461
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper11
Quote:
Originally Posted by Brett Merkey View Post
Yes, it is possible to use CSS to insert text into content. Use a pseudo-element.
And which platforms does that work on?
I've never seen it used in actual ebooks.
What happens if Amazon converts the epub?
What does Calibre do on conversion to LRF, PDB, mobi/KF7, azw3/kf8? Logically the css should work like a macro and the conversion have the content text where the class is invoked.

But macros are one of the evil things in C and C++ with sometimes unexpected expansion. Unavoidable in Assembler.
Quoth is offline   Reply With Quote
Old 04-18-2024, 10:04 AM   #5
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: 29,985
Karma: 56143930
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
I agree with @quoth.


Just because CSS allows way more features , becaue. it was set for WEB pages.

An e-book only uses a small subset. Even then, the 'we know better' folk that outfitted you device, chose to ignore, or took the code easy way out (User adjustable WITH Publishers settings being Algebraic)

(and Posters, please verify your general comments on coding are generally Industry supported on mainstream e-readers )
theducks is offline   Reply With Quote
Advert
Old 04-18-2024, 02:08 PM   #6
Quoth
the rook, bossing Never.
Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.
 
Quoth's Avatar
 
Posts: 11,693
Karma: 87663461
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper11
Quote:
Originally Posted by JSWolf View Post
What you want is to add in comments to the CSS. Here is the corrected CSS with a comment.

Code:
/* This is a break */
p.break {
  text-align: center;
  text-indent: 0;
}
And this is a 100% correct answer if the OP wants to insert a comment in CSS.
It works on everything.
Quoth is offline   Reply With Quote
Old 04-18-2024, 02:28 PM   #7
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: 36,857
Karma: 147879470
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by Quoth View Post
And this is a 100% correct answer if the OP wants to insert a comment in CSS.
It works on everything.
I read it as the OP wanted to be able to have the text displayed at the scene break specified in the stylesheet. I've seen this done with some image based scene breaks.
DNSB is offline   Reply With Quote
Old 04-18-2024, 04:09 PM   #8
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: 29,985
Karma: 56143930
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by DNSB View Post
I read it as the OP wanted to be able to have the text displayed at the scene break specified in the stylesheet. I've seen this done with some image based scene breaks.
Actually: background-image might work for that case, but not text
theducks is offline   Reply With Quote
Old 04-18-2024, 04:39 PM   #9
lomkiri
Zealot
lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.
 
lomkiri's Avatar
 
Posts: 136
Karma: 1000102
Join Date: Jul 2021
Device: N/A
Quote:
Originally Posted by theducks View Post
Actually: background-image might work for that case, but not text
The form with text works in the viewer of calibre, in Foliate (linux), koreader (android) and, about eReaders, in Touch Lux 5. But not in Touch Lux 3.
lomkiri is offline   Reply With Quote
Old 04-18-2024, 05:08 PM   #10
Quoth
the rook, bossing Never.
Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.
 
Quoth's Avatar
 
Posts: 11,693
Karma: 87663461
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper11
Quote:
Originally Posted by DNSB View Post
I read it as the OP wanted to be able to have the text displayed at the scene break specified in the stylesheet. I've seen this done with some image based scene breaks.
I wasn't sure what the OP wanted, which is why my comment has an "if".

I'd just put the actual text in the p tags, but I don't do that kind of ebook editing.
Quoth is offline   Reply With Quote
Old 04-18-2024, 06:51 PM   #11
lomkiri
Zealot
lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.
 
lomkiri's Avatar
 
Posts: 136
Karma: 1000102
Join Date: Jul 2021
Device: N/A
Quote:
Originally Posted by Quoth View Post
I'd just put the actual text in the p tags, but I don't do that kind of ebook editing.
I didn't know the solution Brett gave. It may be very interesting for all type of repeated features, as the "three stars", for example. It gives the same ability for small parts of text as the CSS for the styles, or as the macros in LaTeX : it's possible to change the visual of all the breaks of an ebook (for example) just changing a unique line.

The restriction Theducks gave may nevertheless point to a serious problem, in case it isn't recognized by parts of the eReaders, It is still to be tested on more devices :-).

BTW, this feature survives to a conversion epub -> azw3 or pdf (using calibre).
lomkiri is offline   Reply With Quote
Old 04-18-2024, 07:27 PM   #12
Brett Merkey
Not Quite Dead
Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.
 
Posts: 194
Karma: 654170
Join Date: Jul 2015
Device: Paperwhite 4; Galaxy Tab
"...may be very interesting for all type of repeated features"
It certainly is. However, it is specially convenient in dealing with books that use whitespace alone for scene breaks. Whitespace is an irritating waste of space for me. The method of pseudo-elements can add a visual break without touching the HTML code or even altering the original CSS. This is easy when the whitespace is produced by adding space to any paragraph above or below where the break is wanted. Style a pseudo-element version of that paragraph and you are done. Presumably the original code will serve as a fallback if that is relevant. I've used the method only on Amazon and Samsung products for about 12 years so I do not know that range of support beyond that.

Last edited by Brett Merkey; 04-18-2024 at 07:40 PM.
Brett Merkey is offline   Reply With Quote
Old 04-18-2024, 08:26 PM   #13
Quoth
the rook, bossing Never.
Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.
 
Quoth's Avatar
 
Posts: 11,693
Karma: 87663461
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper11
Quote:
Originally Posted by lomkiri View Post
It may be very interesting for all type of repeated features, as the "three stars", for example. It gives the same ability for small parts of text as the CSS for the styles, or as the macros in LaTeX : it's possible to change the visual of all the breaks of an ebook (for example) just changing a unique line..
No, since the class will indicate and asterism, you can simply search and replace. There is no need for this, which is for web pages fed by servers not a distributed ebook.

Also in the source wordprocessing each kind of scene break indication can have a different style. That will map 1:1 to CSS and HTML.

You are right that white space scene breaks don't work as well in ebooks, especially on phone screens, where most are read.

There is zero need to utilize CSS as macros to insert content. It's actually more complicated and no easier to maintain and harder to generate.

It's for web page server side programming, which I've done, never for ebooks.
Quoth is offline   Reply With Quote
Old 04-18-2024, 08:34 PM   #14
Quoth
the rook, bossing Never.
Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.
 
Quoth's Avatar
 
Posts: 11,693
Karma: 87663461
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper11
Quote:
Originally Posted by Brett Merkey View Post
"...may be very interesting for all type of repeated features"
It certainly is. However, it is specially convenient in dealing with books that use whitespace alone for scene breaks. Whitespace is an irritating waste of space for me. The method of pseudo-elements can add a visual break without touching the HTML code or even altering the original CSS. This is easy when the whitespace is produced by adding space to any paragraph above or below where the break is wanted. Style a pseudo-element version of that paragraph and you are done. Presumably the original code will serve as a fallback if that is relevant. I've used the method only on Amazon and Samsung products for about 12 years so I do not know that range of support beyond that.
Explain what you mean in plain English. Are you editing someone else's published ebooks, or creating/publishing ebooks for people, and if so what format of source are you given?

There is no "Samsung" ebook platform.

Quote:
Style a pseudo-element version of that paragraph and you are done.
Frankly sounds more complicated and likely to fail than doing it the way most ebooks do it, with zero pseudo-elements.

There are many articles explaining why ebooks shouldn't slavishly copy printed books, especially novels. Replace white-space only scene breaks in the source is trivial as is reducing excessive white space that might be fine on a 9" hardback but not in an ebook.
Quoth is offline   Reply With Quote
Old 04-19-2024, 12:45 AM   #15
skil-phil
Connoisseur
skil-phil is kind to children and small, furry animalsskil-phil is kind to children and small, furry animalsskil-phil is kind to children and small, furry animalsskil-phil is kind to children and small, furry animalsskil-phil is kind to children and small, furry animalsskil-phil is kind to children and small, furry animalsskil-phil is kind to children and small, furry animalsskil-phil is kind to children and small, furry animalsskil-phil is kind to children and small, furry animalsskil-phil is kind to children and small, furry animalsskil-phil is kind to children and small, furry animals
 
skil-phil's Avatar
 
Posts: 57
Karma: 6698
Join Date: Sep 2022
Location: South Africa
Device: kindle pw10
Thanks to all for the comments and interesting discussion. Will try the suggestions later when back from work.
Thanks again.
skil-phil 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
A CSS question Woodssi Sigil 4 01-18-2022 08:36 PM
css question ralphiedee Sigil 74 12-23-2012 06:29 AM
CSS Question jackibar Sigil 24 03-01-2012 09:12 AM
CSS question crutledge Workshop 17 12-17-2011 07:52 AM
CSS Question AppleTard Calibre 1 06-12-2011 12:07 AM


All times are GMT -4. The time now is 09:14 AM.


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