latex-preambles/example/latexmkrc

47 lines
1.1 KiB
Perl

# -----------------------------------------
# This perl script configures latexmkrc
# -----------------------------------------
# Copyright (C) 2020 by Nils Freydank,
# <nils.freydank@posteo.de>
# License: GPL-2
# see COPYING-GPL-2 for more details
# -----------------------------------------
# Be verbose
$silent = 0;
# Define the document's title.
$document_title = "document";
# Use LuaLaTeX and write all output into "cachedir/"
$pdf_mode = 4;
# --shell-escape is necessary for minted and a security issue!
$lualatex = 'lualatex --shell-escape %O %S';
$out_dir = "cachedir";
# Generate a version file containing the current
# git commit ID as long as we have no tag inside.
sub gen_version_file {
local $\ = "";
my $version_file = "cachedir/version.tex";
my $git_tag = `git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null`;
chomp(my $git_version = `git rev-parse --short HEAD`);
# if git_tag is non-emtpy, generate the file
if ($git_tag)
{
unlink $version_file if -e $version_file;
}
else {
open(my $fh, '>', $version_file);
if (defined $fh) {
print $fh $git_version;
}
close $fh;
}
}
gen_version_file;