App-Pinpp
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/App/Pinpp.pm view on Meta::CPAN
package App::Pinpp;
use v5.010;
use strict;
use warnings;
use autodie;
use File::Spec;
use Getopt::Std;
use File::Temp qw(tempfile);
# ABSTRACT: pinpp - The Pinpoint Pre-processor
our $VERSION = '0.03'; # VERSION: Generated by DZP::OurPkg:Version
sub run {
my $class = shift;
# Load our arguments into ARGV, so we can use getopts.
local @ARGV = @_;
my %opts = (
o => '', # Output to PDF
I => 'topics' # Includes directory
);
getopts("o:i:",\%opts);
my ($file) = @ARGV;
$file or die "Usage: $0 file.pinpp";
# Okay code, you have just one job:
# @include <foo.pin> -> includes $INCLUDE_DIR/foo.pin
# NB: Everything after the @include on a line will be removed.
my $content = $class->_slurp($file);
# Remove // comments
$content =~ s{^//[^\n]*\n}{}gsm;
# Process includes
$content =~ s{^\@include\s+<([^>]+)>[^\n]*\n}{$class->include($opts{I},$1)}gmse;
# Remove blank slides
$content =~ s{^--\n--}{--}gsm;
# If a slide has no styling at all, and consists only of indented text,
# reformat it as code.
$content =~ s{
^--[ \t]*\n # Start of slide
(?:
[ \t]+[^\n]*\n # Lines starting with spaces/tabs
| # or...
\n # blank lines. They're cool, too.
)+ # And we can have a bunch of either.
(?=^--) # End of slide look-ahead.
}{_codeify(${^MATCH})}gsmxpe; # USE ALL THE FLAGS!
if (my $outputfile = $opts{o}) {
# Iff we're producing a PDF, then remove speaker comments
$content =~ s{^#[^\n]*\n}{}gsm;
my ($tmp_fh, $tmp_filename) = tempfile( DIR => '.' );
say {$tmp_fh} $content;
close($tmp_fh);
system("pinpoint", "--output=$opts{o}", $tmp_filename);
}
else {
# Otherwise just display our text
say $content;
}
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.751 second using v1.00-cache-2.02-grep-82fe00e-cpan-9e6bc14194b )