finish tex2lyx depth support (hopefully); more things in .cvsignore

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7515 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2003-08-06 22:47:22 +00:00
parent e82268dd92
commit 3a4b075285
9 changed files with 155 additions and 27 deletions

View 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

View 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

View 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

View 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.

View 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

View 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;
}
}

View 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

View 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}

View 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 ");