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

36 lines
1.2 KiB
Racket

#lang debug racket/base
6 years ago
(require racket/list
6 years ago
racket/match
quadwriter/core
6 years ago
"tags.rkt"
6 years ago
"lang-helper.rkt")
(provide (all-defined-out)
6 years ago
#%app #%top #%datum #%top-interaction require
6 years ago
(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 (doc-proc exprs)
(define strs (match exprs
6 years ago
[(? null?) '(" ")] ; single nonbreaking space, so something prints
6 years ago
[strs strs]))
6 years ago
;; markdown parser returns list of paragraphs
(root null (match strs
[(list str) strs]
6 years ago
[_ (add-between strs (list q:para-break)
#:before-first (list q:para-break)
#:after-last (list q:para-break)
#:splice? #true)])))
6 years ago
(make-module-begin doc-proc)
6 years ago
(module reader racket/base
6 years ago
(require racket/port markdown "lang-helper.rkt")
6 years ago
(provide read-syntax get-info)
6 years ago
(define read-syntax (make-read-syntax 'quadwriter/markdown
(λ (path-string p) (xexpr->parse-tree (parse-markdown (port->string p)))))))