docs: def pandoc(script=None,
             input=None,
             output=None,
             args='{input:q} --output {output:q}',
             **kwargs):
      '''Convert input file to output using pandoc
  
      The input can be specified in three ways:
  
      1. instant script, which is assumed to be in md format
  
      pandoc:   output='report.html'
        script
  
      2. one or more input files. The format is determined by extension of input file
  
      pandoc(input, output='report.html')
  
      3. input file specified by command line option `-r` .
      pandoc(output='report.html')
  
      If no output is specified, it is assumed to be in html format
      and is written to standard output.
  
      You can specify more options such as "from" and "to" by customizing
      the args parameter of the action. The default value of args is
      `{input:q} --output {output:q}'
      '''
      #
      #     # this is output format
      #     pandoc [OPTIONS] [FILES]
      # Input formats:  commonmark, docbook, docx, epub, haddock, html, json*, latex,
      #                 markdown, markdown_github, markdown_mmd, markdown_phpextra,
      #                 markdown_strict, mediawiki, native, odt, opml, org, rst, t2t,
      #                 textile, twiki
      #                 [ *only Pandoc's JSON version of native AST]
      # Output formats: asciidoc, beamer, commonmark, context, docbook, docx, dokuwiki,
      #                 dzslides, epub, epub3, fb2, haddock, html, html5, icml, json*,
      #                 latex, man, markdown, markdown_github, markdown_mmd,
      #                 markdown_phpextra, markdown_strict, mediawiki, native, odt,
      #                 opendocument, opml, org, pdf**, plain, revealjs, rst, rtf, s5,
      #                 slideous, slidy, tei, texinfo, textile
      #                 [**for pdf output, use latex or beamer and -o FILENAME.pdf]
      # Options:
      #   -f FORMAT, -r FORMAT  --from=FORMAT, --read=FORMAT
      #   -t FORMAT, -w FORMAT  --to=FORMAT, --write=FORMAT
      #   -o FILENAME           --output=FILENAME
      #                         --data-dir=DIRECTORY
      #   -R                    --parse-raw
      #   -S                    --smart
      #
      # IGNORED
      #
      if not executable('pandoc').target_exists():
          raise RuntimeError('pandoc not found')
  
      input = sos_targets(collect_input(script, input))
  
      output = sos_targets(output)
      if len(output) == 0:
          write_to_stdout = True
          output = sos_targets(
              tempfile.NamedTemporaryFile(
                  mode='w+t', suffix='.html', delete=False).name)
      else:
          write_to_stdout = False
      #
      ret = 1
      try:
          p = None
          cmd = interpolate(f'pandoc {args}', {'input': input, 'output': output})
          if 'ACTION' in env.config['SOS_DEBUG'] or 'ALL' in env.config['SOS_DEBUG']:
              env.log_to_file('ACTION', f'Running command "{cmd}"')
          if env.config['run_mode'] == 'interactive':
              # need to catch output and send to python output, which will in trun be hijacked by SoS notebook
              from .utils import pexpect_run
              ret = pexpect_run(cmd)
          else:
              p = subprocess.Popen(cmd, shell=True)
              ret = p.wait()
      except Exception as e:
          env.logger.error(e)
      if ret != 0:
          temp_file = os.path.join('.sos', f'pandoc_{os.getpid()}.md')
          shutil.copyfile(input, temp_file)
          cmd = interpolate(f'pandoc {args}', {
              'input': sos_targets(temp_file),
              'output': sos_targets(output)
          })
          raise RuntimeError(
              f'Failed to execute script. Please use command \n{cmd}\nunder {os.getcwd()} to test it.'
          )
      if write_to_stdout:
          with open(output[0].fullname()) as out:
              sys.stdout.write(out.read())
      else:
          env.logger.info(f'Report saved to {output}')
      try:
          os.remove(input)
      except Exception:
          pass