I have a plain text file that looks like this -
234234 some text
345435 some text
开发者_C百科23423 some text
I would like to convert this to HTML either by vbscript, perl or something else so that it looks nice when emailed out. That is maybe I can make the numbers Bolded etc.
Any ideas on how i can do this?
thanks
If your file is as simple as you have written, something like perl -ne 'chomp; s!^(\d+)!<b>$1</b>!; print "$_<br />\n"' inputfile.txt
will do what you have asked.
However if your source is any more complex than this, look into one of the many html formatting modules on CPAN
You can use some template processing system such as Template::Toolkit
.
For example: create a template for the email and store it in a perl variable or file. Then process the template providing some values to be filled in.
I'm guessing this is for an email blaster program? I'm also going to assume users of email blaster will probably paste "Microsoft Word text" and expect it to come out as perfectly compliant HTML emails?!?
If so first I recommend investigating the matrix of email clients and the subtle differences, then secondly for the job of converting text to HTML I'd recommend looking at the code in this project:
http://blog.tatham.oddie.com.au/2009/06/15/released-xhtml-markup-sanitizer/
Its good for the Garbage In Garbage Out problem, it just grabs text and xhtml sanitize it. You should here Tatham explain it, he demonstrated it at Remix 09 here is the link:
http://blog.tatham.oddie.com.au/2009/06/18/video-building-great-standards-based-websites-for-the-big-wide-world-with-asp-net-4-0/
精彩评论