mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-29 13:04:58 +00:00
Adjust tex2lyx InsetArgument to format 446
tex2lyx does now allow mixed order of required and optional arguments.
This commit is contained in:
parent
1b0cbb6932
commit
16eb4f1ed7
@ -637,45 +637,39 @@ void output_command_layout(ostream & os, Parser & p, bool outer,
|
|||||||
}
|
}
|
||||||
context.check_deeper(os);
|
context.check_deeper(os);
|
||||||
context.check_layout(os);
|
context.check_layout(os);
|
||||||
// FIXME: Adjust to format 446!
|
Layout::LaTeXArgMap::const_iterator lait = context.layout->latexargs().begin();
|
||||||
// Since format 446, layouts do not require anymore all optional
|
Layout::LaTeXArgMap::const_iterator const laend = context.layout->latexargs().end();
|
||||||
// arguments before the required ones. Needs to be implemented!
|
for (; lait != laend; ++lait) {
|
||||||
int optargs = 0;
|
|
||||||
while (optargs < context.layout->optArgs()) {
|
|
||||||
eat_whitespace(p, os, context, false);
|
eat_whitespace(p, os, context, false);
|
||||||
if (p.next_token().cat() == catEscape ||
|
if (lait->second.mandatory) {
|
||||||
p.next_token().character() != '[')
|
if (p.next_token().cat() != catBegin)
|
||||||
break;
|
break;
|
||||||
p.get_token(); // eat '['
|
p.get_token(); // eat '{'
|
||||||
// FIXME: Just a workaround. InsetArgument::updateBuffer
|
// FIXME: Just a workaround. InsetArgument::updateBuffer
|
||||||
// will compute a proper ID for all "999" Arguments
|
// will compute a proper ID for all "999" Arguments
|
||||||
// (which is also what lyx2lyx produces).
|
// (which is also what lyx2lyx produces).
|
||||||
// However, tex2lyx should be able to output proper IDs
|
// However, tex2lyx should be able to output proper IDs
|
||||||
// itself.
|
// itself.
|
||||||
begin_inset(os, "Argument 999\n");
|
begin_inset(os, "Argument 999\n");
|
||||||
os << "status collapsed\n\n";
|
os << "status collapsed\n\n";
|
||||||
parse_text_in_inset(p, os, FLAG_BRACK_LAST, outer, context);
|
parse_text_in_inset(p, os, FLAG_BRACE_LAST, outer, context);
|
||||||
end_inset(os);
|
end_inset(os);
|
||||||
|
} else {
|
||||||
|
if (p.next_token().cat() == catEscape ||
|
||||||
|
p.next_token().character() != '[')
|
||||||
|
break;
|
||||||
|
p.get_token(); // eat '['
|
||||||
|
// FIXME: Just a workaround. InsetArgument::updateBuffer
|
||||||
|
// will compute a proper ID for all "999" Arguments
|
||||||
|
// (which is also what lyx2lyx produces).
|
||||||
|
// However, tex2lyx should be able to output proper IDs
|
||||||
|
// itself.
|
||||||
|
begin_inset(os, "Argument 999\n");
|
||||||
|
os << "status collapsed\n\n";
|
||||||
|
parse_text_in_inset(p, os, FLAG_BRACK_LAST, outer, context);
|
||||||
|
end_inset(os);
|
||||||
|
}
|
||||||
eat_whitespace(p, os, context, false);
|
eat_whitespace(p, os, context, false);
|
||||||
++optargs;
|
|
||||||
}
|
|
||||||
int reqargs = 0;
|
|
||||||
while (reqargs < context.layout->requiredArgs()) {
|
|
||||||
eat_whitespace(p, os, context, false);
|
|
||||||
if (p.next_token().cat() != catBegin)
|
|
||||||
break;
|
|
||||||
p.get_token(); // eat '{'
|
|
||||||
// FIXME: Just a workaround. InsetArgument::updateBuffer
|
|
||||||
// will compute a proper ID for all "999" Arguments
|
|
||||||
// (which is also what lyx2lyx produces).
|
|
||||||
// However, tex2lyx should be able to output proper IDs
|
|
||||||
// itself.
|
|
||||||
begin_inset(os, "Argument 999\n");
|
|
||||||
os << "status collapsed\n\n";
|
|
||||||
parse_text_in_inset(p, os, FLAG_BRACE_LAST, outer, context);
|
|
||||||
end_inset(os);
|
|
||||||
eat_whitespace(p, os, context, false);
|
|
||||||
++reqargs;
|
|
||||||
}
|
}
|
||||||
parse_text(p, os, FLAG_ITEM, outer, context);
|
parse_text(p, os, FLAG_ITEM, outer, context);
|
||||||
context.check_end_layout(os);
|
context.check_end_layout(os);
|
||||||
@ -1734,7 +1728,7 @@ void parse_environment(Parser & p, ostream & os, bool outer,
|
|||||||
<< "status collapsed\n";
|
<< "status collapsed\n";
|
||||||
if (newinsetlayout->isPassThru()) {
|
if (newinsetlayout->isPassThru()) {
|
||||||
string const arg = p.verbatimEnvironment(name);
|
string const arg = p.verbatimEnvironment(name);
|
||||||
Context context(true, parent_context.textclass,
|
Context context(true, parent_context.textclass,
|
||||||
&parent_context.textclass.plainLayout(),
|
&parent_context.textclass.plainLayout(),
|
||||||
parent_context.layout);
|
parent_context.layout);
|
||||||
output_ert(os, arg, parent_context);
|
output_ert(os, arg, parent_context);
|
||||||
@ -3905,7 +3899,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
|||||||
string delim = p.get_token().asInput();
|
string delim = p.get_token().asInput();
|
||||||
Parser::Arg arg = p.verbatimStuff(delim);
|
Parser::Arg arg = p.verbatimStuff(delim);
|
||||||
if (arg.first)
|
if (arg.first)
|
||||||
output_ert_inset(os, "\\verb" + delim
|
output_ert_inset(os, "\\verb" + delim
|
||||||
+ arg.second + delim, context);
|
+ arg.second + delim, context);
|
||||||
else
|
else
|
||||||
cerr << "invalid \\verb command. Skipping" << endl;
|
cerr << "invalid \\verb command. Skipping" << endl;
|
||||||
@ -4499,7 +4493,6 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
|||||||
newcontext.layout = &context.textclass.plainLayout();
|
newcontext.layout = &context.textclass.plainLayout();
|
||||||
output_ert(os, arg, newcontext);
|
output_ert(os, arg, newcontext);
|
||||||
} else
|
} else
|
||||||
|
|
||||||
parse_text_in_inset(p, os, FLAG_ITEM, false, context, newinsetlayout);
|
parse_text_in_inset(p, os, FLAG_ITEM, false, context, newinsetlayout);
|
||||||
end_inset(os);
|
end_inset(os);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user