You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
typesetting/quad/quadwriter/markdown.rkt

57 lines
1.9 KiB
Racket

#lang debug racket/base
6 years ago
(require (for-syntax racket/base)
racket/list
racket/match
quadwriter/core
6 years ago
"tags.rkt"
6 years ago
"font.rkt"
6 years ago
"reader-helper.rkt"
"param.rkt")
6 years ago
(provide (except-out (all-defined-out) mb)
(rename-out [mb #%module-begin])
6 years ago
#%app #%datum #%top-interaction
(all-from-out "tags.rkt"))
6 years ago
(define rsquo "")
(define rdquo "")
(define lsquo "")
(define ldquo "")
(define hellip "")
(define ndash "")
(define mdash "")
6 years ago
(define-syntax (mb stx)
(syntax-case stx ()
[(_ PATH-STRING . STRS)
(with-syntax ([DOC (datum->syntax #'PATH-STRING 'doc)])
#'(#%module-begin
;; stick an nbsp in the strings so we have one printing char
(define strs (match (list . STRS)
[(? null?) '(" ")]
[strs strs]))
(define DOC (root null (add-between strs (list pbr)
#:before-first (list pbr)
#:after-last (list pbr)
#:splice? #true)))
(provide DOC)
(module+ main
(render-pdf DOC (path-string->pdf-path 'PATH-STRING)))))]))
6 years ago
(module reader racket/base
6 years ago
(require syntax/strip-context
(only-in markdown parse-markdown)
"reader-helper.rkt")
(provide (rename-out [rs read-syntax]))
6 years ago
(define (rs path-string p)
6 years ago
(define stxs (quad-at-reader path-string p))
(define parsed-stxs
6 years ago
(datum->syntax stxs
(xexpr->parse-tree
6 years ago
(parse-markdown (apply string-append (syntax->datum stxs))))))
6 years ago
(strip-context
6 years ago
(with-syntax ([PATH-STRING path-string]
[PARSED-STXS parsed-stxs])
6 years ago
#'(module _ quadwriter/markdown
6 years ago
PATH-STRING
. PARSED-STXS)))))