![]() |
#1 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,050
Karma: 11391181
Join Date: Mar 2013
Location: Guben, Brandenburg, Germany
Device: Kobo Clara 2E, Tolino Shine 3
|
Assigning paragraph class to multiple paragraphs
I'm using a favourite css for my ebooks, containing a "standard" paragraph style with indented first line. There is also a paragraph class for some specific text as poetry etc. with no indenting, italics etc. Opening a book, for example in html, all text is, first of all, assigned to the standard paragraph style, also the poetry. As there are usually many linebreaks, every line appears as separate paragraph, each one indented etc. Until now I manually changed every line, assigning the "poetry" class to all. This is much work.
Is there a way to assign this specific paragraph style to the "bunch" of lines that contain poetry at once, removing the standard pareagraph style? I think this should be possible, but I simply don't find the trick. Sorry for my difficulties in explaining the problem in English! |
![]() |
![]() |
![]() |
#2 |
Groupie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 171
Karma: 86271
Join Date: Feb 2012
Device: iPad, Kindle Touch, Sony PRS-T1
|
it would help if you could post some of the code you're working with, but from what i understand of your question, you could assign styles to the children (<p> tags) of a container (a <div>) to save yourself some typing:
css: Code:
.myDiv p { text-indent:0; font-style:italic; } Code:
<div class="myDiv"> <p>Some Text</p> <!-- this will have the styles from .myDiv p --> </div> |
![]() |
![]() |
Advert | |
|
![]() |
#3 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,680
Karma: 23983815
Join Date: Dec 2010
Device: Kindle PW2
|
Quote:
(In Code View, you can also select Mark Text from the Context menu to limit search and replace operations to the selected text.) |
|
![]() |
![]() |
![]() |
#4 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,312
Karma: 20171571
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
|
If your "special" lines are not already marked in some way then you will have to manually go through the book to make changes. However, you can create a "clip" using the clip editor that will make this process much easier. All you need to do is highlight all the lines you want to "bundle" and then click on the clip to wrap the bundled lines in a container.
I use several but here are a couple of examples: Div: <div class="">\1</div> Block: <blockquote class="">\1</blockquote> Once I use the clip then I just fill in the class I want to use between the quote marks. I definitely use MZMM's technique: CSS (styled as you desire) .poetry {margin:2em} .poetry p {font-style:italic; text-indent:0} HTML <div class="poetry"> <p>line 1</p> <p>line 2</p> <p>line 3</p> ... </div> |
![]() |
![]() |
![]() |
#5 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,050
Karma: 11391181
Join Date: Mar 2013
Location: Guben, Brandenburg, Germany
Device: Kobo Clara 2E, Tolino Shine 3
|
Quote:
@Doitsu: How could I achieve the poems becoming unformatted, without changing the formatting manually, line by line? The effect is almost the same as described above. @Turtle91: Clip Editor, aha, that's probably what I need (first I have to look what is the German translation). Thanks to all! I really appreciate! |
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,470
Karma: 13095790
Join Date: Aug 2007
Location: Grass Valley, CA
Device: EB 1150, EZ Reader, Literati, iPad 2 & Air 2, iPhone 7
|
For poetry I tend to make a full stanza into one paragraph. I use <br /> for line breaks within the paragraph. This minimizes the need to adjust a large number of paragraphs. But it also minimizes the control you have over formatting but for me it works fine for the occasional poem or lyric in a prose document.
Dale |
![]() |
![]() |
![]() |
#7 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,050
Karma: 11391181
Join Date: Mar 2013
Location: Guben, Brandenburg, Germany
Device: Kobo Clara 2E, Tolino Shine 3
|
@mzmm: Reading it again, I think I now understood right the container trick. I'll try it soon.
|
![]() |
![]() |
![]() |
#8 | ||
frumious Bandersnatch
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,543
Karma: 19001583
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
Quote:
Quote:
By the way, I wouldn't recommend using <p> for poetry lines because they are in fact not paragraphs. One could argue that stanzas are sort of paragraphs, but not lines. I'd use <div> or <span> (with display:block). The latter is closer to the real semantics, the former has the advantage of displaying nicely even with CSS disabled (and the disadvantage that you cannot use <p> for stanzas with that). My usual setup: Code:
<div class="poetry"> <div class="stanza"> <div class="line">verse line</div> <div class="line2">verse line</div> <div class="line">verse line</div> <div class="line2">verse line</div> </div> <div class="stanza"> <div class="line">verse line</div> <div class="line2">verse line</div> <div class="line">verse line</div> <div class="line2">verse line</div> </div> </div> A bit too verbose, and one could dispose of the class="line" through CSS, but it's usually quite easy to apply this formatting to all kinds of poetry fragments. |
||
![]() |
![]() |
![]() |
#9 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,050
Karma: 11391181
Join Date: Mar 2013
Location: Guben, Brandenburg, Germany
Device: Kobo Clara 2E, Tolino Shine 3
|
Quote:
![]() |
|
![]() |
![]() |
![]() |
#10 |
Groupie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 171
Karma: 86271
Join Date: Feb 2012
Device: iPad, Kindle Touch, Sony PRS-T1
|
this is a bit tangential, but i'm actually kind of surprised that there's no plan to include semantic markup for poetry in HTML5. just came across this article which outlines different markup solutions for poetry, and proposes a, albeit kind of idealistic, set of poetry elements.
i'd actually also agree with Jellby that his <div class="stanza"><div class="line"> arrangement is semantically closer to poetic form than using paragraph elements. anyone tried concrete poetry with <pre/>? maybe i give it a go later on. |
![]() |
![]() |
![]() |
#11 |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,908
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Div, P will reflow, maintaining the style
I feel that Pre turn into total hash if a reflow is needed. |
![]() |
![]() |
![]() |
#12 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,050
Karma: 11391181
Join Date: Mar 2013
Location: Guben, Brandenburg, Germany
Device: Kobo Clara 2E, Tolino Shine 3
|
|
![]() |
![]() |
![]() |
#13 | |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,908
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
"The Moon is Blue not very often" Code:
Search: The (.+) is (.+) (not) Replace: The Sun is Red, \2 is \3 the color of the \1 |
|
![]() |
![]() |
![]() |
#14 | ||
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,306
Karma: 78876004
Join Date: Nov 2007
Location: Toronto
Device: Libra H2O, Libra Colour
|
Quote:
Quote:
|
||
![]() |
![]() |
![]() |
#15 |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,908
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Nothing like me missing the correct context of the question
![]() Basically using the \1 in the middle of a clip, wraps the clip around the selected text (AFAIK you can't multi select so \2> is not valid) |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Multiple Paragraphs in a Border | teh603 | Sigil | 5 | 08-01-2013 04:41 PM |
How to remove multiple class attribute from div | lrui | Recipes | 4 | 08-13-2012 09:47 PM |
Replace multiple matching instances within paragraph? | murphycc | Conversion | 2 | 02-23-2012 09:53 AM |
assigning styles to headings | kamanza | Sigil | 9 | 11-14-2011 04:41 AM |
Paragraph indent-size should not applied to centered paragraphs? | ShellShock | Calibre | 3 | 01-16-2010 11:54 AM |