Skip to content
181 changes: 83 additions & 98 deletions scribble-lib/scribble/base.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,22 @@
#:rest (listof pre-content?)
part-start?))

(provide/contract
[title (->* ()
(#:tag (or/c #f string? (listof string?))
#:tag-prefix (or/c #f string? module-path? hash?)
#:style (or/c style? string? symbol? (listof symbol?) #f)
#:version (or/c string? #f)
#:date (or/c string? #f)
#:index-extras desc-extras/c)
#:rest (listof pre-content?)
title-decl?)]
[section (title-like-contract)]
[subsection (title-like-contract)]
[subsubsection (title-like-contract)]
[subsubsub*section (->* ()
(#:tag (or/c #f string? (listof string?)))
#:rest (listof pre-content?)
block?)])
(provide (contract-out
[title
(->* ()
(#:tag (or/c #f string? (listof string?))
#:tag-prefix (or/c #f string? module-path? hash?)
#:style (or/c style? string? symbol? (listof symbol?) #f)
#:version (or/c string? #f)
#:date (or/c string? #f)
#:index-extras desc-extras/c)
#:rest (listof pre-content?)
title-decl?)]
[section (title-like-contract)]
[subsection (title-like-contract)]
[subsubsection (title-like-contract)]
[subsubsub*section
(->* () (#:tag (or/c #f string? (listof string?))) #:rest (listof pre-content?) block?)]))
(provide include-section)

(define (title #:tag [tag #f] #:tag-prefix [prefix #f] #:style [style plain]
Expand Down Expand Up @@ -131,9 +130,8 @@

;; ----------------------------------------

(provide/contract
[author (->* (content?) () #:rest (listof content?) block?)]
[author+email (->* (content? string?) (#:obfuscate? any/c) element?)])
(provide (contract-out [author (->* (content?) () #:rest (listof content?) block?)]
[author+email (->* (content? string?) (#:obfuscate? any/c) element?)]))

(define (author . auths)
(make-paragraph
Expand All @@ -142,10 +140,9 @@
(case (length auths)
[(1) auths]
[(2) (list (car auths) nl "and " (cadr auths))]
[else (let ([r (reverse auths)])
(append (add-between (reverse (cdr r))
(make-element #f (list "," nl)))
(list "," nl "and " (car r))))]))))
[else (define r (reverse auths))
(append (add-between (reverse (cdr r)) (make-element #f (list "," nl)))
(list "," nl "and " (car r)))]))))

(define (author+email name email #:obfuscate? [obfuscate? #f])
(make-element #f
Expand Down Expand Up @@ -173,17 +170,11 @@

(provide items/c)

(provide/contract
[itemlist (->* ()
(#:style (or/c style? string? symbol? #f))
#:rest (listof items/c)
itemization?)]
[item (->* ()
()
#:rest (listof pre-flow?)
item?)])
(provide/contract
[item? (any/c . -> . boolean?)])
(provide (contract-out
[itemlist
(->* () (#:style (or/c style? string? symbol? #f)) #:rest (listof items/c) itemization?)]
[item (->* () () #:rest (listof pre-flow?) item?)]))
(provide (contract-out [item? (any/c . -> . boolean?)]))

(define (itemlist #:style [style plain] . items)
(let ([flows (let loop ([items items])
Expand Down Expand Up @@ -218,33 +209,27 @@
;; ----------------------------------------

(define elem-like-contract
(->* () () #:rest (listof pre-content?) element?))

(provide/contract
[linebreak (-> element?)]
[nonbreaking elem-like-contract]
[hspace (-> exact-nonnegative-integer? element?)]
[elem (->* ()
(#:style element-style?)
#:rest (listof pre-content?)
element?)]
[italic elem-like-contract]
[bold elem-like-contract]
[smaller elem-like-contract]
[larger elem-like-contract]
[emph elem-like-contract]
[tt elem-like-contract]
[subscript elem-like-contract]
[superscript elem-like-contract]

[literal (->* (string?) () #:rest (listof string?) element?)]

[image (->* ((or/c path-string? (cons/c 'collects (listof bytes?))))
(#:scale real?
#:suffixes (listof (and/c string? #rx"^[.]"))
#:style element-style?)
#:rest (listof content?)
image-element?)])
(-> pre-content? ... element?))

(provide (contract-out
[linebreak (-> element?)]
[nonbreaking elem-like-contract]
[hspace (-> exact-nonnegative-integer? element?)]
[elem (->* () (#:style element-style?) #:rest (listof pre-content?) element?)]
[italic elem-like-contract]
[bold elem-like-contract]
[smaller elem-like-contract]
[larger elem-like-contract]
[emph elem-like-contract]
[tt elem-like-contract]
[subscript elem-like-contract]
[superscript elem-like-contract]
[literal (->* (string?) () #:rest (listof string?) element?)]
[image
(->* ((or/c path-string? (cons/c 'collects (listof bytes?))))
(#:scale real? #:suffixes (listof (and/c string? #rx"^[.]")) #:style element-style?)
#:rest (listof content?)
image-element?)]))

(define hspace-cache (make-vector 100 #f))

Expand Down Expand Up @@ -292,11 +277,10 @@
l))])
(if (andmap string? l)
(make-element 'tt l)
(make-element #f (map (lambda (s)
(if (or (string? s) (symbol? s))
(make-element 'tt (list s))
s))
l)))))
(make-element #f (for/list ([s (in-list l)])
(if (or (string? s) (symbol? s))
(make-element 'tt (list s))
s))))))

(define (span-class classname . str)
(make-element classname (decode-content str)))
Expand Down Expand Up @@ -331,27 +315,28 @@
(cons/c rc rc))))
rc)

(provide/contract
[para (->* ()
(#:style (or/c style? string? symbol? #f ))
#:rest (listof pre-content?)
paragraph?)]
[nested (->* ()
(#:style (or/c style? string? symbol? #f ))
#:rest (listof pre-flow?)
nested-flow?)]
[compound (->* ()
(#:style (or/c style? string? symbol? #f ))
(provide (contract-out
[para
(->* ()
(#:style (or/c style? string? symbol? #f))
#:rest (listof pre-content?)
paragraph?)]
[nested
(->* () (#:style (or/c style? string? symbol? #f)) #:rest (listof pre-flow?) nested-flow?)]
[compound
(->* ()
(#:style (or/c style? string? symbol? #f))
#:rest (listof pre-flow?)
compound-paragraph?)]
[tabular (->* ((listof (listof (or/c 'cont block? content?))))
(#:style (or/c style? string? symbol? #f)
#:sep (or/c content? block? #f)
#:column-properties (listof any/c)
#:row-properties (listof any/c)
#:cell-properties (listof (listof any/c))
#:sep-properties (or/c list? #f))
table?)])
[tabular
(->* ((listof (listof (or/c 'cont block? content?))))
(#:style (or/c style? string? symbol? #f)
#:sep (or/c content? block? #f)
#:column-properties (listof any/c)
#:row-properties (listof any/c)
#:cell-properties (listof (listof any/c))
#:sep-properties (or/c list? #f))
table?)]))

(define (convert-block-style style)
(cond
Expand Down Expand Up @@ -385,18 +370,18 @@
[(3) "rd"]
[else "th"]))
(unless (null? cells)
(let ([n (length (car cells))])
(for ([row (in-list (cdr cells))]
[pos (in-naturals 2)])
(unless (= n (length row))
(raise-mismatch-error
'tabular
(format "bad length (~a does not match first row's length ~a) for ~a~a row: "
(length row)
n
pos
(nth-str pos))
row)))))
(define n (length (car cells)))
(for ([row (in-list (cdr cells))]
[pos (in-naturals 2)])
(unless (= n (length row))
(raise-mismatch-error
'tabular
(format "bad length (~a does not match first row's length ~a) for ~a~a row: "
(length row)
n
pos
(nth-str pos))
row))))
(for ([row (in-list cells)]
[pos (in-naturals 1)])
(when (and (pair? row) (eq? (car row) 'cont))
Expand Down
51 changes: 13 additions & 38 deletions scribble-lib/scribble/sigplan.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,19 @@
scribble/latex-properties
(for-syntax racket/base))

(provide/contract
[abstract
(->* () () #:rest (listof pre-content?)
block?)]
[subtitle
(->* () () #:rest (listof pre-content?)
content?)]
[authorinfo
(-> pre-content? pre-content? pre-content?
block?)]
[conferenceinfo
(-> pre-content? pre-content?
block?)]
[copyrightyear
(->* () () #:rest (listof pre-content?)
block?)]
[copyrightdata
(->* () () #:rest (listof pre-content?)
block?)]
[exclusive-license
(->* () ()
block?)]
[doi
(->* () () #:rest (listof pre-content?)
block?)]
[to-appear
(->* () () #:rest pre-content?
block?)]
[category
(->* (pre-content? pre-content? pre-content?)
((or/c #f pre-content?))
content?)]
[terms
(->* () () #:rest (listof pre-content?)
content?)]
[keywords
(->* () () #:rest (listof pre-content?)
content?)])
(provide (contract-out
[abstract (->* () () #:rest (listof pre-content?) block?)]
[subtitle (->* () () #:rest (listof pre-content?) content?)]
[authorinfo (-> pre-content? pre-content? pre-content? block?)]
[conferenceinfo (-> pre-content? pre-content? block?)]
[copyrightyear (->* () () #:rest (listof pre-content?) block?)]
[copyrightdata (->* () () #:rest (listof pre-content?) block?)]
[exclusive-license (->* () () block?)]
[doi (->* () () #:rest (listof pre-content?) block?)]
[to-appear (->* () () #:rest pre-content? block?)]
[category (->* (pre-content? pre-content? pre-content?) ((or/c #f pre-content?)) content?)]
[terms (->* () () #:rest (listof pre-content?) content?)]
[keywords (->* () () #:rest (listof pre-content?) content?)]))

(provide preprint 10pt nocopyright onecolumn noqcourier notimes
include-abstract)
Expand Down
39 changes: 14 additions & 25 deletions scribble-lib/scriblib/footnote.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,19 @@
(define (footnote-part . text) (do-footnote-part footnotes id))))

(define (do-footnote footnotes id text)
(let ([tag (generated-tag)]
[content (decode-content text)])
(make-traverse-element
(lambda (get set)
(set id (cons (cons
(make-element footnote-target-style
(make-element
'superscript
(counter-target footnotes tag #f)))
(define tag (generated-tag))
(define content (decode-content text))
(make-traverse-element
(lambda (get set)
(set id
(cons (cons (make-element footnote-target-style
(make-element 'superscript (counter-target footnotes tag #f)))
content)
(get id null)))
(make-element footnote-style
(list
(make-element
footnote-ref-style
(make-element
'superscript
(counter-ref footnotes tag #f)))
(make-element
footnote-content-style
content)))))))
(get id null)))
(make-element footnote-style
(list (make-element footnote-ref-style
(make-element 'superscript (counter-ref footnotes tag #f)))
(make-element footnote-content-style content))))))

(define (do-footnote-part footnotes id)
(make-part
Expand All @@ -78,9 +70,6 @@
(lambda (get set)
(make-compound-paragraph
footnote-block-style
(map (lambda (content)
(make-paragraph
footnote-block-content-style
content))
(reverse (get id null)))))))
(for/list ([content (in-list (reverse (get id null)))])
(make-paragraph footnote-block-content-style content))))))
null))
Loading