From 6a11b78e7d514bead790fe0e3344727757fdf550 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Sat, 1 Mar 2014 20:54:18 -0800 Subject: [PATCH] add markdown support --- main.rkt | 2 ++ markdown/lang/reader.rkt | 4 ++++ world.rkt | 2 ++ 3 files changed, 8 insertions(+) create mode 100644 markdown/lang/reader.rkt diff --git a/main.rkt b/main.rkt index 39b0877..f330adc 100644 --- a/main.rkt +++ b/main.rkt @@ -66,6 +66,7 @@ (cond [(equal? (string->symbol here-ext) world:ptree-source-ext) world:reader-mode-ptree] [(equal? (string->symbol here-ext) world:markup-source-ext) world:reader-mode-markup] + [(equal? (string->symbol here-ext) world:markdown-source-ext) world:reader-mode-markdown] [else world:reader-mode-preproc])) reader-mode)) @@ -76,6 +77,7 @@ ;; 'root is the hook for the decoder function. ;; If it's not a defined identifier, it just hits #%top and becomes `(root ,@body ...) [(equal? parser-mode world:reader-mode-markup) root] + [(equal? parser-mode world:reader-mode-markdown) (compose1 (λ(x) `(root ,@x)) (dynamic-require 'markdown 'parse-markdown) string-append)] ;; for preprocessor output, just make a string. [else (λ xs (apply string-append (map to-string xs)))]) (cdr doc-without-metas))) ;; cdr strips placeholder-root tag diff --git a/markdown/lang/reader.rkt b/markdown/lang/reader.rkt new file mode 100644 index 0000000..8a8016d --- /dev/null +++ b/markdown/lang/reader.rkt @@ -0,0 +1,4 @@ +#lang racket/base +(require pollen/lang/reader-base) + +(make-reader-with-mode world:reader-mode-markdown) \ No newline at end of file diff --git a/world.rkt b/world.rkt index f460358..a4ab1b8 100644 --- a/world.rkt +++ b/world.rkt @@ -6,6 +6,7 @@ (define preproc-source-ext 'pp) (define markup-source-ext 'pm) +(define markdown-source-ext 'pmd) (define null-source-ext 'p) (define ptree-source-ext 'ptree) (define template-source-ext 'pt) @@ -13,6 +14,7 @@ (define reader-mode-auto 'auto) (define reader-mode-preproc 'pre) (define reader-mode-markup 'markup) +(define reader-mode-markdown 'markdown) (define reader-mode-ptree 'ptree) (define decodable-extensions (list markup-source-ext ptree-source-ext))