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,"`
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"
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;
}
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;
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;
+ }
}
// }])