Lingua-EN-Alphabet-Shaw
view release on metacpan or search on metacpan
#!/usr/bin/perl
# Maintainer: You can auto-translate the examples in
# this file by setting PREPARE=1. Don't forget to
# hand-check them afterwards to make sure they are
# in fact correct!
use strict;
use warnings;
use utf8;
use Test::More;
use Lingua::EN::Alphabet::Shaw;
my $shavian = Lingua::EN::Alphabet::Shaw->new();
my @html;
my @names;
# Load the data
while (<DATA>) {
if (/^#\s*(.*)$/) {
push @names, $1;
push @html, '';
} else {
$html[-1] .= $_;
}
}
if (defined $ENV{'PREPARE'}) {
binmode STDOUT, ':utf8';
open SELF, "<$0";
while (<SELF>) {
print $_;
last if /^__DATA__/;
}
close SELF;
while (@html) {
my $name = shift @names;
my $html = shift @html;
print "# $name\n";
print $html;
# skip the transliterations
shift @names;
shift @html;
print "#\n";
print $shavian->transliterate_html($html);
}
} else {
plan tests => scalar(@html)/2;
while (@html) {
my $name = shift @names;
my $latn = shift @html;
my $shaw = shift @html;
shift @names;
is ($shavian->transliterate_html($latn), $shaw, $name);
}
}
__DATA__
# Basic test
<html><head><title>This is a test</title></head>
<body>
<h1>This is a test</h1>
<!-- This is a comment. -->
<p>This is a test. I took some china to
China. He <em>does</em> like does. I
<strong>live</strong> near a <strong>live</strong>
wire.</p>
<div><span title="What is this?">This is something
else.</span> This — contains an entity.
This is a picture. <img
src="http://example.com/demo.png"
alt="This should be translated."/> Here is
<a href="http://example.com">a link</a>. This is
all the text.</div></body></html>
#
<html><head><title>ðð¦ð ð¦ð ð© ðð§ðð</title><meta name="generator" content="Lingua::EN::Alphabet::Shaw" /></head>
<body>
<h1>ðð¦ð ð¦ð ð© ðð§ðð</h1>
<!-- This is a comment. -->
<p>ðð¦ð ð¦ð ð© ðð§ðð. ð² ðð«ð ðð³ð¥ ðð²ð¯ð© ð
·ðð²ð¯ð©. ð£ð° <em>ðð³ð</em> ð¤ð²ð ðð´ð. ð²
<strong>ð¤ð¦ð</strong> ð¯ð½ ð© <strong>ð¤ð²ð</strong>
ð¢ð²ð¼.</p>
<div><span title="ð¢ðªð ð¦ð ðð¦ð?">ðð¦ð ð¦ð ðð³ð¥ðð¦ð
ð§ð¤ð.</span> ðð¦ð — ðð©ð¯ðð±ð¯ð ð©ð¯ ð§ð¯ðð¦ðð¦.
ðð¦ð ð¦ð ð© ðð¦ððð¼. <img alt="ðð¦ð ðð«ð ðð° ðð®ð©ð¯ðð¤ð±ðð©ð." src="http://example.com/demo.png"/> ð£ð½ ð¦ð
<a href="http://example.com">ð© ð¤ð¦ðð</a>. ðð¦ð ð¦ð
ð·ð¤ ð ðð§ððð.</div></body></html>
( run in 1.645 second using v1.01-cache-2.11-cpan-71847e10f99 )