Accessing m4 to pre-process markdown files from a shiny app

I have a shiny app with various chunks of text in markdown formatted files. In other contexts I would parameterise those files and use the m4 macro processor to do the substitutions.

The code would be something like markdown(read_file(pipe("m4 markdownfile.md")))

This needs m4 installed to work. Is it installed on shinyapps.io? Or perhaps there is another way of achieving the same goal ... parameterised files of text.

Cheers,
Geoff

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

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.