| $htmlref | ";
print " [$htmlref] $implicithtml";
if ($placement eq "before") { print "(", $comment->text, ") "; }
# use the reference to retrieve the verse content
my $text = query_passage($esvref);
my $esv=XML::Twig->new(twig_handlers => { p => sub { $_->set_gi('span'); },
div => sub { $_->set_gi('span'); },
br => sub { $_->delete; }},
keep_encoding => 1);
$esv->parse($text);
$esv->flush; # flush the end of the document
if ($placement eq "after") { print " (", $comment->text, ")"; }
#print " |
\n";
print "\n";
}
$lastref = $fullref;
$twig->purge; # frees the memory
}
sub query_passage {
my ($passage) = @_;
# this is for testing only: you have to get your own key and put it here
my $key = "TEST";
my $options = "action=doPassageQuery&include-verse-numbers=false&include-passage-references=false&include-footnotes=false&include-headings=false&include-subheadings=false&include-short-copyright=false";
$queries++;
return get("http://www.gnpcb.org/esv/share/get/?key=$key&passage=$passage&$options");
}
sub process_options {
$opt_usage = 0;
$opt_debug = 0;
$opt_index = "";
# Parse the command line options
use Getopt::Long;
&GetOptions("usage|help|?", "index=s",
# unadvertised
"debug");
if ($opt_usage) {print usage(); exit 0;}
unless (-e $opt_index) {
die "Can't open $opt_index\n".usage();
}
}
sub usage {
return "usage: index2html.pl [-index file.xml]
Read an input file in 'index' format, connect to the ESV web
service to download the verse content for each item, merge in
additional index file content and write to stdout. ";
}