|
|||||||
![]() |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
Member
![]() Posts: 22
Karma: 10
Join Date: Oct 2025
Device: Sony PRS-T3, Kobo Libra Colour
|
Transform HTML - Insert HTML after tag - does not insert immediately after tag
Hi,
I want to insert a short HTML snippet after every <br/> tag, but I want it to be immediately after the tag. However, when I specify the rule "Insert HTML after tag", the snippet is inserted before the next tag instead of immediately after <br/>. How can I fix it, please? Now in more detail. I have the following HTML: <p class="P-P500 c_odt5"> <span class="S-Drop_20_Caps">I </span>never... blablabla more text. <br/> "I told you - blablabla more text.</p> I would like to have the following snippet inserted immediately after <br/>: <span class="drop_caps_tab"/> So I click Convert books -> Look and Feel -> Transform HTML, and there I add a new rule: if tag is br, insert HTML after tag, and I type in the above HTML for <span>. Then I run the conversion. I have several places in the document where this rule applies, and the results vary quite a bit, but my <span> code is never inserted immediately after <br/> but instead it is inserted immediately before the next tag or before the closing of the wrapper tag, which is not what I want. Here are some examples of what I get as a result: <p class="p-body_20_text_20_first_20_paragraph"> <span class="s-drop_20_caps">I </span>never... blablabla <br class="calibre2"/> "I told you...blablabla <span class="drop_caps_tab"></span></p> (In this case my <span> was inserted before the closing tag </p>.) <p class="p-body_20_text_20_first_20_paragraph"> <span class="s-drop_20_caps">F</span>inally!" Agatha...text. <br class="calibre2"/> "<span class="drop_caps_tab"></span><span class="calibre">I was</span>n't worried,"...blablabla</p> (In this case, my <span> was inserted before the next <span> element that was in the code already.) My question is then: how to make my snippet be inserted immediately after <br/>? I want the following result: <br/><span class="drop_caps_tab"/> I don't want anything in between, and certainly none of my text. I already tried all other options in the rules but still cannot get it to work. I can get tags inserted before <br/> but not after.
|
|
|
|
|
|
#2 |
|
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 68
Karma: 582370
Join Date: Apr 2023
Device: Kobo Clara 2E, Pocketbook Inkpad 4
|
Personally, I would not use Transfer HTML for this; I would use Search and Replace.
Search for <br/> and replace with <br/><span class="drop_caps_tab"/>. That said you appear to be missing the closing </span> tag. This would make the search slightly more complicated as you would need account for the closing tag in your search. So for the example given, I suggest: Search for <br/>\n("?[A-Z]) and replace with <br/><span class="drop_caps_tab"/>\n\1</span>. |
|
|
|
| Advert | |
|
|
|
|
#3 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,701
Karma: 9500498
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
|
Yes, I also would use a Search and Replace in the Editor, rather than fiddling with a conversion rule.
|
|
|
|
|
|
#4 | |
|
Member
![]() Posts: 22
Karma: 10
Join Date: Oct 2025
Device: Sony PRS-T3, Kobo Libra Colour
|
Quote:
![]() I am not missing the closing tag, these are both self-closing tags because they have /> in the end. I actually want an empty <span/> tag inserted because of the properties that it brings - it is simulating a tab through padding like so: .drop_caps_tab { padding-left: 0.6cm; } Last edited by LenaWolf; Yesterday at 07:56 PM. Reason: Added CSS code for clarity. |
|
|
|
|
|
|
#5 | |
|
Still reading
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 15,173
Karma: 111120239
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper
|
Quote:
|
|
|
|
|
| Advert | |
|
|
|
|
#6 |
|
Member
![]() Posts: 22
Karma: 10
Join Date: Oct 2025
Device: Sony PRS-T3, Kobo Libra Colour
|
|
|
|
|
|
|
#7 | |
|
Still reading
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 15,173
Karma: 111120239
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper
|
Quote:
There normally should be zero <br /> in body. Vertical spacing should be by class. The only case I know that needs a <br /> is to break a title/heading onto two lines so automatic ToC generation sees it as one entry. Otherwise it's an obsolete throw back to before styles or classes. A <br /> is like typing enter twice in the source. I search and delete blank lines, leading spaces, trailing spaces and tabs. I replace all spaces more than one with one. Any <br /> in body text can he replace by single Search & Replace of </p> <p class="whatever"> Where css of whatever defines a top margin and desired indent, left, right etc. |
|
|
|
|
|
|
#8 | |
|
Member
![]() Posts: 22
Karma: 10
Join Date: Oct 2025
Device: Sony PRS-T3, Kobo Libra Colour
|
Quote:
So my line breaks are not used to achieve vertical spacing at all but to make a work-around for full-sized drop caps in PDF which then needs to be smoothed over in ePUB. But I've got it figured out!
|
|
|
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Insert Tag: separate two sections by a small space to minimise user error | paperback | Editor | 3 | 05-30-2022 06:53 AM |
| 1. calibre_bookmarks.txt / 2. insert tag | jiembe | Calibre | 5 | 12-05-2020 12:14 PM |
| html to EPUB - added class into <html> tag | etihwmot | Conversion | 25 | 08-05-2020 05:20 PM |
| html img tag versus svg wrapped image tag | hobnail | ePub | 8 | 02-27-2020 04:16 AM |
| Some questions or possible enhancements on Insert Tag tool? | arspr | Editor | 6 | 05-10-2014 03:22 PM |