Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
HTML code in Perl

Posted by TedH (TedH), 28 January 2005
Graham, 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):

Code:
<a href="#">Entity Coded Link</a>
<a href="#">Decimal Coded Link</a>
<a href="#">Hex Coded Link</a>



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 2005
Standard way to "webify" the contents of $_:

s/&/&/g;
s/</</g;
s/"/"/g;

Think that's the sort of thing you're looking for

Posted by Custard (Custard), 29 January 2005
Reckon you've been bitten by the same bug!

Code:
s/&/&amp;/g
s/</&lt;/g
s/"/&quot;/g


Theres a module for this. I'll see if I can remember what it's called.
(URL::Entity??)

b

Posted by TedH (TedH), 29 January 2005
Hi 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:

Code:
open (DFILE, "$filename");
while ($lines = <DFILE>) {
s/&/&/g;
s/</</g;
s/"/"/g;
$thedata .= $lines;
}
close (DFILE);


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 2005
Yes, Custard ... I have been bitten.

I swear I typed in something like ....

s / < / & l t ; / g ;

Posted by admin (Graham Ellis), 30 January 2005
OK - 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 2005
Hi, 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 2005
Sunny south, New Milton, by the sea!  Not too cold... yet!

b

Posted by admin (Graham Ellis), 31 January 2005
Melksham, 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 2005
New 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 2005
The 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
jfp

Posted by TedH (TedH), 6 February 2005
I'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.

- Ted



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho