Skip to content

Commit a241597

Browse files
author
Nicklas Tegner
authored
Merge pull request #217 from LukeBriggsDev/master
2 parents a631312 + 77f7a2a commit a241597

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

‎pypandoc/__init__.py‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,13 +282,14 @@ def _convert_input(source, format, input_type, to, extra_args=(), outputfile=Non
282282
new_env = os.environ.copy()
283283
files_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "files")
284284
new_env["PATH"] = new_env.get("PATH", "") + os.pathsep + files_path
285-
285+
creation_flag = 0x08000000 if sys.platform == "win32" else 0 # set creation flag to not open pandoc in new console on windows
286286
p = subprocess.Popen(
287287
args,
288288
stdin=subprocess.PIPE if string_input else None,
289289
stdout=subprocess.PIPE,
290290
stderr=subprocess.PIPE,
291-
env=new_env)
291+
env=new_env,
292+
creationflags=creation_flag)
292293

293294
# something else than 'None' indicates that the process already terminated
294295
if not (p.returncode is None):
@@ -341,11 +342,13 @@ def get_pandoc_formats():
341342
Return 2 lists. "from_formats" and "to_formats".
342343
'''
343344
_ensure_pandoc_path()
345+
creation_flag = 0x08000000 if sys.platform == "win32" else 0 # set creation flag to not open pandoc in new console on windows
344346
p = subprocess.Popen(
345347
[__pandoc_path, '--list-output-formats'],
346348
stdin=subprocess.PIPE,
347349
stderr=subprocess.PIPE,
348-
stdout=subprocess.PIPE)
350+
stdout=subprocess.PIPE,
351+
creationflags=creation_flag)
349352

350353
comm = p.communicate()
351354
out = comm[0].decode().splitlines(False)
@@ -357,7 +360,8 @@ def get_pandoc_formats():
357360
[__pandoc_path, '--list-input-formats'],
358361
stdin=subprocess.PIPE,
359362
stderr=subprocess.PIPE,
360-
stdout=subprocess.PIPE)
363+
stdout=subprocess.PIPE,
364+
creationflags=creation_flag)
361365

362366
comm = p.communicate()
363367
in_ = comm[0].decode().splitlines(False)
@@ -371,10 +375,12 @@ def get_pandoc_formats_pre_1_18():
371375
Return 2 lists. "from_formats" and "to_formats".
372376
'''
373377
_ensure_pandoc_path()
378+
creation_flag = 0x08000000 if sys.platform == "win32" else 0 # set creation flag to not open pandoc in new console on windows
374379
p = subprocess.Popen(
375380
[__pandoc_path, '-h'],
376381
stdin=subprocess.PIPE,
377-
stdout=subprocess.PIPE)
382+
stdout=subprocess.PIPE,
383+
creationflags=creation_flag)
378384

379385
comm = p.communicate()
380386
help_text = comm[0].decode().splitlines(False)
@@ -394,13 +400,15 @@ def get_pandoc_formats_pre_1_18():
394400

395401
def _get_pandoc_version(pandoc_path):
396402
new_env = os.environ.copy()
403+
creation_flag = 0x08000000 if sys.platform == "win32" else 0 # set creation flag to not open pandoc in new console on windows
397404
if 'HOME' not in os.environ:
398405
new_env['HOME'] = tempfile.gettempdir()
399406
p = subprocess.Popen(
400407
[pandoc_path, '--version'],
401408
stdin=subprocess.PIPE,
402409
stdout=subprocess.PIPE,
403-
env=new_env)
410+
env=new_env,
411+
creationflags=creation_flag)
404412
comm = p.communicate()
405413
out_lines = comm[0].decode().splitlines(False)
406414
if p.returncode != 0 or len(out_lines) == 0:

0 commit comments

Comments
 (0)