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 "%%" "" rc_entry = [r'''\converter literate latex "%%" ""
\converter literate pdflatex "%%" ""''']) \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 "%%" "" rc_entry = [r'''\converter sweave latex "%%" ""
\converter sweave pdflatex "%%" ""''']) \converter sweave pdflatex "%%" ""'''])
# #

View File

@ -133,10 +133,11 @@ End
\papercolumns 1 \papercolumns 1
\papersides 2 \papersides 2
\paperpagestyle headings \paperpagestyle headings
\tracking_changes false \tracking_changes true
\output_changes false \output_changes false
\html_math_output 0 \html_math_output 0
\html_be_strict true \html_be_strict true
\author 1 "Jean-Marc Lasgouttes"
\end_header \end_header
\begin_body \begin_body
@ -2140,7 +2141,29 @@ $$r
\end_inset \end_inset
The path to the original input file (this is different from $$p when a 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 \end_layout
\begin_layout Standard \begin_layout Standard

View File

@ -1,10 +1,15 @@
# Wrapper around Sweave that sets up some things for LyX # Wrapper around Sweave that sets up some things for LyX
# argument 1 is the file name # 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 # check whether Sweave.sty is seen by LaTeX
sweavesty <- system("kpsewhich Sweave.sty", intern=T, ignore.stderr=T) ls.sweavesty <- system("kpsewhich Sweave.sty", intern=T, ignore.stderr=T)
sp <- (length(sweavesty) == 0) 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 "Converter.h"
#include "ConverterCache.h"
#include "Buffer.h" #include "Buffer.h"
#include "buffer_funcs.h" #include "buffer_funcs.h"
#include "BufferParams.h" #include "BufferParams.h"
#include "ConverterCache.h"
#include "Encoding.h"
#include "ErrorList.h" #include "ErrorList.h"
#include "Format.h" #include "Format.h"
#include "Language.h" #include "Language.h"
@ -49,7 +50,7 @@ string const token_base("$$b");
string const token_to("$$o"); string const token_to("$$o");
string const token_path("$$p"); string const token_path("$$p");
string const token_orig_path("$$r"); string const token_orig_path("$$r");
string const token_encoding("$$e");
string const add_options(string const & command, string const & options) string const add_options(string const & command, string const & options)
@ -408,6 +409,7 @@ bool Converters::convert(Buffer const * buffer,
command = subst(command, token_to, quoteName(outfile2)); command = subst(command, token_to, quoteName(outfile2));
command = subst(command, token_path, quoteName(infile.onlyPath().absFileName())); command = subst(command, token_path, quoteName(infile.onlyPath().absFileName()));
command = subst(command, token_orig_path, quoteName(orig_from.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); command = libScriptSearch(command);
if (!conv.parselog.empty()) if (!conv.parselog.empty())