NAME
PYX::SGML::Tags - Processing PYX data or file and write as SGML via
Tags.
SYNOPSIS
use PYX::SGML::Tags;
my $obj = PYX::SGML::Tags->new(%parameters);
$obj->parse($pyx, $out);
$obj->parse_file($input_file, $out);
$obj->parse_handle($input_file_handler, $out);
$obj->finalize;
METHODS
"new"
my $obj = PYX::SGML::Tags->new(%parameters);
Constructor.
Returns instance of class.
* "input_encoding"
Input encoding for parse_file() and parse_handler() usage.
Default value is 'utf-8'.
* "input_tags_item_callback"
Input 'Tags' item callback. This callback is for Tags::Output::*
constructor parameter 'input_tags_item_callback'.
Default value is undef.
* "output_encoding"
Output encoding.
Default value is 'utf-8'.
* "tags"
Tags object. Can be any of Tags::Output::* objects. Default
value is "Tags::Output::Raw-"new('output_handler' => \*STDOUT)>.
It's required.
"parse"
$obj->parse($pyx, $out);
Parse PYX text or array of PYX text. Output is serialization to SGML by
Tags::Output::* module. If $out not present, use 'output_handler'.
Returns undef.
"parse_file"
$obj->parse_file($input_file, $out);
Parse file with PYX data. $input_file file is decoded by
'input_encoding'. Output is serialization to SGML. If $out not present,
use 'output_handler'.
Returns undef.
"parse_handler"
$obj->parse_handle($input_file_handler, $out);
Parse PYX handler. $input_file_handler handler is decoded by
'input_encoding'. Output is serialization to SGML. If $out not present,
use 'output_handler'.
Returns undef.
"finalize"
$obj->finalize;
Finalize opened tags, if exists.
Returns undef.
ERRORS
new():
Bad 'Tags::Output::*' object.
From Class::Utils::set_params():
Unknown parameter '%s'.
parse():
From PYX::Parser::parse():
Bad PYX line '%s'.
From Tags::Output::Raw::flush():
Cannot write to output handler.
parse_file():
From PYX::Parser::parse_file():
Bad PYX line '%s'.
No input handler.
From Tags::Output::Raw::flush():
Cannot write to output handler.
parse_handler():
From PYX::Parser::parse_handler():
Bad PYX line '%s'.
No input handler.
From Tags::Output::Raw::flush():
Cannot write to output handler.
EXAMPLE1
use strict;
use warnings;
use PYX::SGML::Tags;
# Input.
my $pyx = <<'END';
(element
-data
)element
END
# Object.
my $obj = PYX::SGML::Tags->new;
# Process.
$obj->parse($pyx);
print "\n";
# Output:
# data
EXAMPLE2
use strict;
use warnings;
use PYX::SGML::Tags;
use Tags::Output::Indent;
# Input.
my $pyx = <<'END';
(element
-data
)element
END
# Object.
my $obj = PYX::SGML::Tags->new(
'tags' => Tags::Output::Indent->new(
'output_handler' => \*STDOUT,
),
);
# Process.
$obj->parse($pyx);
print "\n";
# Output:
# data
EXAMPLE3
use strict;
use warnings;
use PYX::SGML::Tags;
use Tags::Output::Indent;
# Input.
my $pyx = <<'END';
(element
-data
)element
END
# Object.
my $obj = PYX::SGML::Tags->new(
'input_tags_item_callback' => sub {
my $tags_ar = shift;
print '[ '.$tags_ar->[0].' ]'."\n";
return;
},
);
# Process.
$obj->parse($pyx);
print "\n";
# Output:
# [ b ]
# [ d ]
# [ e ]
# data
DEPENDENCIES
Class::Utils, Error::Pure, PYX::Parser, PYX::Utils, Tags::Output::Raw.
SEE ALSO
Task::PYX
Install the PYX modules.
REPOSITORY
AUTHOR
Michal Josef Špaček
LICENSE AND COPYRIGHT
© 2011-2022 Michal Josef Špaček
BSD 2-Clause License
VERSION
0.09