From f4ae2a2897d24dc149422d86e4509b890ec6be40 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Fri, 7 Apr 2017 13:41:14 +0200 Subject: simplify subprocess handling --- highlight_code.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'highlight_code.py') diff --git a/highlight_code.py b/highlight_code.py index f023c0a..a780e0a 100755 --- a/highlight_code.py +++ b/highlight_code.py @@ -15,11 +15,8 @@ def main(): break m = re.search(code_re, s) if m: - pandoc = subprocess.Popen(["pandoc","-f", "markdown", "-"], - universal_newlines=True, stdin=subprocess.PIPE, - stdout=subprocess.PIPE) - code, err = pandoc.communicate(input=code_format.format(m.group(1), m.group(2))) - pandoc.kill() + code = subprocess.check_output(["pandoc","-f", "markdown", "-"], + universal_newlines=True, input=code_format.format(m.group(1), m.group(2))) s = re.sub(code_re, code, s) s = s.replace('\n', '') print(s) -- cgit v1.2.3