The branch, master, has been updated. - Log -----------------------------------------------------------------
commit fbabfdfa4619ea170a684db0b3687441ecf0fd61 Author: Georg Baum <[email protected]> Date: Thu Oct 18 22:01:32 2012 +0200 Add -skipchildren command line switch (bug #4435) This allows to skip generated files, e.g. an alternative xfig export which we do not understand, as mentioned in bug #4435. diff --git a/src/tex2lyx/tex2lyx.1in b/src/tex2lyx/tex2lyx.1in index 267d0d4..4ad7fad 100644 --- a/src/tex2lyx/tex2lyx.1in +++ b/src/tex2lyx/tex2lyx.1in @@ -48,6 +48,11 @@ Use the \fB\-f\fR option (carefully) to clobber any existing files. Noweb. Translate a noweb (aka literate programming) file. This should be (almost?) equivalent to running \*[lq]noweb2lyx foo.tex foo.lyx\*[rq]. This option requires the \fB\-c\fR option. +.TP +.BI \-skipchildren +Do not translate child documents included via \f(CW\einclude\fR and \f(CW\einput\fR. +This option is useful if the child documents are generated files and/or contain many +commands that \fBtex2lyx\fR does not understand yet. .\" .TP .\" .BI \-r .\" Regular environments (see the section on \fISyntax Files\fR). If you give more than one diff --git a/src/tex2lyx/tex2lyx.cpp b/src/tex2lyx/tex2lyx.cpp index 57436cb..360c126 100644 --- a/src/tex2lyx/tex2lyx.cpp +++ b/src/tex2lyx/tex2lyx.cpp @@ -447,6 +447,7 @@ string default_encoding; string syntaxfile; bool copy_files = false; bool overwrite_files = false; +bool skip_children = false; int error_code = 0; /// return the number of arguments consumed @@ -463,6 +464,7 @@ int parse_help(string const &, string const &) "\t-f Force overwrite of .lyx files.\n" "\t-help Print this message and quit.\n" "\t-n translate a noweb (aka literate programming) file.\n" + "\t-skipchildren Do not translate included child documents.\n" "\t-roundtrip re-export created .lyx file infile.lyx.lyx to infile.lyx.tex.\n" "\t-s syntaxfile read additional syntax file.\n" "\t-sysdir SYSDIR Set system directory to SYSDIR.\n" @@ -565,6 +567,13 @@ int parse_noweb(string const &, string const &) } +int parse_skipchildren(string const &, string const &) +{ + skip_children = true; + return 0; +} + + int parse_roundtrip(string const &, string const &) { roundtrip = true; @@ -594,6 +603,7 @@ void easyParse(int & argc, char * argv[]) cmdmap["-f"] = parse_force; cmdmap["-s"] = parse_syntaxfile; cmdmap["-n"] = parse_noweb; + cmdmap["-skipchildren"] = parse_skipchildren; cmdmap["-sysdir"] = parse_sysdir; cmdmap["-userdir"] = parse_userdir; cmdmap["-roundtrip"] = parse_roundtrip; @@ -667,6 +677,12 @@ bool overwriteFiles() } +bool skipChildren() +{ + return skip_children; +} + + namespace { /*! diff --git a/src/tex2lyx/tex2lyx.h b/src/tex2lyx/tex2lyx.h index 1a98a5f..37585fd 100644 --- a/src/tex2lyx/tex2lyx.h +++ b/src/tex2lyx/tex2lyx.h @@ -183,6 +183,8 @@ extern std::string getParentFilePath(bool input); extern bool overwriteFiles(); /// Do we need to copy included files to the output directory? extern bool copyFiles(); +/// Shall we skip child documents and keep them as TeX? +extern bool skipChildren(); /*! diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index 9dce78a..e397c32 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -3814,8 +3814,9 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, string const abslyxname = makeAbsPath( lyxname, getParentFilePath(false)).absFileName(); bool xfig = false; - external = FileName(absfigname).exists(); - if (t.cs() == "input") { + if (!skipChildren()) + external = FileName(absfigname).exists(); + if (t.cs() == "input" && !skipChildren()) { string const ext = getExtension(abstexname); // Combined PS/LaTeX: @@ -3867,6 +3868,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, FileName abssrc(abstexname); copy_file(abssrc, outname); } else if (t.cs() != "verbatiminput" && + !skipChildren() && tex2lyx(abstexname, FileName(abslyxname), p.getEncoding())) { outname = lyxname; ----------------------------------------------------------------------- Summary of changes: src/tex2lyx/tex2lyx.1in | 5 +++++ src/tex2lyx/tex2lyx.cpp | 16 ++++++++++++++++ src/tex2lyx/tex2lyx.h | 2 ++ src/tex2lyx/text.cpp | 6 ++++-- 4 files changed, 27 insertions(+), 2 deletions(-) hooks/post-receive -- The LyX Source Repository
