diff --git a/src/tex2lyx/test/test-insets.tex b/src/tex2lyx/test/test-insets.tex index b221476dd8..9d9be0dbfb 100644 --- a/src/tex2lyx/test/test-insets.tex +++ b/src/tex2lyx/test/test-insets.tex @@ -108,7 +108,7 @@ From bug 7306: \citet{gur+04} have demonstrated that authors should not have umlauts in their names. It's OK to use them in the man\"{u}script, though. \begin{thebibliography}{References} -\bibitem[{{G\"{u}rkan et~al.}(2004)}]{gur+04} Gürkan, M.~A., Freitag, +\bibitem[{{G\"{u}rkan et~al.}(2004)}]{gur+04} Gürkan, M.~A., Freitag, M., \& Rasio, F.~A. 2004, ApJ, 604, 632\end{thebibliography} @@ -168,7 +168,6 @@ def func(param): pass \end{lstlisting} - Here is an example listing with left line numbering, step ``3'', language ``Python'', options ``Extended character table'' and ``Space~as~symbol'', range lines 3\,-\,8: @@ -178,7 +177,7 @@ def func(param): 'this is a python function' pass def func(param): -'This is a German word: Tschüß' +'This is a German word: Tschüß' pass def func(param): 'this is a python function' @@ -186,10 +185,10 @@ pass \end{lstlisting} Special cases: -\begin{lstlisting} -\begin{centering} +\begin{lstlisting}[abovecaptionskip=2em,basicstyle={\large\ttfamily},breaklines=true,extendedchars=true,firstline=2,float=h,language={[R/3 3.1]ABAP},lastline=5,numbers=left,numberstyle={\scriptsize},showspaces=true,showstringspaces=false,stepnumber=3,tabsize=4] hello \end{lstlisting} + \lstinline[language=TeX]!\begin{centering} hello! diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index d6392db3a2..d0956c36a8 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -1122,12 +1122,22 @@ void parse_listings(Parser & p, ostream & os, Context & parent_context) { parent_context.check_layout(os); begin_inset(os, "listings\n"); + if (p.hasOpt()) { + // there can be a [] pair inside the argument for the language + string arg = p.getArg('[', ']'); + if (arg.find("language={[") != string::npos) { + char start = p.next_token().character(); + arg += ']'; + arg += start; + arg += p.getArg(start, ']'); + } + os << "lstparams " << '"' << arg << '"' << '\n'; + } os << "inline false\n" << "status collapsed\n"; Context context(true, parent_context.textclass); context.layout = &parent_context.textclass.plainLayout(); - context.check_layout(os); - string const s = p.verbatimEnvironment("lstlisting"); + string const s = p.plainEnvironment("lstlisting"); for (string::const_iterator it = s.begin(), et = s.end(); it != et; ++it) { if (*it == '\\') os << "\n\\backslash\n"; @@ -1390,11 +1400,7 @@ void parse_environment(Parser & p, ostream & os, bool outer, // FIXME handle listings with parameters // If this is added, don't forgot to handle the // automatic color package loading - if (p.hasOpt()) - parse_unknown_environment(p, name, os, FLAG_END, - outer, parent_context); - else - parse_listings(p, os, parent_context); + parse_listings(p, os, parent_context); p.skip_spaces(); }