1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
(define (p-manpage->xxx xxx id)
(let* ((author "an unknown author") ; to be overridden.
(end '#(ENDTAG DIVISION))
(exc (lambda (t)
(set! author (xatv t 'AUTHOR)) ; extract for later use
`#(STARTTAG
,xxx
(,@(if id (list id) '())
#(LANG TOKEN ("EN")) . ,(token-args t)))))
(end-doc `#(ENDTAG ,xxx))
(ren (lambda (t)
`#(STARTTAG
DIVISION
(#(ID IMPLIED #f)
#(LANG TOKEN ("EN")) . ,(token-args t)))))
(s-division '#(STARTTAG
DIVISION
(#(ID IMPLIED #f) #(LANG TOKEN ("EN")))))
(s-hd '#(STARTTAG HEADING ()))
(e-hd '#(ENDTAG HEADING))
(sect (lambda (name what . stuff)
`(#(STARTTAG ,name)
,(rdp-repll
`(,ren ,end)
(apply rdp-insert `(,s-hd ,@stuff ,e-hd))
what))))
)
(let
((gram
(rdp-cond
`((#(STARTTAG MANPAGE)
,(rdp-repll
`(,exc ,end-doc)
(letrec
((call (rdp-call stuff))
(stuff (rdp-cond*
`((#(STARTTAG SECT1)
,(rdp-repll `(,ren ,end) call))
(#(STARTTAG) ,(rdpp-keep call))
(#(ENDTAG) ,rdp-leave)
(#() ,(lambda (c h s)
(cons-stream
(head s)
(rdp-reduce c h (tail s))))))))
(gram
(rdp-cond*
`(
; if we compile into a manpage doctype,
; don't touch the heading
(#(STARTTAG TITLE)
,(if (eq? xxx 'MANPAGE)
(rdpp-keep call)
(rdp-repll '(#(STARTTAG HEADING ())) call)))
(#(STARTTAG SHORT)
,(if (eq? xxx 'MANPAGE)
(rdpp-keep call)
(rdp-repll `(#(DATA " -- ")
#(ENDTAG HEADING)) call)))
,(sect 'SYNOPSIS call '#(DATA "SYNOPSIS"))
,(sect 'CONFIG call '#(DATA "CONFIGURATION"))
,(sect 'DESCRIPT call '#(DATA "DESCRIPTION"))
,(sect 'OPTIONS call '#(DATA "OPTIONS"))
,(sect 'RETURN call '#(DATA "RETURN CODE"))
,(sect 'ERRORS call '#(DATA "ERRORS"))
,(sect 'EXAMPLES call '#(DATA "EXAMPLES"))
,(sect 'ENV call '#(DATA "ENVIRONMENT"))
,(sect 'FILES call '#(DATA "FILES"))
,(sect 'CONFORM call '#(DATA "CONFORMING TO"))
,(sect 'NOTES call '#(DATA "NOTES"))
,(sect 'DIAG call '#(DATA "DIAGNOSTICS"))
,(sect 'RESTRICT call '#(DATA "RESTRICTIONS"))
,(sect 'HISTORY call '#(DATA "HISTORY"))
(#(STARTTAG SEE)
,(rdp-call ; delay to eval "author"
(rdp-insert s-division
'#(STARTTAG HEADING ())
'#(DATA "AUTHOR")
'#(ENDTAG HEADING)
'#(DATA "This was written by ")
`#(DATA ,author)
'#(DATA ".")
'#(ENDTAG DIVISION)))
,(rdp-repll
`(,ren ,end)
(rdp-insert s-hd '#(DATA "SEE ALSO") e-hd)
call))
(#(STARTTAG SECT)
,(rdp-repll `(,ren ,end) call))
(#(ENDTAG MANPAGE))
(#() ,(lambda (c h s)
(message 0 "Don't know what " (head s)
" should be.")))
))))
gram)))))))
gram)))
|