Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Commit

Permalink
Correctly chooses the code tags to use
Browse files Browse the repository at this point in the history
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 9a96433
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion anchor/views/assets/js/editor.js
Expand Up @@ -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];
Expand Down

0 comments on commit 9a96433

Please sign in to comment.