develooper Front page | perl.libwww | Postings from January 2002

Re: Fixing opening/closing tags.

Thread Previous | Thread Next
From:
Bill Moseley
Date:
January 8, 2002 19:13
Subject:
Re: Fixing opening/closing tags.
Message ID:
3.0.3.32.20020108191306.022b6f4c@pop3.hank.org
At 04:10 PM 01/06/02 -0700, Sean M. Burke wrote:
>>   <b>This <em>is something -- really</em> -- awkward</b> without doubt
>>
>>Ends up:
>>
>>   <b>This <em>is something</em></b>
>>   <b><em>really</em></b>
>>   <b>awkward</b> without doubt

>But here's a hint: Since you're operating on text nodes, and asking things
>about them like their parentage, consider the $h->objectify_text() method

Ok, after a few hours looking at it, I'm humbled.  I'm rather sure I'm
missing what you are suggesting.

I call objectify_text() and then I can easily run through the ~text
segments.  

My thought was to make passes through the ~text, removing text as needed
(any text from [1st, 2nd, etc.] " --" onwards), remove nodes with a single,
empty/undefined text segment, and then use as_HTML.

But that seems way too awkward.

Can you get me on track?

Thanks!,


BTW -- I was curious about this:

$tree->parse(''); 
<html> @0 (IMPLICIT)
  <head> @0.0 (IMPLICIT)
  <body> @0.1 (IMPLICIT)

$tree->parse('<body>foo</body>');
<html> @0 (IMPLICIT)
  <head> @0.0 (IMPLICIT)
  <body> @0.1
    "foo"

$tree->parse('<b>foo</b>');
<html> @0 (IMPLICIT)
  <head> @0.0 (IMPLICIT)
  <body> @0.1 (IMPLICIT)
    <b> @0.1.0
      "foo"

Yet, this one drops the text segment.

$tree->parse('foo');
<html> @0 (IMPLICIT)
  <head> @0.0 (IMPLICIT)
  <body> @0.1 (IMPLICIT)



-- 
Bill Moseley
mailto:moseley@hank.org

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About