App-Basis-ConvertText2

 view release on metacpan or  search on metacpan

lib/App/Basis/ConvertText2.pm  view on Meta::CPAN


=head1 SYNOPSIS

TO be used in conjuction with the supplied ct2 script, which is part of this distribution.
Not really to be used on its own.

=head1 DESCRIPTION

This is a perl module and a script that makes use of %TITLE%

This is a wrapper for [pandoc] implementing extra fenced code-blocks to allow the
creation of charts and graphs etc.
Documents may be created a variety of formats. If you want to create nice PDFs
then it can use [PrinceXML] to generate great looking PDFs or you can use [wkhtmltopdf] to create PDFs that are almost as good, the default is to use pandoc which, for me, does not work as well.

HTML templates can also be used to control the layout of your documents.

The fenced code block handlers are implemented as plugins and it is a simple process to add new ones.

There are plugins to handle

    * ditaa
    * mscgen
    * graphviz
    * uml
    * gnuplot
    * gle
    * sparklines
    * charts
    * barcodes and qrcodes
    * and many others

See 
https://github.com/27escape/App-Basis-ConvertText2/blob/master/README.md
for more information.

=head1 Todo

Consider adding plugins for 

    * http://blockdiag.com/en/index.html, 
    * https://metacpan.org/pod/Chart::Strip
    * https://metacpan.org/pod/Chart::Clicker

=head1 Public methods

=over 4

=cut

# ----------------------------------------------------------------------------

package App::Basis::ConvertText2;
$App::Basis::ConvertText2::VERSION = '0.4';
use 5.10.0;
use strict;
use warnings;
use feature 'state';
use Moo;
use Data::Printer;
use Try::Tiny;
use Path::Tiny;
use Digest::MD5 qw(md5_hex);
use Encode qw(encode_utf8);
use Text::Markdown qw(markdown);
use GD;
use MIME::Base64;
use Furl;
use Module::Pluggable
    require          => 1,
    on_require_error => sub {
    my ( $plugin, $err ) = @_;
    warn "$plugin, $err";
    };
use App::Basis;
use App::Basis::ConvertText2::Support;

# ----------------------------------------------------------------------------
# this contents string is to be replaced with the body of the markdown file
# when it has been converted
use constant CONTENTS => '_CONTENTS_';
use constant PANDOC   => 'pandoc';
use constant PRINCE   => 'prince';
use constant WKHTML   => 'wkhtmltopdf';

my %valid_tags;

# ----------------------------------------------------------------------------
my $TITLE = "%TITLE%";

# ----------------------------------------------------------------------------

has 'name'    => ( is => 'ro', );
has 'basedir' => ( is => 'ro', );

has 'use_cache' => ( is => 'rw', default => sub { 0; } );

has 'cache_dir' => (
    is      => 'ro',
    default => sub {
        my $self = shift;
        return "/tmp/" . get_program() . "/cache/";
    },
    writer => "_set_cache_dir"
);

has 'template' => (
    is      => 'rw',
    default => sub {
        "<!DOCTYPE html'>
<html>
    <head>
        <title>$TITLE</title>
        <style type='text/css'>
            \@page { size: A4 }
        </style>
    </head>
    <body>
        <h1>%TITLE%</h1>

        %_CONTENTS_%



( run in 1.057 second using v1.01-cache-2.11-cpan-39bf76dae61 )