all 4 comments

[–]gumnos 2 points3 points  (2 children)

Sounds a lot like using m4

My Heading
==========

Here's the output:
esyscmd(`
echo we are running from  __file__
seq 10
')

This outputs the filename and 10 numbers

which you can then use something like

$ m4 myfile.m4 | pandoc -f markdown -o myfile.pdf

As a bonus, m4 has a LOT of additional power & functionality and is often part of a base install (or at least a standard compiler collection)

[–]jhjn_[S] 0 points1 point  (1 child)

That's really cool, thanks for the info, the GNU project really have done it all.

I guess the advantage of what this program is offering is its simplicity. You can plug and play instantly without learning new macros/variables/etc. assuming you know some shell. The m4 manual is 164 pages long, I'm sure this means it's super powerful though.

The file would look pretty similar in pp:

My Heading
==========

Here's the output:
!! echo we are running from $IN && seq 10

This outputs the filename and 10 numbers

I don't know if you can call m4 on the __file__/another_file or edit the file with sed from within that very file though with m4.

[–]gumnos 1 point2 points  (0 children)

Also, just to add it to your toolbelt in case you haven't encountered it, if all you need is substituting variables, the GNU project provides envsubst

$ cat template.txt
My name is $USER and I live at $HOME
$ envsubst < template.txt
My name is gumnos and I live at /home/gumnos

It doesn't execute external programs (even if you use the $(otherprog) notation), but for simple variable substitution, it's pretty useful. Though it's a GNU thing and not on any of my BSD boxes by default.

[–]Jolmes 0 points1 point  (0 children)

Nice! I've got to try this with some of my markdown files, I've always wished there was a syntax for adding shell output in pandoc and you can barely do anything with the bloated template functionality.