mbutterick / pollen-users

please use https://forums.matthewbutterick.com/c/typesetting/ instead
https://forums.matthewbutterick.com/c/typesetting/
53 stars 0 forks source link

execute shell command via preprocessor? #129

Closed femtomc closed 2 years ago

femtomc commented 2 years ago

I have some code which calls out to graphviz

◊(dot #:unique-name "graph" 
(apply string-append 
    "rankdir=TD;"
    "node [margin=0 fontsize=12 width=2.2 fixedsize=true 
           shape=rect style=filled];"
    (map generate-link-graph 
    (pagetree->list (get-pagetree "index.ptree")))))

◊(system "dot -Txdot_json -ograph.json images/dot_graph.dot")

then I want to execute a shell command, so I try to use system. However, this doesn't execute (even if I try to sequence, and return proper syntax.

Is there some way to do this?

Edit: I forgot to include racket/system into this file. However, I tried to get around the fact that I get a malformed X-expression:

◊(begin
    (system "dot -Txdot_json -ograph.json images/dot_graph.dot")
    `(p "")
    )

this doesn't work, however.

Edit2: fixed.

◊(if (system "dot -Txdot_json -ograph.json images/dot_graph.dot") "" "")

works!