Jean-Marc Lasgouttes wrote:
Dov Feldstern <dfeldstern-rhxOsnTko2JWk0Htik3J/[EMAIL PROTECTED]> writes:
The trivial way to do this is just to say: well, whichever range
starts first I consider to be the outer range; and when I reach it's
end, I must also close all inner ranges, as well. If some of those
inner ranges are still open, then I will open them again after closing
the outer range, and now they are outside, so everything is OK.
To complement the naive approach, you should also consider the end of
the spans. The span that is larger is the outer one.
Yes, this would work for the non-overlapping case. But it requires
global information regarding the spans extent (which may or may not be
trivial to obtain, depending on the implementation). I think my proposed
algorithm would work as well, with only local information (the
attributes of the current position and it's nearest neighbors), and
would also work for the overlapping case (which I agree with you, is
quite rare and pathological, but I'd rather not disallow it if possible).
This is an approach I have proposed in the past. It was dismissed of
course by inset guys because it was not fun ;) More seriously, the
only big disadvantage I see is a lack of predictability.
But I think that it would "just work".
Regarding (2), the only example that I can think of is Bidi text, if
language is treated as a character attribute (which it currently is,
and rightly so, IMO). In this case, it matters very much whether I
render:
The order also matters when mixing for example bold and italics,
because there can be an italic correction
See bugs:
http://bugzilla.lyx.org/show_bug.cgi?id=3382
http://bugzilla.lyx.org/show_bug.cgi?id=4013
Yes, I see. I could say "well, then Large should have higher
precedence", but I guess that's not generally true...?
But the only way around this as far as I can see is really to take the
global information (range extent) into consideration.
The truth is, if this information is available, then I would just
incorporate it into the precedence tables I suggest: so you'd have
dynamic precedence tables, which are ordered first by range extent, and
only when that's not enough (same range / overlapping ranges), also by a
static precedence table.
We define an "attribute precedence" order. Then, we use the following
rules (to be applied when moving from the GUI to non-overlapping
markup) to make sure that at any given position, the
highest-precedence active range is also the outermost one:
I think we should use some algorithm that discovers nesting from
ranges. It cannot be so difficult. The only problem is when ranges
have exactly the same begin and end ranges, in which case some
precedence helps.
As far as overlapping (not nested) ranges are concerned, there is no
good solution (and they are quite rare and weird) so any solution that
produces valid LaTeX is OK.
JMarc
Dov