Forum Moderators: bakedjake

Message Too Old, No Replies

converting linefeed characters

         

SlowMove

6:04 pm on Dec 26, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm converting several *.txt files to html. Does anyone know how to convert every linefeed character to "<br>"?
I figure there's probably a way to do it using sed or awk, but I was unable to find it.

IcedCardeo

6:15 pm on Dec 26, 2003 (gmt 0)

10+ Year Member



Well, I know this isn't much help [ sorry :) ] but to tell you the truth, I didn't really understand/know that it is possible! To be able to convert files like in a "raw" format sounds interesting as all heck :D.

Well, I do know about converting things like .wma (eew) to .mp3 (yay!).

Longhaired Genius

7:01 pm on Dec 26, 2003 (gmt 0)

10+ Year Member



This is dead easy. What you need is a text editor that will find and replace with regular expressions (like HTML-Kit or Note Tab Lite - both free).

To replace newlines with <br>: search for \n replace with <br>\n (select the regular expression option).

What would probably be more use would be to replace double newlines with paragraph tags, to do this: search for \n\n replace with </p>\n\n<p> (select the regular expression option and add the very first <p> and very last </p> yourself).

SlowMove

7:16 pm on Dec 26, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The only problem is the number of text files. It needs to be batch processed. I searched around and found it:

textinputfile ¦ sed 's/$' "/<br>/" >> outputfile

Thanks for the help.