// the inner env
if (!inner_type.empty() && (inner_flags & FLAG_END))
active_environments.pop_back();
+
+ // Ensure that the end of the outer box is parsed correctly:
+ // The opening brace has been eaten by parse_outer_box()
+ if (!outer_type.empty() && (outer_flags & FLAG_ITEM)) {
+ outer_flags &= ~FLAG_ITEM;
+ outer_flags |= FLAG_BRACE_LAST;
+ }
parse_text(p, os, outer_flags, outer, parent_context);
if (outer_flags & FLAG_END)
handle_ert(os, "\\end{" + outer_type + '}',
}
else if (t.cs() == "item") {
- p.skip_spaces();
string s;
- bool optarg = false;
- if (p.next_token().cat() != catEscape &&
- p.next_token().character() == '[') {
- p.get_token(); // eat '['
- s = parse_text_snippet(p, FLAG_BRACK_LAST,
- outer, context);
- optarg = true;
- }
+ bool const optarg = p.hasOpt();
+ if (optarg) {
+ // FIXME: This swallows comments, but we cannot use
+ // eat_whitespace() since we must not output
+ // anything before the item.
+ s = p.getArg('[', ']');
+ } else
+ p.skip_spaces(false);
context.set_item();
context.check_layout(os);
if (context.has_item) {
if (context.layout->labeltype != LABEL_MANUAL) {
// LyX does not support \item[\mybullet]
// in itemize environments
- handle_ert(os, "[", context);
- os << s;
- handle_ert(os, "]", context);
+ Parser p2(s + ']');
+ os << parse_text_snippet(p2,
+ FLAG_BRACK_LAST, outer, context);
} else if (!s.empty()) {
+ // LyX adds braces around the argument,
+ // so we need to remove them here.
+ if (s.size() > 2 && s[0] == '{' &&
+ s[s.size()-1] == '}')
+ s = s.substr(1, s.size()-2);
+ // If the argument contains a space we
+ // must put it into ERT: Otherwise LyX
+ // would misinterpret the space as
+ // item delimiter (bug 7663)
+ if (contains(s, ' ')) {
+ handle_ert(os, s, context);
+ } else {
+ Parser p2(s + ']');
+ os << parse_text_snippet(p2,
+ FLAG_BRACK_LAST,
+ outer, context);
+ }
// The space is needed to separate the
// item from the rest of the sentence.
- os << s << ' ';
+ os << ' ';
eat_whitespace(p, os, context, false);
}
}
}
//\makebox() is part of the picture environment and different from \makebox{}
- //\makebox{} will be parsed by parse_box when bug 2956 is fixed
+ //\makebox{} will be parsed by parse_box
else if (t.cs() == "makebox") {
string arg = t.asInput();
if (p.next_token().character() == '(') {
//the syntax is: \makebox(x,y)[position]{content}
arg += p.getFullParentheseArg();
arg += p.getFullOpt();
- handle_ert(os, arg + p.get_token().asInput(), context);
+ eat_whitespace(p, os, context, false);
+ handle_ert(os, arg + '{', context);
+ eat_whitespace(p, os, context, false);
+ parse_text(p, os, FLAG_ITEM, outer, context);
+ handle_ert(os, "}", context);
} else
//the syntax is: \makebox[width][position]{content}
parse_box(p, os, 0, FLAG_ITEM, outer, context,