diff --git a/README.md b/README.md index 80acb12..d66e99e 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Features * With pTeX-like engines, automatically run dvipdfmx to produce PDF file. * Automatically re-run (La)TeX to resolve cross-references and other things. * Watch input files for change (requires an external program). \[`--watch` option\] -* Support for MakeIndex, BibTeX, Biber, makeglossaries commands. \[`--makeindex`, `--bibtex`, `--biber`, `--makeglossaries` options\] +* Support for MakeIndex, BibTeX, Biber, makeglossaries, sagetex commands. \[`--makeindex`, `--bibtex`, `--biber`, `--makeglossaries`, `--sagetex` options\] Usage ----- @@ -107,6 +107,8 @@ Options to run auxiliary programs: Use Biber program to produce `.bbl` file from `.bcf` file. * `--makeglossaries[=COMMAND]` Use makeglossaries program to produce `.gls` file from `.glo` file. +* `--sagetex[=COMMAND]` + Use sagetex program to produce `.sout` and `.scmd` file from `.sage` file. TeX-compatible options: diff --git a/doc/cluttex.pdf b/doc/cluttex.pdf index 2d49565..e71f28b 100644 Binary files a/doc/cluttex.pdf and b/doc/cluttex.pdf differ diff --git a/doc/cluttex.tex b/doc/cluttex.tex index ae3bc01..c39b5f5 100644 --- a/doc/cluttex.tex +++ b/doc/cluttex.tex @@ -112,6 +112,8 @@ \section{Command-line usage} Run Biber. Default value for \metavar{COMMAND}: \texttt{biber} \item[\texttt{--makeglossaries[=\metavar{COMMAND}]}] Run makeglossaries. Experimental. +\item[\texttt{--sagetex[=\metavar{COMMAND}]}] + Run sagetex. Experimental. \end{description} \TeX-compatible options: diff --git a/src/cluttex.lua b/src/cluttex.lua index 309eb1c..2d02fa0 100644 --- a/src/cluttex.lua +++ b/src/cluttex.lua @@ -427,6 +427,27 @@ local function single_run(auxstatus, iteration) end end + if options.sagetex then + for _,file in ipairs(filelist) do + if pathutil.ext(file.path) == "sage" then + local sagefileinfo = {path = file.path, abspath = file.abspath, kind = "auxiliary"} + if reruncheck.comparefileinfo({sagefileinfo}, auxstatus) then + local sage_command = { + options.sagetex, -- Do not escape options.sagetex to allow additional options + -- TODO handle output directory? + pathutil.basename(file.abspath) + } + coroutine.yield(table.concat(sage_command, " ")) + end + end + end + else + -- Check log file + if string.find(execlog, "Run Sage on") then + message.diag("You may want to use --sagetex option.") + end + end + if string.find(execlog, "No pages of output.") then return "No pages of output." end diff --git a/src/texrunner/handleoption.lua b/src/texrunner/handleoption.lua index 290f27f..b390a26 100644 --- a/src/texrunner/handleoption.lua +++ b/src/texrunner/handleoption.lua @@ -58,6 +58,7 @@ Options: --bibtex=COMMAND+OPTIONs Command for BibTeX, such as `bibtex' or `pbibtex'. --biber[=COMMAND+OPTIONs] Command for Biber. + --sagetex[=COMMAND+OPTIONS] Command for sagetex --makeglossaries[=COMMAND+OPTIONs] Command for makeglossaries. -h, --help Print this message and exit. -v, --version Print version information and exit. @@ -242,6 +243,11 @@ local option_spec = { param = true, default = "biber", }, + { + long = "sagetex", + param = true, + default = "sage", + }, { long = "makeglossaries", param = true, @@ -434,6 +440,10 @@ local function handle_cluttex_options(arg) assert(options.makeglossaries == nil, "multiple --makeglossaries options") options.makeglossaries = param + elseif name == "sagetex" then + assert(options.sagetex == nil, "multiple --sagetex options") + options.sagetex = param + end end diff --git a/src/texrunner/reruncheck.lua b/src/texrunner/reruncheck.lua index d1602bc..658803f 100644 --- a/src/texrunner/reruncheck.lua +++ b/src/texrunner/reruncheck.lua @@ -85,6 +85,8 @@ local function parse_recorder_file(file, options, filelist, filemap) kind = "auxiliary" elseif ext == "glo" then -- makeglossaries kind = "auxiliary" + elseif ext == "sage" then -- sagetex + kind = "auxiliary" end fileinfo = {path = path, abspath = abspath, kind = kind} table.insert(filelist, fileinfo)