Show More
@@ -15,6 +15,8 b' from __future__ import print_function' | |||
|
15 | 15 | |
|
16 | 16 | # Stdlib imports |
|
17 | 17 | import subprocess |
|
18 | import re | |
|
19 | import warnings | |
|
18 | 20 | from io import TextIOWrapper, BytesIO |
|
19 | 21 | |
|
20 | 22 | # IPython imports |
@@ -30,6 +32,7 b' class PandocMissing(ConversionException):' | |||
|
30 | 32 | """Exception raised when Pandoc is missing. """ |
|
31 | 33 | pass |
|
32 | 34 | |
|
35 | minimal_version = "1.12.1" | |
|
33 | 36 | |
|
34 | 37 | def pandoc(source, fmt, to, extra_args=None, encoding='utf-8'): |
|
35 | 38 | """Convert an input string in format `from` to format `to` via pandoc. |
@@ -68,3 +71,21 b" def pandoc(source, fmt, to, extra_args=None, encoding='utf-8'):" | |||
|
68 | 71 | out = TextIOWrapper(BytesIO(out), encoding, 'replace').read() |
|
69 | 72 | return out.rstrip('\n') |
|
70 | 73 | |
|
74 | ||
|
75 | pv_re = re.compile(r'(\d{0,3}\.\d{0,3}\.\d{0,3})') | |
|
76 | def get_pandoc_version(): | |
|
77 | out = subprocess.check_output(['pandoc', '--version'], universal_newlines=True) | |
|
78 | return pv_re.search(out).group(0) | |
|
79 | ||
|
80 | ||
|
81 | pandoc.version = get_pandoc_version() | |
|
82 | ||
|
83 | def check_pandoc_version(): | |
|
84 | return pandoc.version >= minimal_version | |
|
85 | ||
|
86 | if(not check_pandoc_version()): | |
|
87 | warnings.warn( "You are using an old version of pandoc (%s)\n"%pandoc.version + | |
|
88 | "Recommended version is %s.\nTry updating."%minimal_version + | |
|
89 | "http://johnmacfarlane.net/pandoc/installing.html.\nContinuing with doubts...", | |
|
90 | RuntimeWarning, | |
|
91 | stacklevel=2) |
General Comments 0
You need to be logged in to leave comments.
Login now