Permalink
Browse files

Live preview now works

  • Loading branch information...
1 parent e07083a commit dbebcafda20950517b58da5e924408b1cc2fffed @swaroopch committed Dec 4, 2012
View
@@ -16,13 +16,16 @@
<body>
<div class="row">
<div id="text-section" class="six columns">
+ <h2>Pandoc text</h2>
<div class="panel">
- Text input here
+ <textarea id="source-text" rows="50"></textarea>
</div>
</div>
<div id="preview-section" class="six columns">
+ <h2>Preview</h2>
<div class="panel">
- Preview here
+ <div id="preview-html">
+ </div>
</div>
</div>
</div>
@@ -33,5 +36,6 @@
<!-- Initialize JS Plugins -->
<script src="foundation/javascripts/app.js"></script>
+ <script src="index.js"></script>
</body>
</html>
View
@@ -0,0 +1,31 @@
+$(function() {
+ var os = require("os");
+ var fs = require("fs");
+ var exec = require("exec");
+
+ var tmp_source_file = os.tmpDir() + "kalam.txt";
+
+ function render() {
+ var text = $("#source-text").val();
+
+ fs.writeFile(tmp_source_file, text, function(err) {
+ if (err) {
+ alert(err);
+ return;
+ }
+
+ var pandoc_command = ["pandoc",
+ "-f",
+ "markdown",
+ "-t",
+ "html",
+ "-i",
+ tmp_source_file];
+ exec(pandoc_command, function(err, out, code) {
+ $("#preview-html").html(out);
+ });
+ });
+ }
+
+ window.setInterval(render, 3000);
+});

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit dbebcaf

Please sign in to comment.