« blib/lib/XML/Grammar/Screenplay/App/ToDocBook.pm
↑ Summary
blib/lib/XML/Grammar/FictionBase/XSLT/Converter.pm »
| 1 | package XML::Grammar::Screenplay::App::ToHTML; | ||
| 2 | $XML::Grammar::Screenplay::App::ToHTML::VERSION = '0.32.0'; | ||
| 3 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 2 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 2 | ▶ | use autodie; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 2 | ▶ | use parent 'Exporter'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | our @EXPORT = (qw(run)); | ||
| 10 | |||
| 11 | 2 | ▶ | use Getopt::Long qw/ GetOptions /; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | |||
| 13 | 0 | ▶ | use XML::Grammar::Screenplay::ToHTML (); |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 14 | |||
| 15 | |||
| 16 | sub run | ||
| 17 | { | ||
| 18 | my ( $self, $args ) = @_; | ||
| 19 | my $output_filename; | ||
| 20 | |||
| 21 | GetOptions( "output|o=s" => \$output_filename, ); | ||
| 22 | |||
| 23 | if ( !defined($output_filename) ) | ||
| 24 | { | ||
| 25 | die "Output filename not specified! Use the -o|--output flag!"; | ||
| 26 | } | ||
| 27 | |||
| 28 | my $converter = XML::Grammar::Screenplay::ToHTML->new(); | ||
| 29 | |||
| 30 | my $output_dom = $converter->translate_to_html( | ||
| 31 | { | ||
| 32 | source => { file => shift(@ARGV), }, | ||
| 33 | output => "dom", | ||
| 34 | } | ||
| 35 | ); | ||
| 36 | if ( defined($args) ) | ||
| 37 | { | ||
| 38 | $args->{dom_post_proc}->( | ||
| 39 | +{ | ||
| 40 | dom => ( \$output_dom ), | ||
| 41 | } | ||
| 42 | ); | ||
| 43 | } | ||
| 44 | my $chars = $converter->_to_html_stylesheet()->output_as_chars($output_dom); | ||
| 45 | |||
| 46 | $chars =~ s/[ \t]+$//gms; | ||
| 47 | |||
| 48 | open my $out, ">:encoding(UTF-8)", $output_filename; | ||
| 49 | print {$out} $chars; | ||
| 50 | close($out); | ||
| 51 | |||
| 52 | return; | ||
| 53 | } | ||
| 54 | |||
| 55 | 1; | ||
| 56 | |||
| 57 | __END__ | ||