Hi!
Sorry for the late reply. I didn't mention that I was not subscribed to the
list. Can you add me to the list?
> | Hi!
> |
> | If I export a document of type SGML (LinuxDoc article) as LinuxDoc an
> | additional <em> tag is inserted after each </em> tag. The same
> | happens
>
> Is this cvs lyx? Or a released version?
This is a release 1.1.4fix1.
I had a look at the source (buffer.C) which says:
/* push a tag in a style stack */
void Buffer::push_tag(ostream & os, char const * tag,
int & pos, char stack[5][3])
{
/* pop all previous tags */
for (int j = pos; j >= 0; --j)
os << "</" << stack[j] << ">";
/* add new tag */
sprintf(stack[++pos], "%s", tag);
/* push all tags */
for (int i = 0; i <= pos; ++i)
os << "<" << stack[i] << ">";
}
This is quite clear. All tags of the old stack are closed,
the new tag is pushed on top of the stack and all tags
on the new stack are opened.
(But why close and open all tags? Wouldn't it suffice to
just open the new tag:
{ sprintf(stack[++pos], "%s", tag); os << "<" << tag << ">"; }
Ok. Now let's have a look at the pop_tag() method:
// pop a tag from a style stack
void Buffer::pop_tag(ostream & os, char const * tag,
int & pos, char stack[5][3])
{
// pop all tags till specified one
for (int j = pos; (j >= 0) && (strcmp(stack[j], tag)); --j)
os << "</" << stack[j] << ">";
// closes the tag
os << "</" << tag << ">";
// push all tags, but the specified one
for (int i = 0; i <= pos; ++i) {
os << "<" << stack[i] << ">";
strcpy(stack[i - 1], stack[i]);
}
--pos;
}
I don't know why there's the additional condition strcmp(stack[j], tag)?
When I ran lyx "tag" was always the same as stack[pos].
Therefore lyx prints nothing in the first for-loop.
Then it prints the (only) closing tag.
In the second for loop all tags (including the specified one!) are printed.
The strcpy() copies to stack[-1] (if i==0!!!) and does not pop a tag
off the stack but removes the bottom tag!!! This is no stack behaviour!
Therefore the output of later calls to pop_tag () is incorrect if pos was
greater than 0.
I changed this to
{
// pop all tags
for (int j = pos; j >= 0; --j)
os << "</" << stack[j] << ">";
// remove old tag
--pos;
// push all tags
for (int i = 0; i <= pos; ++i)
os << "<" << stack[i] << ">";
}
This is the exact inverse of the push_tag() method.
IMHO it would suffice to write:
{ --pos; os << "</" << tag << ">"; }
I wrote a small test case for this problem (lyx file format):
Some
\emph on
emphasized
\emph default
and
\family typewriter
typewriter
\family default
text.
Some cascading text:
\emph on
emphasized
\family typewriter
typewriter
\series bold
bold
\series default
typewriter
\family default
emphasized
\emph default
.
With the old pop_tag() method I got:
Some <em>emphasized</em><em> and <tt>typewriter</tt><tt> text.
Some cascading text: <em>emphasized </em><em><tt>typewriter </tt></em>
<em><tt><bf>bold</bf><em><tt><bf> typewriter</bf></tt><tt><bf>
emphasized</bf></em><bf>.
With my version it produces the correct output:
Some <em>emphasized</em> and <tt>typewriter</tt> text.
Some cascading text: <em>emphasized </em><em><tt>typewriter </tt></em>
<em><tt><bf>bold</bf></tt></em><em><tt> typewriter</tt></em><em> emphasized</em>.
Bye,
Guenter
--
Guenter Grossberger
Email: [EMAIL PROTECTED]