Re: breakup (was: Issues with literate programming DSSSL Script)

Subject: Re: breakup (was: Issues with literate programming DSSSL Script)
From: Brandon Ibach <bibach@xxxxxxxxxxxxxx>
Date: Mon, 27 Dec 1999 18:43:13 -0600
Quoting Simon Pepping <spepping@xxxxxxxxxxxxxxxx>:
> The TeX backend does accept it since it has a function
> formattingInstruction, which outputs the argument. Strangely enough,
> it does not declare it as one of its extensions in makeTeXFOTBuilder,
> so it seems built-in. It is the style engine that refuses the FO
> unless one declares it as an extension.
   Hmm... guess that falls under the "undocumented feature" category. :)

> The SGML backend I have (openjade, 1.4devel, early october) does not
> have such a function, and indeed the string does not appear at all.
   That would have to fall under the "bug" category.  Wonder how that
happened?  This all works under release versions, anyway.

> >    As I mentioned to Mark, I have a simple, but complete, example of
> > this stuff in action, which I can pass along, if you're interested.
> Yes, that would be interesting.
   Attached. :)

-Brandon :)
<!doctype src [
<!element src      o o (scrap)+>
<!element scrap    - - (title?,(#pcdata|scrapref)+)>
<!attlist scrap    id  ID     #required>
<!element title    - - (#pcdata)+>
<!element scrapref - o EMPTY>
<!attlist scrapref id  IDREF  #required>
<!entity lt "&#60;"> <!entity gt "&#62;">
<scrap id="scrap3">increment</scrap>

<scrap id="scrap2">
<scrapref id="scrap3">(a) if z &gt; a

<scrap id="scrap1"><title>Outside Loop</title>
While (a &lt; max_a)
	<scrapref id="scrap2">
<!doctype style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN">


(declare-flow-object-class formatting-instruction
  "UNREGISTERED::James Clark//Flow Object Class::formatting-instruction")

(define breakup (lambda (#!optional (nl (children (current-node))))
  (let loop ((n nl) (s "") (r '()))
    (if (node-list-empty? n) 
        (if (< 0 (string-length s)) (append r (list s)) r)
        (let* ((cn (node-list-first n)) (c (node-property 'class-name cn)))
          (loop (node-list-rest n)
                (if (not (equal? 'data-char c)) ""
                    (string-append s (string (node-property 'char cn))))
                (if (equal? 'data-char c) r
                    (append r (if (< 0 (string-length s)) (list s) '())
                            (list cn)))))))))

(define scrapout (lambda (#!optional (n (current-node)))
  (let loop ((c (breakup (children n))) (r (empty-sosofo)))
    (if (null? c) r (loop (cdr c) (sosofo-append r
          (if (node-list? (car c)) (process-node-list (car c))
              (make formatting-instruction data: (car c)))))))))

(element scrap (sosofo-append (scrapout)
  (make formatting-instruction data: "\U-000D\U-000A")))

(element scrapref
  (scrapout (element-with-id (attribute-string "id"))))

(element title (empty-sosofo))

Current Thread