Permalink
Browse files

Correctly chooses the code tags to use

Fixes issue #1136, which showed that single backticks were being used for multiline code blocks when clicking the `code` button.
  • Loading branch information...
TheBrenny committed Aug 6, 2016
1 parent 7a8ba70 commit 9a964334ee597bc8e9027959c892e5a7512368ee
Showing with 10 additions and 1 deletion.
  1. +10 −1 anchor/views/assets/js/editor.js
@@ -106,7 +106,16 @@
wrap('*', '*');
},
code: function() {
wrap('`', '`');
var wrapping = '`';
var element = textarea[0];
var start = element.selectionStart, end = element.selectionEnd;
var value = element.value;
var selection = value.substring(start, end);
if(/\n+.*/gm.test(selection)) {
wrapping = '\n```\n';
}
wrap(wrapping, wrapping);
},
link: function() {
var element = textarea[0];

0 comments on commit 9a96433

Please sign in to comment.