2003-08-04 10:26:10 +00:00
|
|
|
|
// -*- C++ -*-
|
2003-08-19 10:04:35 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file tex2lyx.h
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
* \author Jean-Marc Lasgouttes
|
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-08-19 10:04:35 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2003-04-17 15:05:17 +00:00
|
|
|
|
#ifndef TEX2LYX_H
|
|
|
|
|
#define TEX2LYX_H
|
|
|
|
|
|
|
|
|
|
#include "texparser.h"
|
2003-07-28 21:58:09 +00:00
|
|
|
|
#include "lyxtextclass.h"
|
2003-04-17 15:05:17 +00:00
|
|
|
|
|
|
|
|
|
#include <iosfwd>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
2003-11-19 10:35:50 +00:00
|
|
|
|
#include <map>
|
2003-04-17 15:05:17 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2006-11-26 21:30:39 +00:00
|
|
|
|
namespace support { class FileName; }
|
|
|
|
|
|
2003-08-04 10:26:10 +00:00
|
|
|
|
class Context;
|
2003-04-17 15:05:17 +00:00
|
|
|
|
|
2003-08-04 10:26:10 +00:00
|
|
|
|
/// in preamble.C
|
2003-10-23 11:46:33 +00:00
|
|
|
|
LyXTextClass const parse_preamble(Parser & p, std::ostream & os, std::string const & forceclass);
|
2003-04-17 15:05:17 +00:00
|
|
|
|
|
2004-08-10 09:40:53 +00:00
|
|
|
|
/// used packages with options
|
|
|
|
|
extern std::map<std::string, std::vector<std::string> > used_packages;
|
|
|
|
|
|
2003-08-04 10:26:10 +00:00
|
|
|
|
|
|
|
|
|
/// in text.C
|
2006-03-16 15:37:35 +00:00
|
|
|
|
std::string translate_len(std::string const &);
|
|
|
|
|
|
2003-07-28 21:58:09 +00:00
|
|
|
|
void parse_text(Parser & p, std::ostream & os, unsigned flags, bool outer,
|
2003-08-04 10:26:10 +00:00
|
|
|
|
Context & context);
|
|
|
|
|
|
2005-07-26 11:58:43 +00:00
|
|
|
|
/*!
|
|
|
|
|
* Parses a subdocument, usually useful in insets (whence the name).
|
|
|
|
|
*
|
|
|
|
|
* It ignores \c context.need_layout and \c context.need_end_layout and
|
|
|
|
|
* starts and ends always a new layout.
|
|
|
|
|
* Therefore this may only be used to parse text in insets or table cells.
|
|
|
|
|
*/
|
2003-09-09 18:27:24 +00:00
|
|
|
|
void parse_text_in_inset(Parser & p, std::ostream & os, unsigned flags,
|
2005-07-26 11:58:43 +00:00
|
|
|
|
bool outer, Context const & context);
|
2003-04-17 15:05:17 +00:00
|
|
|
|
|
|
|
|
|
|
2003-08-04 10:26:10 +00:00
|
|
|
|
/// in math.C
|
2003-04-17 15:05:17 +00:00
|
|
|
|
void parse_math(Parser & p, std::ostream & os, unsigned flags, mode_type mode);
|
|
|
|
|
|
|
|
|
|
|
2003-08-04 10:26:10 +00:00
|
|
|
|
/// in table.C
|
2004-12-15 20:21:43 +00:00
|
|
|
|
void handle_tabular(Parser & p, std::ostream & os, bool is_long_tabular,
|
2006-04-05 23:56:29 +00:00
|
|
|
|
Context & context);
|
2003-08-04 10:26:10 +00:00
|
|
|
|
|
2003-04-17 15:05:17 +00:00
|
|
|
|
|
2003-08-04 10:26:10 +00:00
|
|
|
|
/// in tex2lyx.C
|
2003-04-17 15:05:17 +00:00
|
|
|
|
std::string const trim(std::string const & a, char const * p = " \t\n\r");
|
|
|
|
|
|
2003-06-30 11:36:08 +00:00
|
|
|
|
void split(std::string const & s, std::vector<std::string> & result,
|
|
|
|
|
char delim = ',');
|
|
|
|
|
std::string join(std::vector<std::string> const & input,
|
|
|
|
|
char const * delim);
|
2003-04-17 15:05:17 +00:00
|
|
|
|
|
|
|
|
|
bool is_math_env(std::string const & name);
|
2004-06-28 06:53:12 +00:00
|
|
|
|
char const * const * is_known(std::string const &, char const * const *);
|
2003-04-17 15:05:17 +00:00
|
|
|
|
|
2005-01-06 13:22:20 +00:00
|
|
|
|
/*!
|
|
|
|
|
* Adds the command \p command to the list of known commands.
|
|
|
|
|
* \param o1 first optional parameter to the latex command \newcommand
|
|
|
|
|
* (with brackets), or the empty string if there were no optional arguments.
|
|
|
|
|
* \param o2 wether \newcommand had a second optional parameter
|
|
|
|
|
*/
|
|
|
|
|
void add_known_command(std::string const & command, std::string const & o1,
|
2006-04-05 23:56:29 +00:00
|
|
|
|
bool o2);
|
2005-01-06 13:22:20 +00:00
|
|
|
|
|
2003-04-17 15:05:17 +00:00
|
|
|
|
// Access to environment stack
|
2003-04-23 15:14:43 +00:00
|
|
|
|
extern std::vector<std::string> active_environments;
|
|
|
|
|
std::string active_environment();
|
2003-04-17 15:05:17 +00:00
|
|
|
|
|
2003-11-19 10:35:50 +00:00
|
|
|
|
enum ArgumentType {
|
|
|
|
|
required,
|
|
|
|
|
verbatim,
|
|
|
|
|
optional
|
|
|
|
|
};
|
|
|
|
|
|
2005-07-14 15:19:01 +00:00
|
|
|
|
typedef std::map<std::string, std::vector<ArgumentType> > CommandMap;
|
2003-11-19 10:35:50 +00:00
|
|
|
|
|
2005-07-14 15:19:01 +00:00
|
|
|
|
/// Known TeX commands with arguments that get parsed into ERT.
|
|
|
|
|
extern CommandMap known_commands;
|
|
|
|
|
/// Known TeX environments with arguments that get parsed into ERT.
|
|
|
|
|
extern CommandMap known_environments;
|
|
|
|
|
/// Known TeX math environments with arguments that get parsed into LyX mathed.
|
|
|
|
|
extern CommandMap known_math_environments;
|
2006-08-13 09:46:28 +00:00
|
|
|
|
///
|
|
|
|
|
extern bool noweb_mode;
|
2004-07-29 17:03:37 +00:00
|
|
|
|
|
|
|
|
|
/// path of the master .tex file
|
|
|
|
|
extern std::string getMasterFilePath();
|
2005-05-25 16:01:19 +00:00
|
|
|
|
/// path of the currently processed .tex file
|
|
|
|
|
extern std::string getParentFilePath();
|
2004-07-29 17:03:37 +00:00
|
|
|
|
|
|
|
|
|
|
2005-05-25 16:01:19 +00:00
|
|
|
|
/*!
|
|
|
|
|
* Reads tex input from \a infilename and writes lyx output to \a outfilename.
|
2003-10-23 11:46:33 +00:00
|
|
|
|
* Uses some common settings for the preamble, so this should only
|
|
|
|
|
* be used more than once for included documents.
|
|
|
|
|
* Caution: Overwrites the existing preamble settings if the new document
|
2005-05-25 16:01:19 +00:00
|
|
|
|
* contains a preamble.
|
|
|
|
|
* \return true if the conversion was successful, else false.
|
|
|
|
|
*/
|
2006-11-26 21:30:39 +00:00
|
|
|
|
bool tex2lyx(std::string const & infilename, support::FileName const & outfilename);
|
2003-10-23 11:46:33 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
2003-04-17 15:05:17 +00:00
|
|
|
|
#endif
|