RE: Embedded displays in <para>s in DocBook

Subject: RE: Embedded displays in <para>s in DocBook
From: Avi Kivity <Avi@xxxxxxxxxxxxx>
Date: Fri, 19 Feb 1999 17:56:39 +0200
On Friday, February 19, 1999 13:54, Andrey Taranov
[SMTP:andrey@xxxxxxxxxxxxx] wrote:
> Hello Dssslist,
> 
>   What do you think of the following problem:
> 
>   I use a customized version of Norman's stylesheet to process
>   DocBook
>   texts. The standard paragraph style in my company is justified
>   text
>   with indented first line. Now consider some displayed element
>   embedded in para text (e.g. <literallayout>):
> 
>   <para>Some text ...
>       <literallayout>example text</>
>     continuation of the preceding text.</para>
> 
>   The result of this construct is that we get an extra space at the
>   beginning of continuation paragraph in RTF output. This is
>   definitely not desired.
> 
>   One solution would be to glue the first word of continuation text
>   to
>   the close tag of the displayed element. This solves the problem
>   ok,
>   but does not satisfy me, because I just cannot make all the
>   typers
>   in the company follow this convention. Two alternatives remain:
> 
>   1) process the situation as it is by the stylesheet somehow; or

I'm not familiar with docbook, but there is probably a (process-children)
buried inside para processing.
You could replace it with the following untested code:

(element para
    ;unrelated magic
    (process-node-list (trim-some-nodes-around-some-other-nodes whitespace?
displayed-element? (children (current-node))))
    ;more processing
)

(define (displayed-element? nd)
    (match-element? 'literallayout nd)
)

(define (whitespace? nd) ???) 

(define (trim-some-nodes-around-some-other-nodes trim? around? nl)
    (node-list-reverse 
        (trim-nodes-after trim? around?
            (node-list-reverse
                 (trim-nodes-after trim? around? nl)
            )
        )
    )
)

(define (trim-nodes-after trim? after? nl)
    (node-list-reduce
        nl
        (lambda (nl candidate) 
            (if 
                (and 
                      (after? (node-list-last nl))
                      (trim? candidate)
                ) 
                nl ;trimmed away
                (node-list nl candidate)
             )
        )
        (node-list)
    )
)

>   2) split the <para> element in two -- preceding the display and
>   following the display -- and use some role=cont attribute on the
>   continuation paragraph to tell the stylesheet to suppress the
>   indentation of the first line.
> 
>   The question is: which way to choose? Both require some support
>   from
>   the stylesheet, but I cannot think of a way to implement the 1)
>   way.
>   On the other hand I can implement things like way 2) quite easily.
>   
> 
>   Which way is THE-RIGHT-THING, anyhow?
> 
I don't like placing unnecessary constraints on authors (knowing they will
be violated), so I try to do as much as possible in the style sheet.
Modifying DTDs is even worse -- DTD == compatibility.

All in all, this is an icky solution to an icky problem. Seems a lot of work
just to get rid of a little space.

-Avi
---
.sig temporarily out of order. we apologize for any inconvenience.



 DSSSList info and archive:  http://www.mulberrytech.com/dsssl/dssslist


Current Thread