HACKER Q&A
📣 leksak

What macro-processing language am I looking for


I have a project that I want to document and one thing I'd like to do is to highlight that the application code is decomposed in a way that maps essentially 1-to-1 to the theoretical framework and the way I'd like to do this is to run `tree` inside of the markup that should be outputted as Markdown in the end.

E.g., passing the following input.some_fileextension file to the processor should evaluate the tree command and put the results there

bla bla bla

$ tree dir

bla bla blah

Is this a task for pandoc? M4? Something else? I want something close to Jupyter notebooks without needing that _entire_ framework at hand.

Or is there some lispy type of thing that I can use?


  👤 karmakaze Accepted Answer ✓
What application code language are you using that doesn't already have one or more source doc-generators? Can you just tweak or post process the output from them?

👤 Someone
shell? Something like this (definitely buggy; you’ll have to remove the ‘$’ from the line before you evaluate it. I also didn’t check how to match that dollar sign at the start of a line. I think you can solve both problems by using a semicolon, not a dollar sign as indicator for ‘evaluate this line’. You also _may_ want to allow multi-line commands and there maybe more bugs):

  while read line ; do
    case "$line" in
      \$*) `$line`
      *)  echo $line
      ;;
    esac
  done