diff --git a/cgi-bin/pandoc.cgi b/cgi-bin/pandoc.cgi index f3e93f1..31ca8e0 100755 --- a/cgi-bin/pandoc.cgi +++ b/cgi-bin/pandoc.cgi @@ -57,7 +57,8 @@ if method == "POST": if from_format == None: from_format = guess_format_from_filename(f.filename) - tmp = NTF(delete=False) +# tmp = NTF(delete=False) + tmp = open('pandoc.tmp','wb') bytes = 0 while True: data = f.file.read() @@ -76,7 +77,10 @@ if method == "POST": print # p = subprocess.check_output('pandoc --from {0} --to {1} "{2}"'.format(ffrom, to, tmp.name), shell=True, stderr=subprocess.STDOUT) # print p - p = subprocess.Popen([PANDOC, '--from', from_format, '--to', to_format, tmp.name], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + if to_format is 'icml': + p = subprocess.Popen([PANDOC, '--from', 'docx', '--to', to_format,'-s', '/home/andre/public_html/oooooooooo.io/cgi-bin/pandoc.tmp'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + else: + p = subprocess.Popen([PANDOC, '--from', 'docx', '--to', to_format, '/home/andre/public_html/oooooooooo.io/cgi-bin/pandoc.tmp', '--atx-headers'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() print out @@ -86,7 +90,7 @@ if method == "POST": print print u"An error occurred, pandoc said: {0}".format(e.output).format("utf-8") - tmp.unlink(tmp.name) +# tmp.unlink(tmp.name) ################################### # FORM/TEXT INPUT @@ -101,7 +105,11 @@ if method == "POST": print # p = subprocess.check_output('pandoc --from {0} --to {1} "{2}"'.format(ffrom, to, tmp.name), shell=True, stderr=subprocess.STDOUT) # print p - p = subprocess.Popen([PANDOC, '--from', from_format, '--to', to_format], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + + if to_format == 'icml': + p = subprocess.Popen([PANDOC, '--from', from_format, '--to', to_format , '-s'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + else: + p = subprocess.Popen([PANDOC, '--from', from_format, '--to', to_format, '--atx-headers' ], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate(text) print out diff --git a/cgi-bin/pandoc.tmp b/cgi-bin/pandoc.tmp new file mode 100644 index 0000000..50d1ee7 Binary files /dev/null and b/cgi-bin/pandoc.tmp differ diff --git a/hybrid.html b/hybrid.html index 107e8e4..e10733c 100644 --- a/hybrid.html +++ b/hybrid.html @@ -64,7 +64,7 @@ - + diff --git a/hybrid.js b/hybrid.js index 06aed1e..ce82ea0 100644 --- a/hybrid.js +++ b/hybrid.js @@ -50,7 +50,7 @@ aa_frames("#split"); var editor = ace.edit($("#editortext").get(0)); editor.setTheme("ace/theme/chrome"); editor.setHighlightActiveLine(false); -editor.setShowInvisibles(true); +editor.setShowInvisibles(false); editor.getSession().setMode("ace/mode/markdown"); editor.getSession().setUseWrapMode(true);