Angus Leeming wrote: > Georg Baum wrote: >> Nobody answered this one. >> >> Do we want >> tex2lyx infile.tex >> >> to create infile.lyx or do we want it to write to stdout like it is doing >> now? > > I think that it should write to stdout. I think that we should also > support > $ tex2lyx -o outfile.lyx infile.tex > $ tex2lyx --outfile outfile.lyx infile.tex > and > $ tex2lyx --outdir somedir infile.tex > > I think that tex2lyx should exit (creating nothing) if it ascertains that > it will create more than one file and --outdir has not been specified.
Why? It is IMO rather useful to be able to convert a larger project with included files in subdirectories so that the directory structure is preserved. Anyway, the only purpose of this patch is to make the Import LaTeX menu entry working again, so I would like to apply the attached version. I'll leave the rest for somebody else to do (probably post 1.4.0). Lars? > You asked ;-) And you answered more than I asked ;-) Georg
Index: src/tex2lyx/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/tex2lyx/ChangeLog,v retrieving revision 1.100 diff -u -p -r1.100 ChangeLog --- src/tex2lyx/ChangeLog 16 Jul 2005 15:18:14 -0000 1.100 +++ src/tex2lyx/ChangeLog 20 Jul 2005 09:52:55 -0000 @@ -1,3 +1,7 @@ +2005-07-25 Georg Baum <[EMAIL PROTECTED]> + + * tex2lyx.C (main): allow specification of output file name + 2005-07-18 Lars Gullik Bjønnes <[EMAIL PROTECTED]> * Makefile.am (EXTRA_DIST): add tex2lyx.man Index: src/tex2lyx/tex2lyx.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/tex2lyx/tex2lyx.C,v retrieving revision 1.72 diff -u -p -r1.72 tex2lyx.C --- src/tex2lyx/tex2lyx.C 16 Jul 2005 15:18:14 -0000 1.72 +++ src/tex2lyx/tex2lyx.C 20 Jul 2005 09:52:55 -0000 @@ -267,7 +267,7 @@ typedef boost::function<int(string const int parse_help(string const &, string const &) { - cerr << "Usage: tex2lyx [ command line switches ] <infile.tex>\n" + cerr << "Usage: tex2lyx [ command line switches ] <infile.tex> [<outfile.lyx>]\n" "Command line switches (case sensitive):\n" "\t-help summarize tex2lyx usage\n" "\t-f Force creation of .lyx files even if they exist already\n" @@ -482,7 +482,7 @@ int main(int argc, char * argv[]) easyParse(argc, argv); if (argc <= 1) { - cerr << "Usage: tex2lyx [ command line switches ] <infile.tex>\n" + cerr << "Usage: tex2lyx [ command line switches ] <infile.tex> [<outfile.lyx>]\n" "See tex2lyx -help." << endl; return 2; } @@ -491,6 +491,13 @@ int main(int argc, char * argv[]) lyx::support::init_package(argv[0], cl_system_support, cl_user_support, lyx::support::top_build_dir_is_two_levels_up); + // Now every known option is parsed. Look for input and output + // file name (the latter is optional). + string const infilename = MakeAbsPath(argv[1]); + string outfilename; + if (argc > 2) + outfilename = MakeAbsPath(argv[2]); + string const system_syntaxfile = lyx::support::LibFileSearch("", "syntax.default"); if (system_syntaxfile.empty()) { cerr << "Error: Could not find syntax file \"syntax.default\"." << endl; @@ -500,14 +507,20 @@ int main(int argc, char * argv[]) if (!syntaxfile.empty()) read_syntaxfile(syntaxfile); - string const infilename = MakeAbsPath(argv[1]); masterFilePath = OnlyPath(infilename); parentFilePath = masterFilePath; - if (tex2lyx(infilename, cout)) - return EXIT_SUCCESS; - else - return EXIT_FAILURE; + if (outfilename.empty() || outfilename == "-") { + if (tex2lyx(infilename, cout)) + return EXIT_SUCCESS; + else + return EXIT_FAILURE; + } else { + if (tex2lyx(infilename, outfilename)) + return EXIT_SUCCESS; + else + return EXIT_FAILURE; + } } // }]) Index: lib/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/ChangeLog,v retrieving revision 1.725 diff -u -p -r1.725 ChangeLog --- lib/ChangeLog 19 Jul 2005 20:56:11 -0000 1.725 +++ lib/ChangeLog 25 Jul 2005 07:29:02 -0000 @@ -1,3 +1,7 @@ +2005-07-25 Georg Baum <[EMAIL PROTECTED]> + + * configure.m4: fix invocation of tex2lyx again. + 2005-07-19 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> * configure.m4: fi invocation of tex2lyx. Index: lib/configure.m4 =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/configure.m4,v retrieving revision 1.105 diff -u -p -r1.105 configure.m4 --- lib/configure.m4 19 Jul 2005 20:56:11 -0000 1.105 +++ lib/configure.m4 25 Jul 2005 07:29:02 -0000 @@ -260,7 +260,7 @@ GRACE_VIEWER="$GRACE_EDITOR" SEARCH_PROG([for a text editor], TEXT_EDITOR, xemacs gvim kedit kwrite kate nedit gedit notepad) # Search for an installed tex2lyx or a ready-to-install one -SEARCH_PROG([for a LaTeX -> LyX converter],tex_to_lyx_command, "$PWD/../src/tex2lyx/tex2lyx -f \$\$i >\$\$o" "tex2lyx$version_suffix -f \$\$i >\$\$o") +SEARCH_PROG([for a LaTeX -> LyX converter],tex_to_lyx_command, "$PWD/../src/tex2lyx/tex2lyx -f \$\$i \$\$o" "tex2lyx$version_suffix -f \$\$i \$\$o") SEARCH_PROG([for a Noweb -> LyX converter],literate_to_lyx_command,"noweb2lyx \$\$i \$\$o") literate_to_lyx_command=`echo $literate_to_lyx_command | sed "s,noweb2lyx,noweb2lyx$version_suffix,"`