diff options
| author | Florian Fischer <florian.fl.fischer@fau.de> | 2017-04-07 13:41:14 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fl.fischer@fau.de> | 2017-04-07 13:42:00 +0200 |
| commit | f4ae2a2897d24dc149422d86e4509b890ec6be40 (patch) | |
| tree | 646285e9d4ee4491dbcf88e653870e5a7deb22a3 | |
| parent | c9f8abdeb0b9ec072eeac1229b06be0373b2a173 (diff) | |
| download | rcheatsheet-f4ae2a2897d24dc149422d86e4509b890ec6be40.tar.gz rcheatsheet-f4ae2a2897d24dc149422d86e4509b890ec6be40.zip | |
simplify subprocess handling
| -rwxr-xr-x | highlight_code.py | 7 |
1 files changed, 2 insertions, 5 deletions
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) |
