Commit 05dd7e15223e6e4fac6742982803a59963334c48
Remove extra spaces after list item bullets
Charles Lehner committed on 6/3/2016, 12:41:50 AMParent: fabc115ec408aa86397386cdb395fb2f7ce3f297
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -18,10 +18,22 @@ | ||
18 | 18 | filter: ['span', 'div', 'small', 'font'], |
19 | 19 | replacement: function (content) { |
20 | 20 | return content |
21 | 21 | } |
22 | + }, | |
23 | + { | |
24 | + filter: 'li', | |
25 | + replacement: function (content, node) { | |
26 | + content = content.replace(/^\s+/, '').replace(/\n/gm, '\n ') | |
27 | + var parent = node.parentNode | |
28 | + var index = Array.prototype.indexOf.call(parent.children, node) + 1 | |
29 | + | |
30 | + var prefix = /ol/i.test(parent.nodeName) ? index + '. ' : '- ' | |
31 | + return prefix + content | |
32 | + } | |
22 | 33 | }] |
23 | 34 | } |
35 | + | |
24 | 36 | inputEl.onkeydown = inputEl.onkeyup = debounce(function() { |
25 | 37 | var newVal = inputEl.innerHTML |
26 | 38 | if (value == newVal) return |
27 | 39 | value = newVal |
Built with git-ssb-web