mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Fix bug #7663: Misparsing of description \item with spaces
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40182 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
d139b234b2
commit
2a216184c4
@ -2311,6 +2311,10 @@ void Paragraph::latex(BufferParams const & bparams,
|
|||||||
if (body_pos > 0) {
|
if (body_pos > 0) {
|
||||||
// the optional argument is kept in curly brackets in
|
// the optional argument is kept in curly brackets in
|
||||||
// case it contains a ']'
|
// case it contains a ']'
|
||||||
|
// This is not strictly needed, but if this is changed it
|
||||||
|
// would be a file format change, and tex2lyx would need
|
||||||
|
// to be adjusted, since it unconditionally removes the
|
||||||
|
// braces when it parses \item.
|
||||||
os << "[{";
|
os << "[{";
|
||||||
column += 2;
|
column += 2;
|
||||||
basefont = getLabelFont(bparams, outerfont);
|
basefont = getLabelFont(bparams, outerfont);
|
||||||
|
@ -277,6 +277,10 @@ What else? Well, we have descriptions:
|
|||||||
\begin{description}
|
\begin{description}
|
||||||
\item[ABC] first item
|
\item[ABC] first item
|
||||||
\item[BCD] second one
|
\item[BCD] second one
|
||||||
|
\item[{x y z}] with space
|
||||||
|
\item % hi there
|
||||||
|
[{x y % bla
|
||||||
|
z}] and with comments
|
||||||
\end{description}
|
\end{description}
|
||||||
labelings:
|
labelings:
|
||||||
\begin{lyxlist}{00.00.0000}
|
\begin{lyxlist}{00.00.0000}
|
||||||
|
@ -2179,16 +2179,15 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
else if (t.cs() == "item") {
|
else if (t.cs() == "item") {
|
||||||
p.skip_spaces();
|
|
||||||
string s;
|
string s;
|
||||||
bool optarg = false;
|
bool const optarg = p.hasOpt();
|
||||||
if (p.next_token().cat() != catEscape &&
|
if (optarg) {
|
||||||
p.next_token().character() == '[') {
|
// FIXME: This swallows comments, but we cannot use
|
||||||
p.get_token(); // eat '['
|
// eat_whitespace() since we must not output
|
||||||
s = parse_text_snippet(p, FLAG_BRACK_LAST,
|
// anything before the item.
|
||||||
outer, context);
|
s = p.getArg('[', ']');
|
||||||
optarg = true;
|
} else
|
||||||
}
|
p.skip_spaces(false);
|
||||||
context.set_item();
|
context.set_item();
|
||||||
context.check_layout(os);
|
context.check_layout(os);
|
||||||
if (context.has_item) {
|
if (context.has_item) {
|
||||||
@ -2204,13 +2203,30 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
|||||||
if (context.layout->labeltype != LABEL_MANUAL) {
|
if (context.layout->labeltype != LABEL_MANUAL) {
|
||||||
// LyX does not support \item[\mybullet]
|
// LyX does not support \item[\mybullet]
|
||||||
// in itemize environments
|
// in itemize environments
|
||||||
handle_ert(os, "[", context);
|
Parser p2(s + ']');
|
||||||
os << s;
|
os << parse_text_snippet(p2,
|
||||||
handle_ert(os, "]", context);
|
FLAG_BRACK_LAST, outer, context);
|
||||||
} else if (!s.empty()) {
|
} 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
|
// The space is needed to separate the
|
||||||
// item from the rest of the sentence.
|
// item from the rest of the sentence.
|
||||||
os << s << ' ';
|
os << ' ';
|
||||||
eat_whitespace(p, os, context, false);
|
eat_whitespace(p, os, context, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user