Make sweave process files with the correct encoding (#6625).

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
This commit is contained in:
Jean-Marc Lasgouttes 2010-10-22 07:51:39 +00:00
parent b072429261
commit 9ebd4405cf
4 changed files with 42 additions and 12 deletions

View 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 "%%" ""'''])
#

View 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

View 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)

View File

@ -12,10 +12,11 @@
#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())