mydir = os.path.dirname(os.path.realpath(__file__))
-def print_markdown_as(format, text):
+def markdown_as(format, text):
sys.stdout.flush()
- proc = subprocess.Popen(['pandoc', '-f', 'markdown', '-t', format], stdin = subprocess.PIPE)
+ proc = subprocess.Popen(['pandoc', '-f', 'markdown', '-t', format], stdin = subprocess.PIPE, stdout = subprocess.PIPE)
proc.stdin.write(bytes(text, 'UTF-8'))
- proc.communicate()
+ (stdout, stderr) = proc.communicate()
proc.stdin.close()
if proc.returncode:
raise Exception("pandoc failed: %d" % proc.returncode)
+ return stdout.decode('utf-8').rstrip()
+
+def print_markdown_as(format, text):
+ print(markdown_as(format, text))
def print_latex_desc(doc, filename):
def iodef_str(iodef):
for io in iodef:
str += Template('\\item {\\bf $name} $type').substitute(io)
if 'range' in io:
- str += ' %s' % io['range']
+ str += ' %s' % markdown_as('latex', io['range'])
if 'note' in io:
- str += ' %s' % io['note']
+ str += ' %s' % markdown_as('latex', io['note'])
str += '\n'
return str +'\end{enumerate}'