App-Basis-ConvertText2
view release on metacpan or search on metacpan
$ ct2 --help
Syntax: ct2 [options] filename
About: Convert my modified markdown text files into other formats, by
default will create HTML in same directory as the input file, will only
process .md files.
If there is no output option used the output will be to file of same name
as the input filename but with an extension (if provided) from the
document, use format: keyword (pdf html doc).
[options]
-h, -?, --help Show help
-c, --clean Clean up the cache before use
-e, --embed Embed images into HTML, do not use this if
converting to doc/odt
-o, --output Filename to store the output as, extension will
control conversion
-p, --prince Convert to PDF using princexml, can handle
embedded images
-s, --template name of template to use
-v, --verbose verbose mode
-w, --wkhtmltopdf Convert to PDF using wkhtmltopdf, can handle
embedded images
=head1 AUTHOR
kevin mulholland, moodfarm@cpan.org
=cut
use v5.10;
use strict;
use warnings;
use Data::Printer;
use POSIX qw(strftime);
use Try::Tiny;
use Path::Tiny;
use App::Basis;
use App::Basis::Config;
use App::Basis::ConvertText2;
# -----------------------------------------------------------------------------
my $MARKUP_DIR = "$ENV{HOME}/." . get_program();
$MARKUP_DIR = $ENV{MARKUP_DIR} if ( $ENV{MARKUP_DIR} );
my $CACHE_DIR = "/tmp/" . getpwuid($>) . "/cache";
my $TEMPLATE = <<EOD;
<!DOCTYPE html>
<html>
<head>
<title>%TITLE%</title>
<meta name="Created" content="%DATE%" />
<meta name="Author" content="%AUTHOR%" />
<meta name="Copyright" content="%COPYRIGHT%" />
<meta name="summary" content="%SUMMARY%" />
<meta name="keywords" content="%KEYWORDS%" />
<meta name="revision" content="%REVISION%" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type='text/css'>
\@page {
size: %PAGE_SIZE% %ORIENTATION% ;
margin: 90pt 30pt 40pt 30pt ;
\@top {
margin: -10pt 0pt 0pt -90pt ;
}
\@bottom-right { content: counter(page) ;}
} }
body {font-style: sans-serif;}
/* toc */
#toc {
padding: 0.4em;
page-break-after: always;
}
#toc p {
font-weight: bold;
font-size: 32;
}
#toc h3 {
text-align: center
}
#toc ul {
columns: 1;
}
#toc ul, #toc li {
list-style: none;
margin: 0;
padding: 0;
padding-left: 10px ;
}
#toc a::after {
content: leader('.') target-counter(attr(href), page);
font-style: normal;
}
#toc a {
text-decoration: none ;
color: black;
}
/* tables*/
table { page-break-inside: avoid ;}
table.footer { font-size: 10px; width: 100%;}
table.footer td.commercial {
font-weight: bold;
font-size: 12px;
text-align: center;
}
/* nice markup for source code */
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode {
margin: 0; padding: 0; vertical-align: baseline; border: none;
}
table.sourceCode { width: 100%; line-height: 100%; }
td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; }
td.sourceCode { padding-left: 5px; }
code > span.kw { color: #007020; font-weight: bold; }
code > span.dt { color: #902000; }
code > span.dv { color: #40a070; }
code > span.bn { color: #40a070; }
( run in 2.758 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )