diff --git a/pandoc.chicken.scm b/pandoc.chicken.scm index 8f4ab6b..bee0084 100644 --- a/pandoc.chicken.scm +++ b/pandoc.chicken.scm @@ -11,10 +11,10 @@ (only (chicken io) read-byte write-byte) (only (chicken port) copy-port) (only (chicken process) process process-wait) - (rename (only (medea) read-json) - (read-json json-read))) + (only (scsh-process) run/port) + (only (medea) read-json)) - (define (run-read-write args input-port read-output) + (define (run-read-write/old args input-port read-output) (receive (from-sub to-sub sub) (process (car args) (cdr args)) (copy-port input-port to-sub read-byte write-byte) (close-output-port to-sub) @@ -28,6 +28,11 @@ (if (and clean-exit? (eqv? 0 exit-status)) output (error "Error running" args)))))) + (define (pandoc-port->json input-format input-port) + (let ((pandoc (string->symbol (car (pandoc-command-line))))) + (read-json (run/port (,pandoc --from ,input-format --to json) + (= 0 input-port))))) + (define (call-with-binary-input-file filename proc) (let ((port (open-input-file filename #:binary))) (dynamic-wind (lambda () #f) diff --git a/pandoc.r5rs.scm b/pandoc.r5rs.scm index fc21586..b5a9918 100644 --- a/pandoc.r5rs.scm +++ b/pandoc.r5rs.scm @@ -100,13 +100,6 @@ (assert-supported-version) (convert-many (vector->list (cdr (assq 'blocks json))))) -(define (pandoc-port->json input-format input-port) - (run-read-write (append (pandoc-command-line) - (list "--from" (symbol->string input-format) - "--to" "json")) - input-port - json-read)) - (define (pandoc-port->sxml input-format input-port) (pandoc-json->sxml (pandoc-port->json input-format input-port)))