Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 08-30-2025, 08:12 PM   #1
Dragen
Member
Dragen began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Feb 2012
Device: Kobo
Move text/code

Hello.

I'm doing a project, where I intend to make a whole series look the same because, sadly, the publisher decided it would look good to have different styles in various entries of the series.

But I've hit a snag. In most of the books, the first letter of the chapter is stylized.
Example:
Code:
<p class="flushleft"><span class="gray">T</span>he castle stood on rising ground half a kilometre from the river.</p>
Which is what I want.

But in some books, the publisher decided it would stylize a few words instead.
Example:
Code:
<p class="flushleft"><span class="gray">The castle stood</span> on rising ground half a kilometre from the river.</p>
And the perfectionist in me can't have that.

Is there a way to automate moving </span> in the first p-line in each chapter to after the first letter (and also ignoring symbols like ')?
Dragen is offline   Reply With Quote
Old 08-31-2025, 04:00 PM   #2
philja
Addict
philja will become famous soon enoughphilja will become famous soon enoughphilja will become famous soon enoughphilja will become famous soon enoughphilja will become famous soon enoughphilja will become famous soon enough
 
Posts: 276
Karma: 516
Join Date: Nov 2015
Location: Europe EEC
Device: Kindle Fire HD6 & HD8
You could try a regex find and replace. For me, this seems to work and copes with stuff like I'm.

Find: <span class="gray">([A-Z]{1})(.+)</span>
Replace: <span class="gray">\1</span>\2

Try it out cautiously.
philja is offline   Reply With Quote
Old 08-31-2025, 04:02 PM   #3
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,368
Karma: 20212733
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
***DOH! Ninja'd again!***

Use a find/replace. Something like this:

Find:
<p class="flushleft"><span class="gray">(.)(.*?)</span>

Replace:
<p class="flushleft"><span class="gray">\1</span>\2


Although that doesn't separate out lines that begin with quotes. For that you could do something like:

Find:
<p class="flushleft"><span class="gray">(\p{P}*?)(.)(.*?)</span>

Replace:
<p class="flushleft">\1<span class="gray">\2</span>\3

Last edited by Turtle91; 08-31-2025 at 04:10 PM.
Turtle91 is offline   Reply With Quote
Old 08-31-2025, 04:11 PM   #4
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: 47,108
Karma: 169815798
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
@Turtle91: Ninja'd. I should have been a bit faster. I went to quote your message and the information on quotes or other punctuation I was going to add was suddenly present.
DNSB is online now   Reply With Quote
Old 08-31-2025, 04:14 PM   #5
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,368
Karma: 20212733
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
Yeah...I realised I didn't answer the part about punctuation in the original, so I edited it to add that part...also realized philja beat me to the answer!
Turtle91 is offline   Reply With Quote
Old 08-31-2025, 04:23 PM   #6
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,368
Karma: 20212733
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
Personally, I don't like using the <span> technique for first letters...it can cause issues with searching, etc. because it breaks up the word. I use css to handle all the styling. If the user's device/app recognizes the css, then it looks great. If it doesn't support the css then they get a slightly reduced quality look...

Code:
CSS:
/* First Para in Chapter in lieu of Drop Caps */
p.first               {text-indent:0; font-size:1em; clear:both}
p.first::first-letter {font-family:serif; font-size:2em; font-weight:bold;
                       float:left; margin:-.1em .1em}
p.first::first-line   {font-variant:small-caps; font-size:1.15em}

HTML:
<p class="first">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
Click image for larger version

Name:	Screenshot 2025-08-31 162730.png
Views:	20
Size:	306.5 KB
ID:	217820

Last edited by Turtle91; 08-31-2025 at 04:28 PM.
Turtle91 is offline   Reply With Quote
Old 08-31-2025, 06:09 PM   #7
Dragen
Member
Dragen began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Feb 2012
Device: Kobo
Thank you all for the advice.

I ended up going with @Turtle91's CSS route.

But I have copied the regex options, for later experimentation.
Dragen is offline   Reply With Quote
Old Yesterday, 04:22 PM   #8
ElMiko
Evangelist
ElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileReadElMiko has read every ebook posted at MobileRead
 
ElMiko's Avatar
 
Posts: 480
Karma: 65460
Join Date: Jun 2011
Device: Kindle
@Turtle91 - presumably, though, the pseudo elements will fail on some number of epub 2 systems, whereas the spans will not, right?
ElMiko is offline   Reply With Quote
Old Today, 09:47 AM   #9
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,368
Karma: 20212733
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
Quote:
Originally Posted by ElMiko View Post
@Turtle91 - presumably, though, the pseudo elements will fail on some number of epub 2 systems, whereas the spans will not, right?
Possibly, but then it will look like a normal sentence. Both of those Pseudo elements have been around forever... like CSS 2 or something... so the chances of it not being honored are low, and only for really ancient devices.

The other option is having the spans break up the word/sentence on all devices. Pick your poison.
Turtle91 is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Move text from prior file foosion Editor 6 09-29-2024 04:20 PM
How To Move Text To The Right. Gibbo Editor 4 04-23-2022 06:51 PM
Move Footnote text above Footnotes after Conversion hidden.platypus Conversion 2 10-16-2016 09:12 AM
French text in Code View AUDRY Roger Sigil 7 11-10-2012 11:07 AM
text strike-out code? europas_ice Feedback 4 02-25-2009 12:17 PM


All times are GMT -4. The time now is 03:19 PM.


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