code: def smartquotes(text):
      
      command = shlex.split('pandoc --smart -t plain')
      com = Popen(command, shell=False, stdin=PIPE, stdout=PIPE, stderr=PIPE)
      out, err = com.communicate(text.encode('utf-8'))
      com_out = out.decode('utf-8')
      text = com_out.replace(u'\n', u' ').strip()
      return text
docs: Runs text through pandoc for smartquote correction.