codify: also match triple backticks

fixes issues with people using ```large code-blocks inline```
update-travis
Lorenz Hübschle-Schneider 6 years ago
parent fd40cc1593
commit f10a97659d
  1. 11
      js/filters.js

@ -239,9 +239,14 @@ weechat.filter('prefixlimit', function() {
weechat.filter('codify', function() { weechat.filter('codify', function() {
return function(text) { return function(text) {
var re = /(^|\s)`(.+?)`/g; // The groups of this regex are:
return text.replace(re, function(match, ws, code) { // 1. Start of line or space, to prevent codifying weird`stuff` like this
var rr = ws + '<span class="hidden-bracket">`</span><code>' + code + '</code><span class="hidden-bracket">`</span>'; // 2. Opening single or triple backticks (not 2, not more than 3)
// 3. The code block, does not start with another backtick, non-greedy expansion
// 4. The closing backticks, identical to group 2
var re = /(^|\s)(```|`)([^`].*?)\2/g;
return text.replace(re, function(match, ws, open, code) {
var rr = ws + '<span class="hidden-bracket">' + open + '</span><code>' + code + '</code><span class="hidden-bracket">' + open + '</span>';
return rr; return rr;
}); });
}; };

Loading…
Cancel
Save