main
Matthew Butterick 6 years ago
parent f9b71592f1
commit 6edc2064fc

@ -3,6 +3,7 @@
racket/promise
racket/match
racket/list
racket/file
sugar/list
txexpr/base
racket/date
@ -578,9 +579,10 @@
(define default-page-orientation "tall")
(define/contract (render-pdf qx-arg pdf-path-arg
#:replace [replace? #t])
((qexpr? (or/c path? path-string?)) (#:replace any/c) . ->* . void?)
(define pdf-path (path->complete-path (simplify-path (expand-user-path (->path pdf-path-arg)))))
((qexpr? (or/c #false path? path-string?)) (#:replace any/c) . ->* . (or/c void? bytes?))
(define fallback-path (build-path (find-system-path 'temp-dir) "quadwriter-temp.pdf"))
(define pdf-path (path->complete-path (simplify-path (expand-user-path (->path (or pdf-path-arg fallback-path))))))
(when (and (not replace?) (file-exists? pdf-path))
(raise-argument-error 'render-pdf "path that doesn't exist" pdf-path))
@ -640,4 +642,9 @@
[qs (time-name page-wrap (page-wrap qs page-wrap-size page-quad))]
[qs (time-name position (position (struct-copy quad q:doc [elems qs])))])
(time-name draw (draw qs pdf))
(displayln (format "wrote PDF to ~a" pdf-path)))))
(displayln (format "wrote PDF to ~a" pdf-path))))
(unless pdf-path-arg
(begin0
(file->bytes pdf-path)
(delete-file pdf-path))))

@ -27,9 +27,10 @@
(λ (m)
(match m
[(list _ kw val) (loop (cons (list kw val) acc))]))]
[else (for/list ([item (in-list acc)])
;; reverse in case of multiple values with same keyword, latest takes precedence (by becoming first)
[else (reverse (for/list ([item (in-list acc)])
(match-define (list kw val) (map bytes->string/utf-8 item))
(list (string->symbol (string-trim kw "#:")) val))])))
(list (string->symbol (string-trim kw "#:")) val)))])))
(strip-context
(with-syntax ([PATH-STRING path-string]
[((ATTR-NAME ATTR-VAL) ...) kw-attrs]

@ -2,6 +2,12 @@
(require "core.rkt")
(provide (all-from-out "core.rkt"))
(module docmod racket/base
(define doc 'just-for-label)
(provide doc))
(require (for-label 'docmod))
(provide (for-label doc)) ; stub for scribble labels
(module reader racket/base
(require "lang-helper.rkt")
(provide (rename-out [rs read-syntax]) get-info)

Loading…
Cancel
Save