]> git.lyx.org Git - features.git/commitdiff
- text.cpp: full tex2lyx support for lstlisting (support for \lstinline will follow...
authorUwe Stöhr <uwestoehr@web.de>
Mon, 5 Mar 2012 01:45:14 +0000 (01:45 +0000)
committerUwe Stöhr <uwestoehr@web.de>
Mon, 5 Mar 2012 01:45:14 +0000 (01:45 +0000)
- test/test-insets.tex: add a more advanced examples

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40856 a592a061-630c-0410-9148-cb99ea01b6c8

src/tex2lyx/test/test-insets.tex
src/tex2lyx/text.cpp

index b221476dd806dcfd7914fb9e631f21e757d9e976..9d9be0dbfbef62777fa9beefda8c9b8ce4162083 100644 (file)
@@ -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!
 
 
index d6392db3a2ce2c7d0bbb0b28c68451402c63b8b6..d0956c36a8d1db6fb82e74bfb6f864a871ef2d13 100644 (file)
@@ -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();
        }