scriblib/footnote: fix for non-Latex output
Also, fix warnings generated even for Latex mode. original commit: 45f74eafe59df40ac7682e37aecce3b46ac05f06
This commit is contained in:
parent
58fab5c3a6
commit
6b54708a39
|
@ -1,4 +1,4 @@
|
||||||
#lang scheme
|
#lang racket/base
|
||||||
(require scribble/core
|
(require scribble/core
|
||||||
scribble/decode)
|
scribble/decode)
|
||||||
|
|
||||||
|
@ -14,6 +14,11 @@
|
||||||
#:ref-wrap [ref-wrap (lambda (c s) c)])
|
#:ref-wrap [ref-wrap (lambda (c s) c)])
|
||||||
(make-counter 0 name target-wrap ref-wrap))
|
(make-counter 0 name target-wrap ref-wrap))
|
||||||
|
|
||||||
|
(define (tag->counter-tag counter tag . kind)
|
||||||
|
(if (generated-tag? tag)
|
||||||
|
`(,(string->symbol (format "counter-~a" kind)) ,tag)
|
||||||
|
`(counter (,(counter-name counter) ,tag ,@kind))))
|
||||||
|
|
||||||
(define (counter-target counter tag label
|
(define (counter-target counter tag label
|
||||||
#:continue? [continue? #f]
|
#:continue? [continue? #f]
|
||||||
. content)
|
. content)
|
||||||
|
@ -27,7 +32,7 @@
|
||||||
(list
|
(list
|
||||||
(make-delayed-element
|
(make-delayed-element
|
||||||
(lambda (renderer part ri)
|
(lambda (renderer part ri)
|
||||||
(let ([n (resolve-get part ri `(counter (,(counter-name counter) ,tag "value")))])
|
(let ([n (resolve-get part ri (tag->counter-tag counter tag "value"))])
|
||||||
(let ([l (cons (format "~a" n) content)])
|
(let ([l (cons (format "~a" n) content)])
|
||||||
(if label
|
(if label
|
||||||
(list* label 'nbsp l)
|
(list* label 'nbsp l)
|
||||||
|
@ -43,16 +48,17 @@
|
||||||
(counter-n counter)
|
(counter-n counter)
|
||||||
(add1 (counter-n counter)))])
|
(add1 (counter-n counter)))])
|
||||||
(set-counter-n! counter n)
|
(set-counter-n! counter n)
|
||||||
(collect-put! ci `(counter (,(counter-name counter) ,tag "value")) n)))))
|
(collect-put! ci (generate-tag (tag->counter-tag counter tag "value") ci) n)))))
|
||||||
`(counter (,(counter-name counter) ,tag))))
|
(tag->counter-tag counter tag)))
|
||||||
(if (counter-target-wrap counter)
|
(if (counter-target-wrap counter)
|
||||||
((counter-target-wrap counter)
|
((counter-target-wrap counter)
|
||||||
c
|
c
|
||||||
(format "t:~a" (t-encode (list 'counter (list (counter-name counter) tag)))))
|
(format "t:~a" (t-encode (tag->counter-tag counter tag))))
|
||||||
c)))
|
c)))
|
||||||
|
|
||||||
(define (t-encode s)
|
(define (t-encode s)
|
||||||
(string-append*
|
(apply
|
||||||
|
string-append
|
||||||
(map (lambda (c)
|
(map (lambda (c)
|
||||||
(cond
|
(cond
|
||||||
[(and (or (char-alphabetic? c) (char-numeric? c))
|
[(and (or (char-alphabetic? c) (char-numeric? c))
|
||||||
|
@ -65,7 +71,7 @@
|
||||||
(define (counter-ref counter tag label)
|
(define (counter-ref counter tag label)
|
||||||
(let ([n (make-delayed-element
|
(let ([n (make-delayed-element
|
||||||
(lambda (renderer part ri)
|
(lambda (renderer part ri)
|
||||||
(let ([n (resolve-get part ri `(counter (,(counter-name counter) ,tag "value")))])
|
(let ([n (resolve-get part ri (tag->counter-tag counter tag "value"))])
|
||||||
(if (counter-ref-wrap counter)
|
(if (counter-ref-wrap counter)
|
||||||
(let ([id (format "t:~a" (t-encode (list 'counter (list (counter-name counter) tag))))])
|
(let ([id (format "t:~a" (t-encode (list 'counter (list (counter-name counter) tag))))])
|
||||||
((counter-ref-wrap counter)
|
((counter-ref-wrap counter)
|
||||||
|
@ -86,7 +92,7 @@
|
||||||
'nbsp
|
'nbsp
|
||||||
n)
|
n)
|
||||||
n)
|
n)
|
||||||
`(counter (,(counter-name counter) ,tag)))))
|
(tag->counter-tag counter tag))))
|
||||||
|
|
||||||
(define (counter-collect-value counter)
|
(define (counter-collect-value counter)
|
||||||
(counter-n counter))
|
(counter-n counter))
|
||||||
|
|
12
collects/tests/scribble/docs/footnote.scrbl
Normal file
12
collects/tests/scribble/docs/footnote.scrbl
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#lang scribble/base
|
||||||
|
@(require scriblib/footnote)
|
||||||
|
|
||||||
|
@(define-footnote footnote generate-footnotes)
|
||||||
|
|
||||||
|
@title{Document}
|
||||||
|
|
||||||
|
Left.@footnote{A}
|
||||||
|
|
||||||
|
Right.@footnote{A♯}
|
||||||
|
|
||||||
|
@generate-footnotes[]
|
9
collects/tests/scribble/docs/footnote.txt
Normal file
9
collects/tests/scribble/docs/footnote.txt
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
Document
|
||||||
|
|
||||||
|
Left.1A
|
||||||
|
|
||||||
|
Right.2A♯
|
||||||
|
|
||||||
|
1A
|
||||||
|
|
||||||
|
2A♯
|
Loading…
Reference in New Issue
Block a user