Dear Monks (whether ye be Monker, Monked, or Monkee):

I'm sestting up TwigHandlers like this (partial code):

my $twig = new XML::Twig( TwigHandlers => { 'byline' => \&byline, 'body.head/hedline' => \&hedline, 'body.content/p' => \&process_p, 'body.content/hl2' => \&process_body_hl2, 'body.content/block/p' => \&process_p, 'body.content/block/hl2' => \&process_body_hl2, 'body.content/table' => \&process_table, etc. etc.
... and process_body_hl2 is pretty simple:
sub process_body_hl2 { my ($t, $hl2) = @_; my $para = crunch($hl2->text); $body .= "<p><b>$para</b></p>"; }
Input looks like this:
<body.content> <hl2 style="section_head">SECTION HEAD</hl2> <hl2 style="subhead">subhead</hl2> <p/>
The output for that part comes out like this (this is a different format of xml from the input):
<body.content> <p>SECTION HEAD</p><p>subhead</p>
Where are the <b> tags? Later, the next hl2 in the body looks like this:
<p/> <hl2 style="subhead">2nd subhead</hl2>
And this one comes out the way it should:
<p><b>2nd subhead</b></p><p>
Now, how come the first two did not work, but the subsequent one did?

In reply to TwigHandlers not always called? by BenHopkins

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.