This works ... I put my m4 macros in m4defs.txt and then used the following
to include them before all files I used.
markdown(read_file(pipe(paste0("cat m4defs.txt ",filename," | m4 "))))
Here is my testing m4defs.txt. It allows for example to have notes in my files that
don't display on the Shiny app. The full power of m4 is available. The definition of
divert isn't obvious ... if you don't have it, using the word divert can cause problems. A bad design flaw in m4!
changecom(`/[*',`*]/')dnl
changequote(`[[',`]]')dnl
define(DROPTHIS,[[]])dnl
define(DLNG,[[liquified natural gas (LNG)]])dnl
define([[divert]], [[ifelse([[$#]], [[0]], [[[[$0]]]], [[builtin([[$0]], $@)]]) ]])dnl