From 3a3a58f73bbe0dc24d357474a6e3693d6eee7121 Mon Sep 17 00:00:00 2001 From: Petr Skocik Date: Thu, 12 Mar 2015 19:05:31 +0100 Subject: [PATCH] make reload work --- instant-markdown-d | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/instant-markdown-d b/instant-markdown-d index c75208f..7fe8e83 100755 --- a/instant-markdown-d +++ b/instant-markdown-d @@ -8,6 +8,7 @@ var server = require('http').createServer(httpHandler), io = require('socket.io').listen(server), send = require('send'), server, + html = "", socket; server.listen(8090); @@ -37,7 +38,8 @@ function writeMarkdown(input, output) { } }); input.on('end', function() { - output.emit('newContent', md.render(body)); + html = md.render(body); + output.emit('newContent', html); }); } @@ -88,6 +90,7 @@ io.set('log level', 1); io.sockets.on('connection', function(sock){ socket = sock; process.stdout.write('connection established!'); + socket.emit('newContent', html); writeMarkdown(process.stdin, socket); process.stdin.resume(); });