Extra <br> in html

General TRichView support forum. Please post your questions here
Post Reply
Hanno
Posts: 22
Joined: Sun Mar 05, 2006 12:28 pm

Extra <br> in html

Post by Hanno »

Hi Sergey,

In a TRichViewEdit I type in one word, followed by 2 carriage returns and then another word, so it looks like this:

Code: Select all

Hello

Sergey
When I save it to Html it writes code like this:
<p class=X><span class=X>Hello</span></p>
<p class=X><span class=X><br></span> </p>
<p class=X><span class=X>Sergey</span></p>

Which produces Html that renders an extra blank line like this:

Code: Select all

Hello


Sergey
I have just moved to v1.9.23 from v1.8 so I am noticing some differences here and maybe I am doing something wrong. But in CRVData.pas, in the function TCustomRVData.GetTextForHTML, the block of code at the top is adding the <br> tag when it shouldn't.

if (Result='') and IsFromNewLine(ItemNo) and
((ItemNo+1=ItemCount) or IsParaStart(ItemNo+1)) then begin
Result := Format('<br%s>', [RV_HTMLGetEndingSlash(SaveOptions)]);

I have commented out the line above in bold. Now when I save to html the html looks correct, but is this wrong to comment out this line?
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

In older versions, empty lines were saved as
<p> </p>
In newer versions, they are saved as
<p><br></p>

But both <br> and  ... They should not be together.
Can you send me this document as RVF file?
Hanno
Posts: 22
Joined: Sun Mar 05, 2006 12:28 pm

Post by Hanno »

Thanks Sergey, your reply pointed me in the right direction. Once I knew what it was supposed to be doing, I found the problem - I have some extra code that processes the html looking for the old way of doing things, and replacing the tags it found. So it was my code. Sorry for the trouble.
Post Reply