sharelatex-image/LatexMk

21 lines
432 B
Plaintext

my $root_file = $ARGV[-1];
add_cus_dep( 'Rtex', 'tex', 0, 'rtex_to_tex');
sub rtex_to_tex {
do_knitr("$_[0].Rtex");
}
sub do_knitr {
my $dirname = dirname $_[0];
my $basename = basename $_[0];
system("Rscript -e \"library('knitr'); setwd('$dirname'); knit('$basename')\"");
}
my $rtex_file = $root_file =~ s/\.tex$/.Rtex/r;
unless (-e $root_file) {
if (-e $rtex_file) {
do_knitr($rtex_file);
}
}