View Single Post
Old 11-27-2025, 10:54 AM   #1
LenaWolf
Member
LenaWolf began at the beginning.
 
LenaWolf's Avatar
 
Posts: 20
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.
LenaWolf is offline   Reply With Quote