namespace {
-void output_arguments(ostream &, Parser &, bool, bool, bool, Context &,
+void output_arguments(ostream &, Parser &, bool, bool, string, Context &,
Layout::LaTeXArgMap const &);
}
else
newcontext.font = context.font;
if (layout)
- output_arguments(os, p, outer, false, false, newcontext,
+ output_arguments(os, p, outer, false, string(), newcontext,
layout->latexargs());
parse_text(p, os, flags, outer, newcontext, rdelim);
if (layout)
- output_arguments(os, p, outer, false, true, newcontext,
+ output_arguments(os, p, outer, false, "post", newcontext,
layout->postcommandargs());
newcontext.check_end_layout(os);
}
}
-void output_arguments(ostream & os, Parser & p, bool outer, bool need_layout, bool post,
+void output_arguments(ostream & os, Parser & p, bool outer, bool need_layout, string const prefix,
Context & context, Layout::LaTeXArgMap const & latexargs)
{
- if (need_layout) {
- context.check_layout(os);
- need_layout = false;
- } else
- need_layout = true;
+ if (context.layout->latextype != LATEX_ITEM_ENVIRONMENT || !prefix.empty()) {
+ if (need_layout) {
+ context.check_layout(os);
+ need_layout = false;
+ } else
+ need_layout = true;
+ }
int i = 0;
Layout::LaTeXArgMap::const_iterator lait = latexargs.begin();
Layout::LaTeXArgMap::const_iterator const laend = latexargs.end();
need_layout = false;
}
begin_inset(os, "Argument ");
- if (post)
- os << "post:";
+ if (!prefix.empty())
+ os << prefix << ':';
os << i << "\nstatus collapsed\n\n";
parse_text_in_inset(p, os, FLAG_RDELIM, outer, context, 0, rdelim);
end_inset(os);
need_layout = false;
}
begin_inset(os, "Argument ");
- if (post)
- os << "post:";
+ if (!prefix.empty())
+ os << prefix << ':';
os << i << "\nstatus collapsed\n\n";
parse_text_in_inset(p, os, FLAG_RDELIM, outer, context, 0, rdelim);
end_inset(os);
context.need_end_deeper = true;
}
context.check_deeper(os);
- output_arguments(os, p, outer, true, false, context,
+ output_arguments(os, p, outer, true, string(), context,
context.layout->latexargs());
parse_text(p, os, FLAG_ITEM, outer, context);
- output_arguments(os, p, outer, false, true, context,
+ output_arguments(os, p, outer, false, "post", context,
context.layout->postcommandargs());
context.check_end_layout(os);
if (parent_context.deeper_paragraph) {
}
context.check_deeper(os);
// handle known optional and required arguments
- // FIXME: for item environments, this is currently
- // placed wrongly (in an empty paragraph). It has to go to
- // the first \item par instead.
- if (context.layout->latextype == LATEX_ENVIRONMENT
- || context.layout->latextype == LATEX_ITEM_ENVIRONMENT)
- output_arguments(os, p, outer, false, false, context,
+ if (context.layout->latextype == LATEX_ENVIRONMENT)
+ output_arguments(os, p, outer, false, string(), context,
context.layout->latexargs());
+ else if (context.layout->latextype == LATEX_ITEM_ENVIRONMENT) {
+ ostringstream oss;
+ output_arguments(oss, p, outer, false, string(), context,
+ context.layout->latexargs());
+ context.list_extra_stuff = oss.str();
+ }
parse_text(p, os, FLAG_END, outer, context);
if (context.layout->latextype == LATEX_ENVIRONMENT)
- output_arguments(os, p, outer, false, true, context,
+ output_arguments(os, p, outer, false, "post", context,
context.layout->postcommandargs());
context.check_end_layout(os);
if (parent_context.deeper_paragraph) {
continue;
}
- if (t.cs() == "item") {
+ // "item" by default, but could be something else
+ if (t.cs() == context.layout->itemcommand()) {
string s;
- bool const optarg = p.hasOpt();
- if (optarg) {
+ if (context.layout->labeltype == LABEL_MANUAL) {
// FIXME: This swallows comments, but we cannot use
// eat_whitespace() since we must not output
// anything before the item.
// An item in an unknown list-like environment
// FIXME: Do this in check_layout()!
context.has_item = false;
- if (optarg)
- output_ert_inset(os, "\\item", context);
- else
- output_ert_inset(os, "\\item ", context);
+ string item = "\\" + context.layout->itemcommand();
+ if (!p.hasOpt())
+ item += " ";
+ output_ert_inset(os, item, context);
}
- if (optarg) {
- if (context.layout->labeltype != LABEL_MANUAL) {
- // handle option of itemize item
- begin_inset(os, "Argument item:1\n");
- os << "status open\n";
- os << "\n\\begin_layout Plain Layout\n";
- Parser p2(s + ']');
- os << parse_text_snippet(p2,
- FLAG_BRACK_LAST, outer, context);
- // we must not use context.check_end_layout(os)
- // because that would close the outer itemize layout
- os << "\n\\end_layout\n";
- end_inset(os);
- eat_whitespace(p, os, context, false);
- } else if (!s.empty()) {
+ if (context.layout->labeltype != LABEL_MANUAL)
+ output_arguments(os, p, outer, false, "item", context,
+ context.layout->itemargs());
+ if (!context.list_extra_stuff.empty()) {
+ os << context.list_extra_stuff;
+ context.list_extra_stuff.clear();
+ }
+ else if (!s.empty()) {
// LyX adds braces around the argument,
// so we need to remove them here.
if (s.size() > 2 && s[0] == '{' &&
os << ' ';
eat_whitespace(p, os, context, false);
}
- }
continue;
}