The branch, 2.0.x, has been updated.

- Log -----------------------------------------------------------------

commit ff9d937253283e891e5776c9ff2a5e949f976a7a
Author: Jean-Marc Lasgouttes <[email protected]>
Date:   Mon Jan 21 09:48:28 2013 +0100

    Handle encoding correctly with knitr>=1.0 (#8504)
    
    Knitr now has a parameter to indicate the encoding of the file. With this 
patch,it is used when possible (from Yihui Xie).

diff --git a/lib/scripts/lyxknitr.R b/lib/scripts/lyxknitr.R
index 7c029ea..438b40a 100644
--- a/lib/scripts/lyxknitr.R
+++ b/lib/scripts/lyxknitr.R
@@ -21,12 +21,8 @@
 ## $$e encoding (e.g. 'UTF-8')
 
 library(knitr)
-
 .cmdargs = commandArgs(TRUE)
 
-.orig.enc = getOption("encoding")
-options(encoding = .cmdargs[3])
-
 ## the working directory is the same with the original .lyx file; you
 ## can put your data files there and functions like read.table() can
 ## work correctly without specifying the full path
@@ -34,4 +30,11 @@ setwd(.cmdargs[4])
 opts_knit$set(root.dir = getwd())
 
 ## run knit() to get .tex or .R
-knit(.cmdargs[1], output = .cmdargs[2], tangle = 'tangle' %in% .cmdargs)
+if (is.null(formals(knit)$encoding)) {
+  .orig.enc = getOption("encoding")
+  options(encoding = .cmdargs[3])
+  knit(.cmdargs[1], output = .cmdargs[2], tangle = 'tangle' %in% .cmdargs)
+} else {
+  knit(.cmdargs[1], output = .cmdargs[2], encoding = .cmdargs[3],
+       tangle = 'tangle' %in% .cmdargs)
+}
diff --git a/status.20x b/status.20x
index 6ad00b8..5455051 100644
--- a/status.20x
+++ b/status.20x
@@ -82,6 +82,9 @@ What's new
 - Fix problem using lyxpak.py when outside the LyX tree: Variable was
   undefined.
 
+- When using the knitr module, use new "encoding" parameter of knitr if 
+  available (bug 8504).
+
 - Respect InsetLayout's PassThru setting for XHTML export.
 
 - Fix layout conversion bug involving quoted Flex inset names that do not

-----------------------------------------------------------------------

Summary of changes:
 lib/scripts/lyxknitr.R |   13 ++++++++-----
 status.20x             |    3 +++
 2 files changed, 11 insertions(+), 5 deletions(-)


hooks/post-receive
-- 
The LyX Source Repository

Reply via email to