Replace newline chars in RichText Field

In a web application, users have entered text in a RTF like this:

Text with no actual content, text with no actual content, with no actual content at all, whatsoever. Text with no actual content, text with no actual content, with no actual content at all, whatsoever.

Text with no actual content, text with no actual content, with no actual content at all, whatsoever. Text with no actual content, text with no actual content, with no actual content at all, whatsoever, again and again.

Text with no actual content, text with no actual content, with no actual content at all, whatsoever. Text with no actual content, text with no actual content, with no actual content at all.

That is, after each paragraph, an extra Enter has been entered. In the effort of converting this to HTML editing (using for example Xinha), I’ve made an agent to find each paragraph and add a
tag as well (since after editing, the original newlines are of course removed/not converted to HTML).

BUT, here is the problem. The methods I’ve found to search through the RTF for “newlines” don’t give me the blank rows inbetween (se example above). When using the Example 2 code in the NotesRichTextRange class (Designer Help) it only prompt me with the “full paragraphs”.

So, how would you attack the issue above of replacing/inserting code in the example above to make in appear exactly like that in a WYSIWYG HTML editor…?

Subject: Replace newline chars in RichText Field

I’m not sure exactly what you are trying to accomplish, but it sounds like you want the content in Notes to appear the way it does in Xinha. If so, newlines are certainly not the only problem. You might want to take a look at our CoexEdit product, which allows you to edit on the web or in Notes. We have it integrated with Xinha, so it would be fairly simple for you to try and see if it addressed your needs.

If, on the other hand, you don’t want to edit in Notes but simply need the text with the newlines, you can export to DXL and look for the paragraph markers. The Notes rich text classes are probably bot robust enough for your needs, but the DXL import/export probably is.

Subject: RE: Replace newline chars in RichText Field

Thanks for your effort - it is the second alternative, no editing in Notes, but finding all the newlines in the RTF.Do you mind giving me a very quick intro how to use this DXL thing yiour talking of - what do I need to set up (only for this problem)?

Thanks again.

Subject: RE: Replace newline chars in RichText Field

“This DXL thing you’re talking of” means using the NotesDXLExporter to export the documents to Domino XML (DXL), looking for the elements using either the NotesDOMParser, the NotesSAXParser, or editing the text in a NotesStream, then re-importing the documents to the database using a NotesDXLImporter. The Designer Help examples for these objects and their methods are very good. If you are using the NotesDOMParser, the DOM methods are the same as you’d use with JavaScript on the web (except that variables are more strongly typed), so there’s LOTS of information out there.

Subject: RE: Replace newline chars in RichText Field

Thanks, I’ll give it a try and get back.

Subject: RE: Replace newline chars in RichText Field

OK, I’ve now tried the first part - to export the database with DXL, but I made the selection of only on of the forms in the db.This file was 20 MB. But the db filesize is approx 350 MB…! I presume this will be a HUGE textfile to cope with. Of course it could be done in parts, even if it’s more work.

Read this doc, which was very interesting: http://www.lotusgeek.com/SapphireOak/LotusGeekBlog.nsf/d6plinks/ROLR-6CTKKN

But, my question after reading it is - when I’ve changed the RTF called Body, is it possible to only update the documents with this field, NOT reimporting all of the documents information/re-creating the whole db?

And still, is this really the easiest (or only) way to accomplish a change of the RTF??

Subject: RE: Replace newline chars in RichText Field

Yes, it is the easiest way (without using a third-party product). You don’t have to export all of the documents; a NotesDocumentCollection is an allowed input, as is a NotesDocument.

Subject: RE: Replace newline chars in RichText Field

I should point out that there are third party products that could help, but this is certainly the easiest free way.

Subject: RE: Replace newline chars in RichText Field

Turns out it’s not Rich Text, Ben – just a textarea created using a multivalue text field. @Transform should do the trick.

Subject: RE: Replace newline chars in RichText Field

Hi, no it IS a RTF, but with the addition “Display Using HTML” which turns it into a .

Subject: *Agreed. @Transform should do it.

Subject: Replace newline chars in RichText Field

Hi,

I’m not sure to have understood your problem, but you can use
@ReplaceSubstring(“RTF_Field”;@NewLine;“BR>]” ) in Entry Conversion Object of
field to replace newline by
tag, thus when the document will be saved the
field value will be converted…

Thierry

Subject: RE: Replace newline chars in RichText Field

You mean the Input Translation formula?If so, it doesn’t exist on RichText Fields…

Subject: RE: Replace newline chars in RichText Field

"You mean the Input Translation formula?"Yes (sorry, I use a french version…)

“If so, it doesn’t exist on RichText Fields…”

Oops! you’re right.

In fact in one of my form I use a text field with “Allow multiples values” check on and in HTML attibuts I put “FONT FACE=ARIAL SIZE=2 ROWS=4 COLS=91 WRAP=Virtual” that simulates a RTF field in the browser (IE) and I can work with Input Translation formula and also I can manipulate the field value easily. (In my case, I don’t need to use Java applet and this field is only for text value)

Thierry

Subject: RE: Replace newline chars in RichText Field

OK, that is exatly the way it has been in this application for 4 years.But now, the users want to be able to copy Word-document content inte the field and edit in WYSIWYG mode, that’s why I’m asking.

Subject: RE: Replace newline chars in RichText Field

My copy of Xinha inserts a

tagset for each paragraph break in running text. The only way users should be able to insert unhandled line breaks is by using the direct HTML editor (<>), and those should be “properly” converted to have
tags by Domino for reading. (You can remove the (<>) button from the editor as well.)

Subject: RE: Replace newline chars in RichText Field

Yes Stan, I’ve noticed that. A new document edited with Xinha and hitting enter adds (correct I believe!) a paragraph tag.

BUT, this is how already created OLD documents, edited only by a ordinary TEXTAREA field on the web, and thereby entered newlines, can be converted by agent to display correctly when I’m about to change to Xinha in the design afterwards…!

I must admit that I think it would be most correct to replace every two following hard pagebreaks by a

tag. Every single pagebreak by a
. At least that is what I presume the users have “meant”…

PS. By hitting Shift-Enter you can get a hard pagebreak and not a new paragraph in Xinha.