##// END OF EJS Templates
Cleanup
Jonathan Frederic -
Show More
@@ -23,8 +23,9 b' from io import TextIOWrapper, BytesIO'
23 # IPython imports
23 # IPython imports
24 from IPython.nbconvert.utils.pandoc import pandoc
24 from IPython.nbconvert.utils.pandoc import pandoc
25 from IPython.nbconvert.utils.exceptions import ConversionException
25 from IPython.nbconvert.utils.exceptions import ConversionException
26 from IPython.utils.process import find_cmd, FindCmdError, getoutput
26 from IPython.utils.process import get_output_error_code
27 from IPython.utils.py3compat import cast_bytes
27 from IPython.utils.py3compat import cast_bytes
28 from IPython.utils.version import check_version
28
29
29 #-----------------------------------------------------------------------------
30 #-----------------------------------------------------------------------------
30 # Functions
31 # Functions
@@ -100,7 +101,7 b' def markdown2rst(source):'
100 return pandoc(source, 'markdown', 'rst')
101 return pandoc(source, 'markdown', 'rst')
101
102
102 def _verify_node(cmd):
103 def _verify_node(cmd):
103 """Verify that the node command exists and is atleast the minimum supported
104 """Verify that the node command exists and is at least the minimum supported
104 version of node.
105 version of node.
105
106
106 Parameters
107 Parameters
@@ -108,23 +109,13 b' def _verify_node(cmd):'
108 cmd : string
109 cmd : string
109 Node command to verify (i.e 'node')."""
110 Node command to verify (i.e 'node')."""
110 try:
111 try:
111 find_cmd(node_cmd)
112 out, err, return_code = get_output_error_code([cmd, '--version'])
112 except FindCmdError:
113 except OSError:
114 # Command not found
113 return False
115 return False
114 else:
116 return return_code == 0 and check_version(out.lstrip('v'), '0.9.12')
115 # Remove the version 'v' prefix from the output and strip whitespace.
117
116 version_str = getoutput(cmd + ' --version').replace('v', '').strip()
118 # prefer md2html via marked if node.js >= 0.9.12 is available
117 try:
118 # Make sure the node version is atleast 0.9.12
119 version_numbers = [int(x) for x in version_str.split('.')]
120 if version_numbers[0] > 0 or version_numbers[1] > 9 or (version_numbers[1] == 9 and version_numbers[2] >= 12):
121 return True
122 else:
123 return False
124 except:
125 return False
126
127 # prefer md2html via marked if node.js is available
128 # node is called nodejs on debian, so try that first
119 # node is called nodejs on debian, so try that first
129 node_cmd = 'nodejs'
120 node_cmd = 'nodejs'
130 if _verify_node(node_cmd):
121 if _verify_node(node_cmd):
General Comments 0
You need to be logged in to leave comments. Login now