-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.docx.p
20 lines (18 loc) · 1015 Bytes
/
template.docx.p
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
◊(local-require racket/list racket/file racket/system)
◊(define pandoc-source ◊string-append{
---
title: ◊(select 'title here)
author: ◊(select 'author here)
---
◊(apply string-append (filter string? (flatten doc)))})
◊(define working-directory
(make-temporary-file "pollen-markdown-work-~a" 'directory))
◊(define temp-md-path (build-path working-directory "temp.md"))
◊(define temp-docx-path (build-path working-directory "temp.docx"))
◊(define reference-doc-path (build-path (current-project-root) "reference-doc.docx"))
◊(display-to-file pandoc-source temp-md-path #:exists 'replace)
◊(define command (format "pandoc --reference-doc=~a ~a -o ~a" reference-doc-path temp-md-path temp-docx-path))
◊(unless (system command) (error "pandoc: rendering error"))
◊(let ([docx (file->bytes temp-docx-path)])
(delete-directory/files working-directory)
docx)