HTML code in Perl
Posted by TedH (TedH), 28 January 2005Graham, you're the whiz on this.
Got a simple blog, works fine. A user who downloaded the script from my site came back with a request to allow html tags to show (like below):
The log which this is entered in works and displays the coded tags properly until - the log either is added to or edited. Then the Entity, Hex or Decimal is replaced by standard code brackets and of course it all vanishes, leaving only say the actual html (links in this case example).
How does one enable the coded brackets to be left yet still allow other HTML code. I've tried "code" and "pre" but it gets overwritten anyway.
Hope you can help, thanks - Ted
Posted by admin (Graham Ellis), 29 January 2005Standard way to "webify" the contents of $_:
Think that's the sort of thing you're looking for
Posted by Custard (Custard), 29 January 2005Reckon you've been bitten by the same bug!
Theres a module for this. I'll see if I can remember what it's called.
Posted by TedH (TedH), 29 January 2005Hi guys,
Graham tried your bit and it worked fine for the inital log entry and a new entry.
However, when I edited any entry in that log, the code was changed to standard tags.
The script has 2 forms. One for log entry. Another for edits and the creation of new non-log files.
The 2nd form, when called for an edit shows the code in the textarea as standard tags. So, even though I've put your bit into the script like so:
The text area in the edit form seems to ignore it. Is there something else needed at this point?
ta muchly - Ted
Posted by admin (Graham Ellis), 30 January 2005Yes, Custard ... I have been bitten.
I swear I typed in something like ....
s / < / & l t ; / g ;
Posted by admin (Graham Ellis), 30 January 2005OK - that came through AOK.
Ted ... you need to convert as (correctly) shown in Custard's post rather than as got bashed by the YaBB software when I first posted - sorry about the confusion.
Where you get only partial conversion (something works one time but not another), have a careful look back at your code - it's very easy to set up the logic so that certain parts of the input get converted twice or not at all, especially when you're recalling for edit. I think my earlier post in this thread proved that point
Posted by TedH (TedH), 30 January 2005Hi, been a busy weekend, just got back.
Thanks, I'll have a go tomorrow at that and get back to you.
Don't know about where you guys are, but the wind is blinkin' cold here - roll on summer.
Posted by Custard (Custard), 30 January 2005Sunny south, New Milton, by the sea! Not too cold... yet!
Posted by admin (Graham Ellis), 31 January 2005Melksham, Wilts. Haven't stuck my head out the door yet tghis morning. 24 hours ago was on the Solent ... flat calm crossing from the Channel Islands. 7 days ago, Washington DC - now THAT was cold!
Posted by TedH (TedH), 31 January 2005New Milton eh, my wife's parents lived there (Hordle before). Her sister is still living there.
Dont' know Wiltshire much, only went through it on way to Somerset when my parents were alive (they had reitred there). Does get cold in Washington every now and then, that it does.
We're in Beckenham, Kent.
Posted by John_Moylan (jfp), 31 January 2005The two modules that I usually use for escaping & unescaping are:
URI::Escape (as the name inplies, this is for urls)
HTML::Entities; (this is more whats on discussion here)
Oh, and sunny Shepperton by the way
Posted by TedH (TedH), 6 February 2005I'll check out the modules - thanks.
Sorry didn't get back sooner been swamped.
Did try the code but when the edit form came up it had changed it all back to HTML.
Perhaps the modules will help on that.
Haven't been to Shepperton for many a year.
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: firstname.lastname@example.org • WEB: http://www.wellho.net • SKYPE: wellho