NAME

 Tags::Utils::Preserve - Class to check if content in element is preserved?

SYNOPSIS

 use Tags::Utils::Preserve;

 my $obj = Tags::Utils::Preserve->new(%params);
 my $preserved_flag = $obj->begin;
 my ($preserver_flag, $prev_preserved_flag) = $obj->begin;
 my $preserved_flag = $obj->end;
 my ($preserved_flag, $prev_preserved_flag) = $obj->end;
 $obj->get;
 $obj->reset;
 $obj->save_previous;

METHODS

new(%params)
 Constructor.
  • preserved

     Preserved tags.
begin()
 Process for begin of tag.
 Returns preserved flag in scalar context.
 Returns preserved flag and previous preserved flag in array context.
end()
 Process for end of tag.
 Returns preserved flag in scalar context.
 Returns preserved flag and previous preserved flag in array context.
get()
 Get preserved flag.
 Returns preserved flag in scalar context.
 Returns preserved flag and previous preserved flag in array context.
reset()
 Resets.
 Returns undef.
save_previous()
 Save previous stay.
 Returns undef.

ERRORS

 new():
         From Class::Utils::set_params():
                 Unknown parameter '%s'.

EXAMPLE

 use strict;
 use warnings;

 use Tags::Utils::Preserve;

 # Begin element helper.
 sub begin_helper {
         my ($pr, $tag) = @_;
         print "TAG: $tag ";
         my ($pre, $pre_pre) = $pr->begin($tag);
         print "PRESERVED: $pre PREVIOUS PRESERVED: $pre_pre\n";
 }
 
 # End element helper.
 sub end_helper {
         my ($pr, $tag) = @_;
         print "ENDTAG: $tag ";
         my ($pre, $pre_pre) = $pr->end($tag);
         print "PRESERVED: $pre PREVIOUS PRESERVED: $pre_pre\n";
 
 }
 
 # Object.
 my $pr = Tags::Utils::Preserve->new(
         'preserved' => ['tag']
 );
 
 # Process.
 begin_helper($pr, 'foo');
 begin_helper($pr, 'tag');
 begin_helper($pr, 'foo');
 end_helper($pr, 'foo');
 end_helper($pr, 'tag');
 end_helper($pr, 'foo');

 # Output:
 # TAG: foo PRESERVED: 0 PREVIOUS PRESERVED: 0
 # TAG: tag PRESERVED: 1 PREVIOUS PRESERVED: 0
 # TAG: foo PRESERVED: 1 PREVIOUS PRESERVED: 1
 # ENDTAG: foo PRESERVED: 1 PREVIOUS PRESERVED: 1
 # ENDTAG: tag PRESERVED: 0 PREVIOUS PRESERVED: 1
 # ENDTAG: foo PRESERVED: 0 PREVIOUS PRESERVED: 0

DEPENDENCIES

Class::Utils, List::MoreUtils, Readonly.

SEE ALSO

Task::Tags

Install the Tags modules.

REPOSITORY

https://github.com/michal-josef-spacek/Tags

AUTHOR

Michal Josef Špaček mailto:skim@cpan.org

http://skim.cz/

LICENSE AND COPYRIGHT

© 2005-2021 Michal Josef Špaček

BSD 2-Clause License

VERSION

0.11