![]() |
#1 |
Member
![]() 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> 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> 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 ')? |
![]() |
![]() |
![]() |
#2 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() 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. |
![]() |
![]() |
![]() |
#3 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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. |
![]() |
![]() |
![]() |
#4 |
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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.
|
![]() |
![]() |
![]() |
#5 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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!
![]() |
![]() |
![]() |
![]() |
#6 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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>
Last edited by Turtle91; 08-31-2025 at 04:28 PM. |
![]() |
![]() |
![]() |
#7 |
Member
![]() 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. |
![]() |
![]() |
![]() |
#8 |
Evangelist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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?
|
![]() |
![]() |
![]() |
#9 | |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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:
The other option is having the spans break up the word/sentence on all devices. Pick your poison. |
|
![]() |
![]() |
![]() |
|
![]() |
||||
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 |