From 8c491e0145be8f9a45e0a36c67997fe519beda2f Mon Sep 17 00:00:00 2001 From: JT Date: Sat, 30 May 2015 11:33:59 +0100 Subject: [PATCH 1/3] Turns out it's quite simple to get source lines into output. --- index.html | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 4c927d4..0090dbd 100644 --- a/index.html +++ b/index.html @@ -306,9 +306,21 @@ return ''; }); + var env = {}; + var tokens = md.parse(val, env); + + tokens.forEach(function(t){ + if(t.map){ + t.attrPush([ 'source-lines', t.map[0] + ' ' + (t.map[1]-1) ]); + } + }); + + var html = md.renderer.render(tokens, md.options, env); + + var out = document.getElementById('out'); var old = out.cloneNode(true); - out.innerHTML = md.render(val); + out.innerHTML = html; emojify.run(out); var allold = old.getElementsByTagName("*"); @@ -361,6 +373,8 @@ } function saveAsHtml() { + // TODO out.innerHTML includes source-lines and various emoji refs + // probably best to do a fresh md.render(editor.getValue()) save(document.getElementById('out').innerHTML, "untitled.html"); } From 101615116d3a90dc430ea2bb3337cb27a3351028 Mon Sep 17 00:00:00 2001 From: JT Date: Sat, 6 Jun 2015 11:28:48 +0100 Subject: [PATCH 2/3] Initial stab at synced scrolling. --- index.html | 10 +-- scroll-sync.js | 190 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 195 insertions(+), 5 deletions(-) create mode 100644 scroll-sync.js diff --git a/index.html b/index.html index 0090dbd..d0f4b22 100644 --- a/index.html +++ b/index.html @@ -17,16 +17,13 @@ +