#!/usr/bin/perl use lib qw (../lib lib); use Test::More 'no_plan'; use strict; use warnings; use MKDoc::XML::Tagger; use MKDoc::XML::Tokenizer; # _tag_close and _tag_open functions { my $tag = MKDoc::XML::Tagger::_tag_close ('strong'); is ($tag, ''); $tag = MKDoc::XML::Tagger::_tag_open ('strong'); is ($tag, ''); $tag = MKDoc::XML::Tagger::_tag_open ('strong', { class => 'superFort' }); is ($tag, ''); } # this regex should match any amount of consecutive whitespace, # or \&(214) like tags, or carriage returns { my $sample_text = <SGML that is completely described in this document. EOF my $tokens = MKDoc::XML::Tokenizer->process_data ($example); my ($text, $tags) = MKDoc::XML::Tagger::_segregate_markup_from_text ($tokens); like ($text, qr/\&\(1\)SGML\&\(2\)/); like ($text, qr/\&\(3\)completely described\&\(4\)/); } # more nasty test { my $r = MKDoc::XML::Tagger->process_data ( 'Hello Cool World!', { _expr => 'Cool World', _tag => 'a', href => 'cw', alt => 'foo' }, { _expr => 'Hello Cool World', _tag => 'a', href => 'hcw' } ); is ($r, 'Hello Cool World!'); $r = MKDoc::XML::Tagger->process_data ( '<hello>', { _expr => 'hello', _tag => 'a', href => 'http://www.hello.com/' }, ); like ($r, qr/process_data ( '

News foo barStatements, declarations

', { '_expr' => 'news', 'href' => 'http://news.com/', '_tag' => 'a', }, { '_expr' => 'News', 'lang' => 'en', 'href' => 'http://users.groucho/news/', '_tag' => 'a', } ); } { my $data = qq |

<p>this is a test, hello world, this is a test</p>

|; my $r = MKDoc::XML::Tagger->process_data ( $data, { _expr => 'Hello World', _tag => 'a', href => 'cw', alt => 'foo' } ); } { my $r = MKDoc::XML::Tagger->process_data ( 'q & a', { '_expr' => 'Q & A', 'href' => 'http://news.com/', '_tag' => 'a', } ); is ($r, '
q & a'); } 1; __END__