From 59cb54eb08f81549f890b232e8e0b57c04bd30ca Mon Sep 17 00:00:00 2001 From: Jeff LANCE Date: Mon, 4 Sep 2023 00:07:17 +0200 Subject: [PATCH] update --- conf/latexmkrc | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/conf/latexmkrc b/conf/latexmkrc index 94449c0..63b3c29 100644 --- a/conf/latexmkrc +++ b/conf/latexmkrc @@ -11,9 +11,9 @@ $out_dir = "build"; $emulate_aux = 1; # files to be deleted during a cleanup operation -$clean_ext = "nav pre snm synctex.gz bbl vrb"; +$clean_ext = "nav pre pythontex-files-%R/* pythontex-files-%R snm synctex.gz bbl vrb"; $clean_full_ext = "nav pre snm synctex.gz bbl vrb"; -push @generated_exts, "nav", "pre", "snm", "synctex.gz", "bbl", "vrb"; +push @generated_exts, "nav", "pre", "pytxcode", "snm", "synctex.gz", "bbl", "vrb"; # default excluded files when run without any arguments @default_excluded_files = ("partie*.tex"); @@ -32,12 +32,6 @@ $lualatex = "lualatex -shell-escape -synctex=1 -interaction=nonstopmode -halt-on # Asy compilation # -# old way to compile asy through latexmk -# sub asy {return system("asy '$_[0]'");} -# add_cus_dep("asy","eps",0,"asy"); -# add_cus_dep("asy","pdf",0,"asy"); -# add_cus_dep("asy","tex",0,"asy"); - add_cus_dep("asy","eps",0,"asy2eps"); add_cus_dep("asy","pdf",0,"asy2pdf"); add_cus_dep("asy","tex",0,"asy2tex"); @@ -74,6 +68,32 @@ my $ret = system("asy -vv -f '$_[1]' '$_[0]' >& '$_[0].log'"); return $ret; } +# PythonTeX +# +$pythontex = 'pythontex %O %S'; +$extra_rule_spec{'pythontex'} = [ 'internal', '', 'mypythontex', "%Y%R.pytxcode", "%Ypythontex-files-%R/%R.pytxmcr", "%R", 1 ]; + +sub mypythontex { + my $result_dir = $aux_dir1."pythontex-files-$$Pbase"; + my $ret = Run_subst( $pythontex, 2 ); + rdb_add_generated( glob "$result_dir/*" ); + open( my $fh, "<", $$Pdest ); + if ($fh) { + while (<$fh>) { + if ( /^%PythonTeX dependency:\s+'([^']+)';/ ) { + print "Found pythontex dependency '$1'\n"; + rdb_ensure_file( $rule, $aux_dir1.$1 ); + } + } + undef $fh; + } + else { + warn "mypythontex: I could not read '$$Pdest'\n", + " to check dependencies\n"; + } + return $ret; +} + # SageTeX # add_cus_dep( 'sage', 'sout', 0, 'makesout' );