| Convert-Wiki documentation | Contained in the Convert-Wiki distribution. |
Convert::Wiki::Node::Head - Represents a headline node
use Convert::Wiki::Node::Head; my $head = Convert::Wiki::Node->new( txt => 'About Foo', type => 'head1' ); print $head->as_wiki();
A Convert::Wiki::Node::Head represents a headline node in a text.
None by default.
The base class Convert::Wiki::Node.
Tels http://bloodgate.com
Copyright (C) 2004 by Tels
This library is free software; you can redistribute it and/or modify it under the terms of the GPL. See the LICENSE file for more details.
| 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__