mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
* tex2lyx support for multiple optional argument using \newlyxcommand
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22282 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
f85fccef65
commit
3f5e1c0e27
@ -111,7 +111,7 @@ CommandMap known_math_environments;
|
||||
|
||||
|
||||
void add_known_command(string const & command, string const & o1,
|
||||
bool o2)
|
||||
unsigned optionalsNum)
|
||||
{
|
||||
// We have to handle the following cases:
|
||||
// definition o1 o2 invocation result
|
||||
@ -127,8 +127,7 @@ void add_known_command(string const & command, string const & o1,
|
||||
if (isStrUnsignedInt(opt1)) {
|
||||
// The command has arguments
|
||||
nargs = convert<unsigned int>(opt1);
|
||||
if (nargs > 0 && o2) {
|
||||
// The first argument is optional
|
||||
for (unsigned int i = 0; i < optionalsNum; ++i) {
|
||||
arguments.push_back(optional);
|
||||
--nargs;
|
||||
}
|
||||
|
@ -75,11 +75,11 @@ char const * const * is_known(std::string const &, char const * const *);
|
||||
/*!
|
||||
* 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
|
||||
* (with brackets), or the empty string if there were no optional argument.
|
||||
* \param optionalsNum is the number of optional parameters
|
||||
*/
|
||||
void add_known_command(std::string const & command, std::string const & o1,
|
||||
bool o2);
|
||||
unsigned optionalsNum);
|
||||
|
||||
// Access to environment stack
|
||||
extern std::vector<std::string> active_environments;
|
||||
|
@ -2393,11 +2393,18 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
||||
}
|
||||
string const command = p.verbatim_item();
|
||||
string const opt1 = p.getOpt();
|
||||
string const opt2 = p.getFullOpt();
|
||||
add_known_command(command, opt1, !opt2.empty());
|
||||
string const ert = name + '{' + command + '}' +
|
||||
opt1 + opt2 +
|
||||
'{' + p.verbatim_item() + '}';
|
||||
string optionals;
|
||||
unsigned optionalsNum = 0;
|
||||
while (true) {
|
||||
string const opt = p.getFullOpt();
|
||||
if (opt.empty())
|
||||
break;
|
||||
optionalsNum++;
|
||||
optionals += opt;
|
||||
}
|
||||
add_known_command(command, opt1, optionalsNum);
|
||||
string const ert = name + '{' + command + '}' + opt1
|
||||
+ optionals + '{' + p.verbatim_item() + '}';
|
||||
|
||||
context.check_layout(os);
|
||||
begin_inset(os, "FormulaMacro");
|
||||
|
Loading…
Reference in New Issue
Block a user