]> git.lyx.org Git - lyx.git/commitdiff
Tentative fix for bug #7545. Please test.
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 15 Jun 2011 15:51:02 +0000 (15:51 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 15 Jun 2011 15:51:02 +0000 (15:51 +0000)
The problem is with sweave when the temp file path contains spaces. This patch adds some postprocessing that removes the reference to the temp dir.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39070 a592a061-630c-0410-9148-cb99ea01b6c8

lib/scripts/lyxsweave.R

index 15ec609cfbbc991c67a5d94d9b0c39c3818c8a47..09dad2d2739921b6806a93be4ecf34cb97ce068b 100644 (file)
@@ -37,3 +37,12 @@ ls.pr <- paste(dirname(ls.args[2]), tmpout, sep="/")
 
 # finally run sweave
 Sweave(file=ls.args[1], output=ls.args[2], syntax="SweaveSyntaxNoweb", stylepath=ls.sp, prefix.string=ls.pr)
+
+# remove absolute path from \includegraphics
+ls.doc = readLines(ls.args[2])
+ls.cmd = paste('\\includegraphics{', dirname(ls.args[2]), "/", sep = "")
+ls.idx = grep(ls.cmd, ls.doc, fixed = TRUE)
+if (length(ls.idx)) {
+   ls.doc[ls.idx] = sub(ls.cmd, "\\includegraphics{", ls.doc[ls.idx], fixed = TRUE)
+   writeLines(ls.doc, ls.args[2])
+}