groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Groff] Re: grohtml and diversions


From: Werner LEMBERG
Subject: [Groff] Re: grohtml and diversions
Date: Fri, 11 Apr 2003 23:49:32 +0200 (CEST)

> I've been drinking plenty of black coffee and thinking hard about
> these issues..  I wonder whether a different tack might be taken.
> What about defining a new class, say `tag' which can be chained to
> other tags and the head of this tag list can be stored on a glyph
> node, or on diversion node.

I think it is better to maintain two `state tables' instead: One which
covers the troff state (e.g. line length, indentation, etc. --
approximately a small subset of the `environment' class) and another
which covers the html state, i.e., the html tags emitted in the troff
intermediate output to guide post-grohtml.  With your approach, e.g.

  .ll 5i
  .ll 3i
  .ll 2i
  a

produces three tags attached to `a' which is not efficient (if you
want to avoid that you have to maintain a state table even with your
approach...).

> When one of
>
> >   .br
> >   .ce
> >   .fi
> >   .fl
> >   .in
> >   .ll
> >   .nf
> >   .po
> >   .ps
> >   .rj
> >   .sp
> >   .ta
> >   .ti
>
> is seen a tag is created and appended to the current list of
> outstanding tags.  When a glyph is created then the current list of
> outstanding tags is placed into the glyph.  As tags are placed onto
> glyphs they cannot have any white space surrounding them.  A tag may
> be created in a complete state (the value is known) or an incomplete
> state in which case the value must be discover just before they are
> written to post-grohtml.

Hmm, I think this won't work.  As far as I can see, there is no
`incomplete state' within troff.

> In your first example we have:
>
>   .di xxx
>   .ll 5i     <tag .ll 5i complete> and put on outstanding list
>   a          outstanding list is placed onto glyph a's list.
>              outstanding list is reset.

My approach: As soon as the first glyph is emitted to the diversion
(`a' in the example), output the *complete troff state* (this is
something new which I haven't suggested in the previous mail).  This
is, we have a series of

  \!\X'html-tag: .ll ...'
  \!\X'html-tag: .in ...'

(the \! is used because we are in a diversion).  Perhaps we shall add
a special single tag to do that efficiently.

Partial emission won't work (this I have found out today).  Consider
this:

  .ll 5i
  foo
  .di xxx
  a
  .di
  .ll 3i
  x\*[xxx]

While emitting `xxx' we have to know that the line length was 5i
as `xxx' has been defined.

>   .br        <tag .br complete> and added to outstanding list

My approach: Emit \!\X'html-tag: .br'.

>   .ll        <tag .ll incomplete> and appended to outstanding list

Nothing with my approach.  This `.ll' does *not* belong to the
diversion at all!  It only changes the troff state, thus it shouldn't
be recorded in the diversion.

>   .di        outstanding list placed onto diversion, xxx, tag list.
>              outstanding list is reset.

Nothing with my approach.

>   x\*[xxx]   glyph x is emitted and the diversion xxx is processed.

My approach: Before emitting glyph `x' check whether the troff state
has changed and emit tags if necessary.  Before emitting `xxx' save
the html state on a stack.

>              <tag .ll 5i is emitted> (was found on `a' list)

My approach does nothing special here; now the \!\X'...' stuff already
part of the diversion simply gets expanded.

>              glyph a is emitted

Again, with my approach the troff state has to be checked and tags
emitted if necessary.

>              now the tags found on diversion xxx are emitted
>              <tag .br> emitted

Nothing special with my approach.

>              <tag .ll incompete> is discovered, therefore evaluate
>                                  this and emit tag.

This is wrong IMHO as explained above.

After ending the diversion, the html state must be restored (emitting
tags if necessary) and popped off the stack.


    Werner

reply via email to

[Prev in Thread] Current Thread [Next in Thread]