]> git.lyx.org Git - lyx.git/blob - lib/scripts/lyxsweave.R
9a8c6f3e6acc27dee3c019c0945d6462c982d6b8
[lyx.git] / lib / scripts / lyxsweave.R
1 # Wrapper around Sweave that sets up some things for LyX
2 # argument 1 is the absolute name of the input file
3 # argument 2 is the absolute name of the output file
4 # argument 3 is the iconv name for the encoding of the file
5 # argument 4 is the original document directory
6
7 ls.args <- commandArgs(trailingOnly=T)
8
9 # check whether Sweave.sty is seen by LaTeX
10 ls.sweavesty <- system("kpsewhich Sweave.sty", intern=T, ignore.stderr=T)
11 ls.sp <- (length(ls.sweavesty) == 0)
12
13 # set default encoding to the one of the file; it will be reset to previous
14 # default by the sweave module
15 ls.enc <- getOption("encoding")
16 options(encoding=ls.args[3])
17
18 # pass document dir to sweave module
19 ls.dir <- ls.args[4]
20
21 # this is used to tell where temporary files should go
22 ls.pr <- sub("\\.tex$", "", ls.args[2])
23
24
25 # finally run sweave
26 Sweave(file=ls.args[1], output=ls.args[2], syntax="SweaveSyntaxNoweb", stylepath=ls.sp, prefix.string=ls.pr)