]> git.lyx.org Git - features.git/commitdiff
finish tex2lyx depth support (hopefully); more things in .cvsignore
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 6 Aug 2003 22:47:22 +0000 (22:47 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 6 Aug 2003 22:47:22 +0000 (22:47 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7515 a592a061-630c-0410-9148-cb99ea01b6c8

src/.cvsignore
src/ChangeLog
src/frontends/xforms/.cvsignore
src/frontends/xforms/ChangeLog
src/tex2lyx/ChangeLog
src/tex2lyx/context.C
src/tex2lyx/context.h
src/tex2lyx/test-structure.tex
src/tex2lyx/text.C

index e94535cc37a5047a34e4fcbda75a93a87bfac6ee..d5af05663a9c4d93c236aa3580b4e712f2140095 100644 (file)
@@ -1,11 +1,15 @@
 config.h
-version.C
+config.h.in
 lyx
+lyx-xforms
+lyx-qt
 Makefile
 Makefile.in
-config.h.in
 stamp-h
 stamp-h1
+version.C
+version.C-tmp
+stamp-version
 *.deps
 .libs
 a.out
index dfe0a1c8e5f22465b0979c6530b43a0741f369ab..b4fa9dd946c5b1487ec43b9e38f8a956ccd80f40 100644 (file)
@@ -1,3 +1,7 @@
+2003-08-06  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
+
+       * .cvsignore: add lyx-xforms, lyx-qt, version.C-tmp and stamp-version
+
 2003-08-05  Alfredo Braunstein  <abraunst@libero.it>
 
        * text2.C (DEPM): fix part of bug 1255 and 1256 
index 077d350df8579dd97f0925b8f5ada8927225f664..40eb1aabc228313d4ba9807b1b21a0d89a31ff52 100644 (file)
@@ -5,4 +5,8 @@ Makefile
 .libs
 libxforms.la
 lyx_forms.h
+lyx_forms.h-tmp
+stamp-forms
 lyx_xpm.h
+lyx_xpm.h-tmp
+stamp-xpm
index 45f7505b18b22de02755bd9aeef9151278b2119f..360264f2bc5866e9a0d3609d031a8d8e5876993e 100644 (file)
@@ -1,3 +1,8 @@
+2003-08-06  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
+
+       * .cvsignore: add lyx_forms.h-tmp, stamp-forms, lyx_xpm.h-tmp,
+       stamp-xpm. 
+
 2003-08-06  Martin Vermeer  <martin.vermeer@hut.di>
 
        * Color.C: Kayvan's std::setw micropatch.
index becf01bf19a5c3a53f6a24101b410c579d066e7f..c013fa708b38a8ca105e5897f5e66f78d837f4a1 100644 (file)
@@ -1,3 +1,16 @@
+2003-08-07  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
+
+       * text.C (parse_text): special handling for \item and \bibitem
+       macros
+
+       * context.C (begin_layout, end_layout, begin_deeper, end_deeper):
+       tiny helper functions
+       (check_layout): 
+       (check_end_deeper): add special handling for the case of a normal
+       paragraph inside a list-like environment.
+
+       * test-structure.tex: add more stuff there
+
 2003-08-05  Alfredo Braunstein  <abraunst@libero.it>
 
        * context.h: compile fix
index 7bb967d1113f5d8aeda62eab3a3564b48374178f..1558da7e282076cdac5f367c536047fc78afce5a 100644 (file)
@@ -9,11 +9,39 @@
 using std::ostream;
 using std::endl;
 
+namespace {
+
+void begin_layout(ostream & os, LyXLayout_ptr layout)
+{
+       os << "\n\\begin_layout " << layout->name() << "\n\n";
+}
+
+
+void end_layout(ostream & os)
+{
+       os << "\n\\end_layout\n";
+}
+
+
+void begin_deeper(ostream & os)
+{
+       os << "\n\\begin_deeper \n";
+}
+
+
+void end_deeper(ostream & os)
+{
+       os << "\n\\end_deeper \n";
+}
+       
+}
+
 Context::Context(bool need_layout_,
                 LyXTextClass const & textclass_,
                 LyXLayout_ptr layout_, LyXLayout_ptr parent_layout_)
        : need_layout(need_layout_),
          need_end_layout(false), need_end_deeper(false),
+         has_item(false), deeper_paragraph(false),
          textclass(textclass_),
          layout(layout_), parent_layout(parent_layout_)
 {
@@ -28,13 +56,38 @@ void Context::check_layout(ostream & os)
 {
        if (need_layout) {
                check_end_layout(os);
-               
-               os << "\n\\begin_layout " << layout->name() << "\n\n";
-               need_layout=false;
-               need_end_layout = true;
-               if (!extra_stuff.empty()) {
-                       os << extra_stuff;
-                       extra_stuff.erase();
+
+               // are we in a list-like environment?
+               if (layout->isEnvironment()
+                   && layout->latextype != LATEX_ENVIRONMENT) {
+                       if (has_item) {
+                               if (deeper_paragraph) {
+                                       end_deeper(os);
+                                       deeper_paragraph = false;
+                               }
+                               begin_layout(os, layout);
+                               has_item = false;
+                               need_layout=false;
+                               need_end_layout = true;
+                       } else {
+                               // a standard paragraph in an
+                               // enumeration. We have to recognize
+                               // that this may require a begin_deeper.
+                               if (!deeper_paragraph)
+                                       begin_deeper(os);
+                               begin_layout(os, textclass.defaultLayout());
+                               need_layout=false;
+                               need_end_layout = true;
+                               deeper_paragraph = true;
+                       }
+               } else {
+                       begin_layout(os, layout);
+                       need_layout=false;
+                       need_end_layout = true;
+                       if (!extra_stuff.empty()) {
+                               os << extra_stuff;
+                               extra_stuff.erase();
+                       }
                }
        }
 }
@@ -42,8 +95,8 @@ void Context::check_layout(ostream & os)
 
 void Context::check_end_layout(ostream & os) 
 {
-       if (need_end_layout) {
-               os << "\n\\end_layout\n";
+       if (need_end_layout) {          
+               end_layout(os);
                need_end_layout = false;
        }
 }
@@ -53,11 +106,10 @@ void Context::check_deeper(ostream & os)
 {
        if (parent_layout->isEnvironment()) {
                if (need_end_deeper) {
-                               // no need to have \end_deeper \begin_deeper
-// FIXME: This does not work because \par already calls check_end_layout
+                       // no need to have \end_deeper \begin_deeper
                        need_end_deeper = false;
                } else {
-                       os << "\n\\begin_deeper \n";
+                       begin_deeper(os);
                        need_end_deeper = true;
                }
        } else
@@ -68,9 +120,13 @@ void Context::check_deeper(ostream & os)
 void Context::check_end_deeper(ostream & os) 
 {
        if (need_end_deeper) {
-               os << "\n\\end_deeper \n";
+               end_deeper(os);
                need_end_deeper = false;
        }
+       if (deeper_paragraph) {
+               end_deeper(os);
+               deeper_paragraph = false;
+       }
 }
 
 
index f7fe9671c63552ed9a3dd0511b0eb9352dab49ea..663f0c135e5b90296b5ff55c11eda6d9c68a1b57 100644 (file)
@@ -37,7 +37,14 @@ struct Context {
        // If there has been an \begin_deeper, we'll need a matching
        // \end_deeper
        bool need_end_deeper;
-
+       // If we are in an itemize-like environment, we need an \item
+       // for each paragraph, otherwise this has to be a deeper
+       // paragraph.
+       bool has_item;
+       // we are handling a standard paragraph in an itemize-like
+       // environment
+       bool deeper_paragraph;
+       
        // The textclass of the document. Could actually be a global variable
        LyXTextClass const & textclass;
        // The layout of the current paragraph
index d48767b953e975bd1f257a5c06041b5c5c09eb58..3b834462da76ea73cfbec8e62720a6c34ac4731f 100644 (file)
@@ -1,18 +1,21 @@
 \documentclass{article}
 
+\newenvironment{foo}{==[}{]==}
+
 \begin{document}
 
 This document contains all sorts of layouts we are supposed to
 support, along with weird nestings.
 
+At time you will see that I use subsubsections in weird places. The
+intent is just to make sure that I can include a macro-type layout
+everyzhere it makes sense.
 
 A normal paragraph
-
-Another one 
 \begin{equation} 
 x = \sin y 
 \end{equation} 
-with maths inside
+with maths inside it.
 
 \begin{quote}
 An environment...
@@ -55,7 +58,7 @@ Some centered stuff (does not work)
 \begin{quotation}
 An environment
 
-\section*{with a command inside it}
+\subsubsection*{with a command inside it}
 \end{quotation}
 
 \begin{quotation}
@@ -85,4 +88,33 @@ We can also nest enumerations
 \item Item2
 \end{enumerate}
 
+Let's see what happens when normal paragraphs are inserted in lists:
+
+\begin{itemize}
+\item the first item
+
+with some explanatory text under it
+
+and a second paragraph for good measure
+
+\subsubsection*{we can even have one as a subsubsection}
+
+\item the second item
+
+\item the third item
+
+\subsubsection*{and a sssection heading inside it (why not?)}
+\end{itemize}
+
+What else? Well, we have descriptions:
+\begin{description}
+\item[A] first item
+\item[B] second one
+\end{description}
+
+or even bibliography
+\begin{thebibliography}{9}
+\bibitem{FOO} Edward Bar. \emph{The Foo Book}. (1999)
+\end{thebibliography}
+
 \end{document}
index 5c4b3fba6ccb7f10b1c832424b398feefd237805..f2cc658129591e36c78148f7eb26863d41e1bd6e 100644 (file)
@@ -440,11 +440,21 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                                s = parse_text(p, FLAG_BRACK_LAST, outer, newcontext);
                        }
                        context.need_layout = true;
+                       context.has_item = true;
                        context.check_layout(os);
                        if (s.size())
                                os << s << ' ';
                }
 
+               else if (t.cs() == "bibitem") {
+                       context.need_layout = true;
+                       context.has_item = true;
+                       context.check_layout(os);
+                       os << "\\bibitem ";
+                       os << p.getOpt();
+                       os << '{' << p.verbatim_item() << '}' << "\n";
+               }
+
                else if (t.cs() == "def") {
                        string name = p.get_token().cs();
                        while (p.next_token().cat() != catBegin)
@@ -589,13 +599,6 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                        os << "\n\\" << t.cs() << " default \n";
                }
 
-               else if (t.cs() == "bibitem") {
-                       context.check_layout(os);
-                       os << "\\bibitem ";
-                       os << p.getOpt();
-                       os << '{' << p.verbatim_item() << '}' << "\n";
-               }
-
                else if (is_known(t.cs(), known_latex_commands)) {
                        context.check_layout(os);
                        begin_inset(os, "LatexCommand ");