Convert::Wiki::Node::Head - Represents a headline node


Convert-Wiki documentation Contained in the Convert-Wiki distribution.

Index


Code Index:

NAME

Top

Convert::Wiki::Node::Head - Represents a headline node

SYNOPSIS

Top

	use Convert::Wiki::Node::Head;

	my $head = Convert::Wiki::Node->new( txt => 'About Foo', type => 'head1' );

	print $head->as_wiki();

DESCRIPTION

Top

A Convert::Wiki::Node::Head represents a headline node in a text.

EXPORT

Top

None by default.

SEE ALSO

Top

The base class Convert::Wiki::Node.

AUTHOR

Top

Tels http://bloodgate.com

COPYRIGHT AND LICENSE

Top


Convert-Wiki documentation Contained in the Convert-Wiki distribution.

#############################################################################
# (c) by Tels 2004. Part of Convert::Wiki
#
# represents a headline node
#############################################################################

package Convert::Wiki::Node::Head;

use 5.006001;
use strict;
use warnings;

use Convert::Wiki::Node;

use vars qw/$VERSION @ISA/;

@ISA = qw/Convert::Wiki::Node/;
$VERSION = '0.04';

#############################################################################

sub _init
  {
  my ($self,$args) = @_;

  $self->{level} ||= 1; 

  $self->SUPER::_init($args);
  }

sub _as_wiki
  {
  my ($self,$txt) = @_;

  # if we are the first headline, we get level 1
  if (!defined $self->prev_by_type('head'))
    {
    $self->{level} = 1;
    }
  # if we follow right on another headline, take it's level plus 1
  my $prev = $self->prev();
  if (defined $prev && $prev->type() eq 'head')
    {
    $self->{level} = $prev->{level} + 1;
    }

  my $p = '=' x ($self->{level} + 1);		# level 1: ==

  # "== Foo ==\n\n"
  $p . ' ' . $txt . ' ' . $p . "\n\n";
  }

1;
__END__