chickadee » hyde » make-external-translator

make-external-translator program-name #!optional argsprocedure

Creates a procedure that reads from (current-input-port) and writes to the standard input of the external program program-name (either a string or a thunk returning a string). Optionally a thunk can be passed for args which needs to return a list of arguments for the program. The program's standard output is read back and written to (current-output-port). It can be used to create page translators for external programs, e.g. the markdown translator included in Hyde is defined like this:

(define translate-markdown (make-external-translator markdown-program))
(translators (cons (list "md" translate-markdown) (translators)))