Margin Notes using CSS/Perl

Hi Everyone,

I'm trying to convert a job from IF/XX to CSS/Perl and I'm having a little difficulty with the margin notes. Currently, I store paragraph numbers using <px;;0><pa> and output using the OPEN xymacro.  When I try to write (what I think is) an equivalent statement in XyPerl, I get a bunch for question marks displayed.  Has anyone else had this problem or am I just doing something wrong?

CSS:
para[para-number]:before{
content:
-xpp-perl(prelead, '0', '0')
-xpp-perl(xymacro, fg)
-xpp-perl(xymacro, px, '', '0')
attr(para-number)
-xpp-perl(xymacro, pa);
}

XyPerl:
sub seclist {

$X -> open_db('first', 'main', 'stream');
$X -> open_db('first', 'main', 'block');
while ($X -> get_var('!opened')) {
$X -> open_db('first', 'main', 'line');
while ($X -> get_var('!opened')) {
if ($X -> get_var('!flag')) {
if ($X -> get_var('!bwidth') > $X -> get_var('!bdepth')) {
$X -> vm($X -> get_var('!bx'));
} else {
$X -> vm($X -> get_var('!by') + $X -> get_var('!yfinal'));
}
my $paraNum = $X->get_text(0, 'd');
$X -> set_text($paraNum);
$X -> qa();
}
$X -> open_db('next', 'main', 'line');
}
$X -> open_db('next', 'main', 'block');
}
}

Thanks,
Kris

Parents
  • Kris,

    You were almost there...

    Just change:

    my $paraNum = $X->get_text(0, 'd');

    to:

    my $paraNum = $X->get_text(0, 'f');

    and things will work.

    Remark: it might be more efficient to replace the series of -xpp-perl statements by 1 xyperl routine that does everything in 1 go.

    Like the following:

    p[para-number]:before {

         content: -xpp-perl(paraNumber);

    }

    and in the xyperl file you add:

    sub paraNumber {
      my $X = XPPcompo->new(); 
      my $attr = $X->get_attr('@para-number');
      $X->fg();
      $X->px('', '0');
      $X->set_text($attr);
      $X->pa();
    }

    note that the @para-number syntax is only available in V9.2. For older release you might be forced to use the older (and dangerous) get|_attr('para-number') function

Reply
  • Kris,

    You were almost there...

    Just change:

    my $paraNum = $X->get_text(0, 'd');

    to:

    my $paraNum = $X->get_text(0, 'f');

    and things will work.

    Remark: it might be more efficient to replace the series of -xpp-perl statements by 1 xyperl routine that does everything in 1 go.

    Like the following:

    p[para-number]:before {

         content: -xpp-perl(paraNumber);

    }

    and in the xyperl file you add:

    sub paraNumber {
      my $X = XPPcompo->new(); 
      my $attr = $X->get_attr('@para-number');
      $X->fg();
      $X->px('', '0');
      $X->set_text($attr);
      $X->pa();
    }

    note that the @para-number syntax is only available in V9.2. For older release you might be forced to use the older (and dangerous) get|_attr('para-number') function

Children