|
Subject: RE: Basic footnotes - my answer (or beauty is in the eye of the beholder? NW) From: "Pawson, David" <DPawson@xxxxxxxxxxx> Date: Thu, 7 May 1998 11:18:01 +0100 |
Introducing our middle managers and
admin people to SGML to permit
equal multi-media delivery, one clever so and so
wanted 'proper' notes.
After much help (Norman W and Chris M) from the list,
this is what I came out with.
Hope it might help others.
Cookbook Tony?
source file snippet
<p> blah blah blah <footnote> xxxxxxxxxxxx </footnote>
rest of paragraph </p>
The DTD tree has a fairly high element 'SECTION', at the end
of which I wanted to collect footnotes.
within the PCDATA at the bottom I want to be able to insert
<footnote> the actual text of the footnote </footnote>
whereas the display (in print) comes out as one would
expect.
this is the stylesheet bit
; within the main body
; This is the element where I want to add any notes at the end.
(element (section)
(sosofo-append (process-children)
(if (not (node-list-empty? (select-elements (descendants
(current-node)) "FOOTNOTE")))
(make rule
orientation: 'horizontal) ;; but only if there are
notes.
(literal ""))
(with-mode footnotes
(process-children))))
;; At each foot note, put in a number, superscript
(element footnote
($ss-seq$ + (literal (footnote-number (current-node)))))
; mode processing.
; 1 Bits 'stolen with glee' from Norman W ;-) How does he do that!
; Thanks Norm
;===================== footnote mode =====================
(define component-element-list
(list "SECTION" "SUBSECT1""SUBSECT2" "SUBSECT3"
"REPORT")) ;; just in case nothing else matches...
(define (component-child-number inputnd #!optional (complist
component-element-list))
;; REFENTRY
;; PURP Find child-number within a component
;; DESC
;; Finds the first ancestor of 'inputnd' in 'complist' and then counts
;; all the elements of type 'inputnd' from that point on and returns
;; the number of 'inputnd'. (This is like a 'recursive-child-number'
;; starting at the first parent of 'inputnd' in 'complist'.)
;; /DESC
;; /REFENTRY
(let ((nd (ancestor-member inputnd complist)))
(let loop ((nl (select-elements (descendants nd) (gi inputnd)))
(num 1))
(if (node-list-empty? nl)
0
(if (node-list=? (node-list-first nl) inputnd)
num
(if (string=? (gi (node-list-first nl)) (gi inputnd))
(loop (node-list-rest nl) (+ num 1))
(loop (node-list-rest nl) num)))))))
;;
======================================================================
(define ($ss-seq$ plus-or-minus #!optional (sosofo (process-children)))
(make sequence
font-size:
(* (inherited-font-size) 0.6)
position-point-shift:
(plus-or-minus (* (inherited-font-size) 0.4))
sosofo))
(define (ancestor-member nd gilist)
;; REFENTRY
;; PURP Returns the first ancestor in a list of GIs
;; DESC
;; Returns the first ancestor of 'nd' whose GI that is a member of
'gilist'.
;; /DESC
;; /REFENTRY
(if (node-list-empty? nd)
(empty-node-list)
(if (member (gi nd) gilist)
nd
(ancestor-member (parent nd) gilist))))
(define (footnote-number footnote)
(format-number (component-child-number footnote) "1"))
;; (element-children) returns the children of a node of class element.
;; Thanks to Chris Maden.
;; Not entirely sure how this works, but what it seems to do
;; is permit with-mode processing of the actual footnotes
;; without displaying all the other surrounding paragraphs!
(define (element-children #!optional (snl (current-node)))
(node-list-filter (lambda (node)
(equal? (node-property 'class-name
node)
'element))
(children snl)))
;2 Actual footnotes processing.
(mode footnotes
(default (process-node-list (element-children))) ;; Mmmmm. But it
works!!
(element (footnote)
(make paragraph
(make sequence
(literal "Note")
(literal (footnote-number (current-node)))
(literal " ")
(process-children))))
); End of with mode processing.
DSSSList info and archive: http://www.mulberrytech.com/dsssl/dssslist
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: sosofo-append or sequence?, Tony Graham | Thread | Re: Basic footnotes - my answer (o, Norman Walsh |
| RE: Architectural Forms, separation, Jordi Mulet | Date | Re: Graphic Size Problem, Alexander Taranov |
| Month |