groff
[Top][All Lists]
Advanced

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

Re: [Groff] grohtml patch


From: Werner LEMBERG
Subject: Re: [Groff] grohtml patch
Date: Thu, 10 Jul 2003 15:31:59 +0200 (CEST)

> I'm attempting to implement the new tag mechanism that you outlined
> back in April.  I've implemented the state machine and can issue
> `diff' tags.

What exactly do you mean with `diff' tags?

> The problem I'm currently struggling with is how to coordinate the
> updating of the state machine relative to the node generation and
> final tbuf printing.
>
> Currently I'm flushing state machine diffs when the tbuf goes from
> an empty state into a non empty state. But this is wrong.
>
> I'm now considering creating a copy of the troff state machine (my
> new class based on the list of troff attributes in your email)
> during env::add_char and adding this copy to a node. Later when this
> node appears during tprint I am going to diff the nodes state with
> the driver state and generate the html tags.
>
> Can you see anything immediately wrong with this approach?  I'm
> hoping that it will fix the synchronisation issue..

Here my idea of implementation:

  . We need one troff_state structure and a stack of html_state
    structures.

    Most of the data for the troff state can be directly taken from
    the `environment' class (or rather, it holds only the stuff not in
    the `environment' class).

  . We need two new node types, html_state_push and html_state_pop
    which both must be transparent to end-of-sentence recognition and
    similar things.

  . Set a flag diversion::diversion_start in the code for `.di xxx' to
    indicate that a diversion has just begun.

    Add an html_state_push node at the very beginning of the diversion
    to make troff push the html state during rereading.

  . In env::add_char, test diversion_start of curdiv.  If set, emit
    the complete troff state as a series of

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

    (or a new special tag which is equivalent to it) right before
    adding a glyph node.  Then reset the flag.

    The \! stuff can be directly inserted using a non_interpreted_node
    structure.

  . In the code for `.di', add an html_state_pop node at the very end
    of the diversion to make troff pop the html state during
    rereading.

I think you don't need a new node type to hold the troff state since
its data has been already output as \!'...' stuff.  Since pushing
and popping the html state is indicated by nodes, implementing a
proper tprint function for html_state_pop should be sufficient.


    Werner

reply via email to

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