]> git.lyx.org Git - lyx.git/commitdiff
Make sweave process files with the correct encoding (#6625).
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 22 Oct 2010 07:51:39 +0000 (07:51 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 22 Oct 2010 07:51:39 +0000 (07:51 +0000)
The required the introduction of the new converter token $$e, that holds
the iconv name of the latex file encoding.

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

lib/configure.py
lib/doc/Customization.lyx
lib/scripts/lyxsweave.R
src/Converter.cpp

index 1ea4c680f4d300f4703cf00f87b0ce0c180f0e37..48cdb7de7ee3e90f5ae7723f1026f9ea8494e8cf 100644 (file)
@@ -612,7 +612,7 @@ def checkConverterEntries():
         rc_entry = [r'''\converter literate   latex      "%%"  ""
 \converter literate   pdflatex      "%%"       ""'''])
     #
-    checkProg('a Sweave -> LaTeX converter', ['Rscript --vanilla $$s/scripts/lyxsweave.R $$i'],
+    checkProg('a Sweave -> LaTeX converter', ['Rscript --vanilla $$s/scripts/lyxsweave.R $$i $$e'],
         rc_entry = [r'''\converter sweave   latex      "%%"    ""
 \converter sweave   pdflatex      "%%" ""'''])
     #
index 30426b4fdb11f20c0fd0b6808b955ea2082e63a0..2f76dadb26242a7c1f275d878181476efd3413c8 100644 (file)
@@ -133,10 +133,11 @@ End
 \papercolumns 1
 \papersides 2
 \paperpagestyle headings
-\tracking_changes false
+\tracking_changes true
 \output_changes false
 \html_math_output 0
 \html_be_strict true
+\author 1 "Jean-Marc Lasgouttes" 
 \end_header
 
 \begin_body
@@ -2140,7 +2141,29 @@ $$r
 \end_inset
 
  The path to the original input file (this is different from $$p when a
- chain of converters is called).
+ chain of converters is called)
+\change_deleted 1 1287732759
+.
+\change_inserted 1 1287732721
+
+\end_layout
+
+\begin_layout Labeling
+\labelwidthstring 00.00.0000
+
+\change_inserted 1 1287732753
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 1 1287732729
+$$e
+\end_layout
+
+\end_inset
+
+ The iconv name for the encoding of the document.
 \end_layout
 
 \begin_layout Standard
index 8ab0ea99510d3df33f39b0fe2a02257f0a030e6f..a8ab1849842204492793b5c16a79478aa3f6ac56 100644 (file)
@@ -1,10 +1,15 @@
 # Wrapper around Sweave that sets up some things for LyX
 # argument 1 is the file name
+# argument 2 is the iconv name for the encoding of the file
 
-args <- commandArgs(trailingOnly=T)
+ls.args <- commandArgs(trailingOnly=T)
 
 # check whether Sweave.sty is seen by LaTeX
-sweavesty <- system("kpsewhich Sweave.sty", intern=T, ignore.stderr=T)
-sp <- (length(sweavesty) == 0)
+ls.sweavesty <- system("kpsewhich Sweave.sty", intern=T, ignore.stderr=T)
+ls.sp <- (length(ls.sweavesty) == 0)
 
-Sweave(args[1], stylepath=sp)
+# set default encoding to the one of the file
+options(encoding=ls.args[2])
+
+#run sweave
+Sweave(ls.args[1], stylepath=ls.sp)
index 14f4522968138dc78558fe97057e4061b435f400..4128129fc76bcab9f7008bd0487dd4a6bb040887 100644 (file)
 
 #include "Converter.h"
 
-#include "ConverterCache.h"
 #include "Buffer.h"
 #include "buffer_funcs.h"
 #include "BufferParams.h"
+#include "ConverterCache.h"
+#include "Encoding.h"
 #include "ErrorList.h"
 #include "Format.h"
 #include "Language.h"
@@ -49,7 +50,7 @@ string const token_base("$$b");
 string const token_to("$$o");
 string const token_path("$$p");
 string const token_orig_path("$$r");
-
+string const token_encoding("$$e");
 
 
 string const add_options(string const & command, string const & options)
@@ -325,7 +326,7 @@ bool Converters::convert(Buffer const * buffer,
        // used anyway.
        OutputParams runparams(buffer ? &buffer->params().encoding() : 0);
        runparams.flavor = getFlavor(edgepath);
-       
+
        if (buffer) {
                runparams.use_japanese = buffer->bufferFormat() == "platex";
                runparams.use_indices = buffer->params().use_indices;
@@ -397,9 +398,9 @@ bool Converters::convert(Buffer const * buffer,
                        }
 
                        // FIXME UNICODE
-                       string const infile2 = 
+                       string const infile2 =
                                to_utf8(makeRelPath(from_utf8(infile.absFileName()), from_utf8(path)));
-                       string const outfile2 = 
+                       string const outfile2 =
                                to_utf8(makeRelPath(from_utf8(outfile.absFileName()), from_utf8(path)));
 
                        string command = conv.command;
@@ -408,6 +409,7 @@ bool Converters::convert(Buffer const * buffer,
                        command = subst(command, token_to, quoteName(outfile2));
                        command = subst(command, token_path, quoteName(infile.onlyPath().absFileName()));
                        command = subst(command, token_orig_path, quoteName(orig_from.onlyPath().absFileName()));
+                       command = subst(command, token_encoding, buffer ? buffer->params().encoding().iconvName() : string());
                        command = libScriptSearch(command);
 
                        if (!conv.parselog.empty())