Merge pull request #1053 from spapas/master

Add a simple codify filter
update-travis
Lorenz Hübschle-Schneider 6 years ago committed by GitHub
commit 521f75c238
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      css/glowingbear.css
  2. 2
      index.html
  3. 10
      js/filters.js
  4. 24
      test/unit/filters.js

@ -926,3 +926,7 @@ img.emojione {
[ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak {
display: none !important;
}
code {
padding: 0px 2px;
}

@ -336,7 +336,7 @@ npm run build-electron-{windows, darwin, linux}</pre>
<td class="prefix"><span ng-class="::{'repeated-prefix': bufferline.prefixtext==bufferlines[$index-1].prefixtext}"><a ng-click="addMention(bufferline)"><span class="hidden-bracket" ng-if="::(bufferline.showHiddenBrackets)">&lt;</span><span ng-repeat="part in ::bufferline.prefix" ng-class="::part.classes" ng-bind="::part.text|prefixlimit:25"></span><span class="hidden-bracket" ng-if="::(bufferline.showHiddenBrackets)">&gt;</span></a></span></td><!--
--><td class="message"><!--
--><div ng-repeat="metadata in ::bufferline.metadata" plugin data="::metadata"></div><!--
--><span ng-repeat="part in ::bufferline.content" class="text" ng-class="::part.classes.concat(['line-' + part.$$hashKey.replace(':','_')])" ng-bind-html="::part.text | conditionalLinkify:part.classes.includes('cof-chat_host') | DOMfilter:'irclinky' | DOMfilter:'emojify':settings.enableJSEmoji | DOMfilter:'inlinecolour' | DOMfilter:'latexmath':('.line-' + part.$$hashKey.replace(':','_')):settings.enableMathjax"></span>
--><span ng-repeat="part in ::bufferline.content" class="text" ng-class="::part.classes.concat(['line-' + part.$$hashKey.replace(':','_')])" ng-bind-html="::part.text | conditionalLinkify:part.classes.includes('cof-chat_host') | codify | DOMfilter:'irclinky' | DOMfilter:'emojify':settings.enableJSEmoji | DOMfilter:'inlinecolour' | DOMfilter:'latexmath':('.line-' + part.$$hashKey.replace(':','_')):settings.enableMathjax"></span>
</td>
</tr>
<tr class="readmarker" ng-if="activeBuffer().lastSeen==$index">

@ -237,4 +237,14 @@ weechat.filter('prefixlimit', function() {
};
});
weechat.filter('codify', function() {
return function(text) {
var re = /(`.+?`)/g;
return text.replace(re, function(z) {
var rr = '<code>' + z.slice(1, z.length-1) + '</code>';
return rr;
});
};
});
})();

@ -92,4 +92,28 @@ describe('Filters', function() {
// I.e. if we ever got this far, the bug is fixed.
}));
});
describe('codify', function() {
it('should not mess up text', inject(function(codifyFilter) {
expect(codifyFilter('foo')).toEqual('foo');
}));
it('should codify single snippets', inject(function(codifyFilter) {
expect(codifyFilter('z `foo` z')).toEqual('z <code>foo</code> z');
}));
it('should codify multiple snippets', inject(function(codifyFilter) {
expect(codifyFilter('z `foo` z `bar` `baz`')).toEqual('z <code>foo</code> z <code>bar</code> <code>baz</code>');
}));
it('should not codify empty snippets', inject(function(codifyFilter) {
expect(codifyFilter('``')).toEqual('``');
}));
it('should not codify single backticks', inject(function(codifyFilter) {
expect(codifyFilter('foo`bar')).toEqual('foo`bar');
}));
});
});

Loading…
Cancel
Save