commit ec84cbfb445413e51472845c3c1a2b5da930492f
Author: Uwe Stöhr <[email protected]>
Date: Tue Nov 11 01:20:03 2014 +0100
tex2lyx: support for \item with opt arg in itemize environment
diff --git a/src/tex2lyx/TODO.txt b/src/tex2lyx/TODO.txt
index 1de2a31..974dcce 100644
--- a/src/tex2lyx/TODO.txt
+++ b/src/tex2lyx/TODO.txt
@@ -62,7 +62,6 @@ Format LaTeX feature LyX feature
446 Optional and required arguments InsetArgument
now numbered by order
448
-449 \item[<arg>] \begin_inset Argument item:<nr>
450 ugm LaTeX font, \font_roman, \font_osf,
451 beamer overlay arguments InsetArgument
\command<arg>, \begin{env}<arg>
diff --git a/src/tex2lyx/test/test-structure.lyx.lyx
b/src/tex2lyx/test/test-structure.lyx.lyx
index e8e1b8a..6a52a84 100644
--- a/src/tex2lyx/test/test-structure.lyx.lyx
+++ b/src/tex2lyx/test/test-structure.lyx.lyx
@@ -877,7 +877,17 @@ the second item
\end_layout
\begin_layout Itemize
-the third item
+
+\begin_inset Argument item:1
+status open
+
+\begin_layout Plain Layout
+custom label
+\end_layout
+
+\end_inset
+
+the third item has a custom label
\end_layout
\begin_deeper
diff --git a/src/tex2lyx/test/test-structure.tex
b/src/tex2lyx/test/test-structure.tex
index 745872b..824994e 100644
--- a/src/tex2lyx/test/test-structure.tex
+++ b/src/tex2lyx/test/test-structure.tex
@@ -285,7 +285,7 @@ and a second paragraph for good measure
\item the second item
-\item the third item
+\item[custom label] the third item has a custom label
\subsubsection*{and a sssection heading inside it (why not?)}
\end{itemize}
diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp
index 009b8b4..2c212a4 100644
--- a/src/tex2lyx/text.cpp
+++ b/src/tex2lyx/text.cpp
@@ -2628,11 +2628,18 @@ void parse_text(Parser & p, ostream & os, unsigned
flags, bool outer,
}
if (optarg) {
if (context.layout->labeltype != LABEL_MANUAL) {
- // LyX does not support \item[\mybullet]
- // in itemize environments
+ // 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()) {
// LyX adds braces around the argument,
// so we need to remove them here.
@@ -2648,8 +2655,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags,
bool outer,
} else {
Parser p2(s + ']');
os << parse_text_snippet(p2,
- FLAG_BRACK_LAST,
- outer, context);
+ FLAG_BRACK_LAST, outer,
context);
}
// The space is needed to separate the
// item from the rest of the sentence.