view release on metacpan or search on metacpan
lib/App/Basis/ConvertText2.pm view on Meta::CPAN
my $input = shift;
my $resp = execute_cmd(
command => PANDOC . " --email-obfuscation=none -S -R --normalize -t html5 --highlight-style='kate'",
timeout => 30,
child_stdin => $input
);
my $html;
debug( "Pandoc: " . $resp->{stderr} ) if ( $resp->{stderr} );
if ( !$resp->{exit_code} ) {
$html = $resp->{stdout};
}
else {
debug( "ERROR", "Could not parse with pandoc, using markdown" );
warn "Could not parse with pandoc, using markdown";
$html = markdown($input);
}
return $html;
lib/App/Basis/ConvertText2.pm view on Meta::CPAN
sub _pandoc_format {
my ( $input, $output ) = @_;
my $status = 1;
my $resp = execute_cmd(
command => PANDOC . " $input -o $output",
timeout => 30,
);
debug( "Pandoc: " . $resp->{stderr} ) if ( $resp->{stderr} );
if ( !$resp->{exit_code} ) {
$status = 0;
}
else {
debug( "ERROR", "Could not parse with pandoc" );
$status = 1;
}
return $status;
}
lib/App/Basis/ConvertText2/Plugin/Barcode.pm view on Meta::CPAN
# let the caller put the block back together
return undef;
}
# we can use the cache or process everything ourselves
my $sig = create_sig( $content, $params );
my $filename = cachefile( $cachedir, "$sig.png" );
if ( !-f $filename ) {
my $gdb ;
# sometimes it throws out some warnings, lets hide them
my ($stdout, $stderr, @result) = capture {
$gdb = GD::Barcode->new( $type, $content, $qrcode );
} ;
if ( !$gdb ) {
warn "warning $tag $params->{type}: " . $GD::Barcode::errStr;
return undef;
}
my $gd = $gdb->plot( NoText => $params->{notext}, Height => $params->{height} );
path($filename)->spew_raw( $gd->png );
# my $cmd = QRCODE . " -o$filename '$content'";
# my ( $exit, $stdout, $stderr ) = run_cmd($cmd);
# for some reason qrcodes may need scaling
if ( -f $filename && $type eq 'QRcode' && $params->{height}) {
my $image = Image::Resize->new($filename);
my $gd = $image->resize( $params->{height}, $params->{height} );
# overwrite original file with resized version
if ($gd) {
path($filename)->spew_raw( $gd->png );
}
lib/App/Basis/ConvertText2/Plugin/Chart.pm view on Meta::CPAN
# legends comma seperated to allow spaces in descriptions
$chart->set_legend( split( /,/, $params->{legends} || "" ) );
$chart->set_legend_font(gdMediumBoldFont);
$chart->set_x_label_font(gdMediumBoldFont);
$chart->set_y_label_font(gdMediumBoldFont);
$chart->set_x_axis_font(gdMediumBoldFont);
$chart->set_y_axis_font(gdMediumBoldFont);
$chart->set_values_font(gdMediumBoldFont);
}
my ( $stdout, $stderr, $exit ) = capture {
my $gd = $chart->plot( \@data );
path($filename)->spew_raw( $gd->png ) if ($$gd);
};
}
my $out;
if ( -f $filename ) {
# create something suitable for the HTML
$out = create_img_src( $filename, $params->{title} );
lib/App/Basis/ConvertText2/Plugin/Ditaa.pm view on Meta::CPAN
# we can use the cache or process everything ourselves
my $sig = create_sig( $content, $params );
my $filename = cachefile( $cachedir, "$sig.png" );
if ( !-f $filename ) {
my $ditaafile = Path::Tiny->tempfile("ditaa.XXXX");
path($ditaafile)->spew_utf8($content);
my $cmd = DITAA . " -o $ditaafile $filename";
my ( $exit, $stdout, $stderr ) = run_cmd($cmd);
if ($exit) {
warn "Could not run script " . DITAA . " get it from http://ditaa.sourceforge.net/";
}
# if we want to force the size of the graph
if ( -f $filename && $x && $y ) {
my $image = Image::Resize->new($filename);
my $gd = $image->resize( $x, $y );
# overwrite original file with resized version
lib/App/Basis/ConvertText2/Plugin/Gle.pm view on Meta::CPAN
if ( !-f $filename ) {
my $glefile = Path::Tiny->tempfile("gleXXXXXXXX");
my $res = sprintf( "size %.4f %.4f", $x / RES, $y / RES) ;
$content =~ s/size\s+(.*?)\s+(.*?)$//gsm ;
$content = "$res\n$content" ;
path($glefile)->spew_utf8($content);
my $cmd = GLE . ( $params->{transparent} ? " -transparent" : "" ) . " -output $filename $glefile";
my ( $exit, $stdout, $stderr ) = run_cmd($cmd);
if ($exit) {
warn "Could not run script " . GLE . " get it from http://glx.sourceforge.net/";
}
}
my $out;
if ( -f $filename ) {
# create something suitable for the HTML
$out = create_img_src( $filename, $params->{title} );
}
lib/App/Basis/ConvertText2/Plugin/Gnuplot.pm view on Meta::CPAN
# set out filename
$content = "set output '$filename'\n$content" ;
# we want to set the size
# strip any size in the data
$content =~ s/set term png size.*$//gsmi ;
$content = "set term png size $x, $y\n$content" ;
path($gnuplotfile)->spew_utf8($content);
my $cmd = GNUPLOT . " $gnuplotfile";
my ( $exit, $stdout, $stderr ) = run_cmd($cmd);
if( $exit) {
warn "Could not run script " . GNUPLOT . " get it from http://gnuplot.sourceforge.net/" ;
}
# if we want to force the size of the graph
# if ( -f $filename && $x && $y ) {
# my $image = Image::Resize->new($filename);
# my $gd = $image->resize( $x, $y );
# # overwrite original file with resized version
# if ($gd) {
lib/App/Basis/ConvertText2/Plugin/Graphviz.pm view on Meta::CPAN
if ( $x && $y ) {
$size = sprintf( " size=\"%.5f,%.5f\";", $x / DPI, $y / DPI );
# add calculated image size to the graph
$content =~ s/(digraph.*?)$/$1\n$size\n/sm;
}
path($dotfile)->spew_utf8($content);
my $cmd = GRAPHVIZ . " -Tpng -o$filename $dotfile";
my ( $exit, $stdout, $stderr ) = run_cmd($cmd);
if ($exit) {
warn "Could not run script " . GRAPHVIZ . " get it from http://graphviz.org";
}
# if we want to force the size of the graph
if ( -f $filename && $x && $y ) {
my $image = Image::Resize->new($filename);
my $gd = $image->resize( $x, $y );
# overwrite original file with resized version
lib/App/Basis/ConvertText2/Plugin/Mscgen.pm view on Meta::CPAN
chomp $content;
return "" if ( !$content );
# we can use the cache or process everything ourselves
my $sig = create_sig( $content, $params );
my $filename = cachefile( $cachedir, "$sig.png" );
if ( !-f $filename ) {
my $mscfile = Path::Tiny->tempfile("mscgen.XXXX");
path($mscfile)->spew_utf8($content);
my $cmd = MSCGEN . " -Tpng -o$filename $mscfile";
my ( $exit, $stdout, $stderr ) = run_cmd($cmd);
if ($exit) {
warn "Could not run script " . MSCGEN . " get it from http://www.mcternan.me.uk/mscgen/";
}
# if we want to force the size of the graph
if ( -f $filename && $x && $y ) {
my $image = Image::Resize->new($filename);
my $gd = $image->resize( $x, $y );
# overwrite original file with resized version
lib/App/Basis/ConvertText2/Plugin/Uml.pm view on Meta::CPAN
# we are lucky that plantuml can have image sizes
if ( $x && $y ) {
$content =~ s/\@startuml/\@startuml\nscale $x*$y\n/;
}
my $umlfile = Path::Tiny->tempfile("umlXXXXXXXX");
path($umlfile)->spew_utf8($content);
my $cmd = UML . " $umlfile $filename";
my ( $exit, $stdout, $stderr ) = run_cmd($cmd);
if( $exit) {
warn "Could not run script " . UML . " get it from https://github.com/27escape/bin/blob/master/uml" ;
}
}
my $out;
if ( -f $filename ) {
# create something suitable for the HTML
$out = create_img_src( $filename, $params->{title} );
}