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.
This commit is contained in:
Georg Baum 2012-10-18 22:01:32 +02:00
parent 33c3e63f40
commit fbabfdfa46
4 changed files with 27 additions and 2 deletions

View File

@ -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 Noweb. Translate a noweb (aka literate programming) file. This should be
(almost?) equivalent to running \*[lq]noweb2lyx foo.tex foo.lyx\*[rq]. This option (almost?) equivalent to running \*[lq]noweb2lyx foo.tex foo.lyx\*[rq]. This option
requires the \fB\-c\fR 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 .\" .TP
.\" .BI \-r .\" .BI \-r
.\" Regular environments (see the section on \fISyntax Files\fR). If you give more than one .\" Regular environments (see the section on \fISyntax Files\fR). If you give more than one

View File

@ -447,6 +447,7 @@ string default_encoding;
string syntaxfile; string syntaxfile;
bool copy_files = false; bool copy_files = false;
bool overwrite_files = false; bool overwrite_files = false;
bool skip_children = false;
int error_code = 0; int error_code = 0;
/// return the number of arguments consumed /// 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-f Force overwrite of .lyx files.\n"
"\t-help Print this message and quit.\n" "\t-help Print this message and quit.\n"
"\t-n translate a noweb (aka literate programming) file.\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-roundtrip re-export created .lyx file infile.lyx.lyx to infile.lyx.tex.\n"
"\t-s syntaxfile read additional syntax file.\n" "\t-s syntaxfile read additional syntax file.\n"
"\t-sysdir SYSDIR Set system directory to SYSDIR.\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 &) int parse_roundtrip(string const &, string const &)
{ {
roundtrip = true; roundtrip = true;
@ -594,6 +603,7 @@ void easyParse(int & argc, char * argv[])
cmdmap["-f"] = parse_force; cmdmap["-f"] = parse_force;
cmdmap["-s"] = parse_syntaxfile; cmdmap["-s"] = parse_syntaxfile;
cmdmap["-n"] = parse_noweb; cmdmap["-n"] = parse_noweb;
cmdmap["-skipchildren"] = parse_skipchildren;
cmdmap["-sysdir"] = parse_sysdir; cmdmap["-sysdir"] = parse_sysdir;
cmdmap["-userdir"] = parse_userdir; cmdmap["-userdir"] = parse_userdir;
cmdmap["-roundtrip"] = parse_roundtrip; cmdmap["-roundtrip"] = parse_roundtrip;
@ -667,6 +677,12 @@ bool overwriteFiles()
} }
bool skipChildren()
{
return skip_children;
}
namespace { namespace {
/*! /*!

View File

@ -183,6 +183,8 @@ extern std::string getParentFilePath(bool input);
extern bool overwriteFiles(); extern bool overwriteFiles();
/// Do we need to copy included files to the output directory? /// Do we need to copy included files to the output directory?
extern bool copyFiles(); extern bool copyFiles();
/// Shall we skip child documents and keep them as TeX?
extern bool skipChildren();
/*! /*!

View File

@ -3814,8 +3814,9 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
string const abslyxname = makeAbsPath( string const abslyxname = makeAbsPath(
lyxname, getParentFilePath(false)).absFileName(); lyxname, getParentFilePath(false)).absFileName();
bool xfig = false; bool xfig = false;
if (!skipChildren())
external = FileName(absfigname).exists(); external = FileName(absfigname).exists();
if (t.cs() == "input") { if (t.cs() == "input" && !skipChildren()) {
string const ext = getExtension(abstexname); string const ext = getExtension(abstexname);
// Combined PS/LaTeX: // Combined PS/LaTeX:
@ -3867,6 +3868,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
FileName abssrc(abstexname); FileName abssrc(abstexname);
copy_file(abssrc, outname); copy_file(abssrc, outname);
} else if (t.cs() != "verbatiminput" && } else if (t.cs() != "verbatiminput" &&
!skipChildren() &&
tex2lyx(abstexname, FileName(abslyxname), tex2lyx(abstexname, FileName(abslyxname),
p.getEncoding())) { p.getEncoding())) {
outname = lyxname; outname = lyxname;