[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] From based text to html converter



At 13.16 1998.04.03, Richard J. Sands wrote:
>the index paper, but we can't seem to convert the story which is pasted
>into a form box into HTML.  Are there any script out there that will take
>text pasted into a form and output html.  Mainly we need it to put
>paragraph breaks into the story to make it look good.   Any suggestions
>would be helpful.

Well, if all you need to do is put <P>'s in there, then a simple regex
should suffice.  There are usually two ways to do it, depending on your
text.  Your text should have either:

  1.  No newlines in paragraphs, only at the end of a paragraph
-or-
  2.  Newlines in paragraphs, and two newlines separating paragraphs

For 1., I would do something like (assuming you are using \015 for
newlines, adjust as necessary):

  $text =~ s/\015+/<P>\015/g;

For 2.:

  $text =~ s/\015{2,}/<P>\015/g;

Hope this helps.  This is not MacPerl-specific, so please keep followups to
e-mail.

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10  1FF7 7F13 8180 B6B6'])
#==               New Book:  MacPerl: Power and Ease               ==#
#==    Publishing Date: Early 1998. http://www.ptf.com/macperl/    ==#



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch