Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^5: Thanks to Ikegami, Chromatic & Corion

by Logicus
on Nov 02, 2011 at 02:27 UTC ( #935268=note: print w/ replies, xml ) Need Help??


in reply to Re^4: Thanks to Ikegami, Chromatic & Corion
in thread Thanks to Ikegami, Chromatic & Corion

Erm... something ain't right, I just hacked your escapes code in and it's converted every "<" and ">" in the whole document!

output ------ &lab;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "ht +tp://www.w3.org/TR/html4/loose.dtd"&rab; &lab;html lang="en"&rab; &lab;head&rab; &lab;link href="/css/main.css" rel="stylesheet" type="text/css"&ra +b; &lab;null&rab; &lab;link href="/css/colours/daytime.css" rel="stylesheet" type="t +ext/css"&rab; &lab;script type="text/javascript" src="/js/ajax.js"&rab;&lab;/scr +ipt&rab; &lab;meta http-equiv="Content-Type" content="text/html; charset=ut +f-8"&rab; &lab;title&rab;Perl Nights&lab;/title&rab; &lab;/head&rab; &lab;body&rab; ... ...


Comment on Re^5: Thanks to Ikegami, Chromatic & Corion
Download Code
Re^6: Thanks to Ikegami, Chromatic & Corion
by Logicus on Nov 02, 2011 at 02:33 UTC

    The escapes need to be the other way around!

    my %escapes = ( '&lab;' => '<', '&rab;' => '>', '&lcb;' => '(', '&rcb;' => ')', '&lsb;' => '[', '&rsb;' => ']' );

    I need a new escapes_re, because now it's simply destroying all the brackets!

      I need a new escapes_re, because now it's simply destroying all the brackets!

      Eeeep!

        Oh, hello __YOU__, how are you?

        Trolled anyone who cares lately?

      Got it!

      my %escapes = ( '&lab;' => '<', '&rab;' => '>', '&lcb;' => '(', '&rcb;' => ')', '&lsb;' => '[', '&rsb;' => ']' ); my $escapes_re = qr/&[lr][acs]b;/; $aXML =~ s/($escapes_re)/$escapes{$1}/g;

        That won't work. you need to handle those sequences, <special> and <post_include> at the same time, not before (which would break "&lab;special>lab&lab;/special>") or after (which would break "<special>lab</special>"). I've covered what would work elsewhere.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://935268]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (6)
As of 2015-07-04 18:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls