Skip to content
Permalink
Browse files

Merge pull request #1054 from spapas/master

Small codify improvements
  • Loading branch information...
torhve committed Jul 4, 2019
2 parents 521f75c + 94ad3b8 commit 6ab4ef7d88668bfb7a985fef48b3923787f4d95b
Showing with 7 additions and 5 deletions.
  1. +2 −0 css/glowingbear.css
  2. +3 −3 js/filters.js
  3. +2 −2 test/unit/filters.js
@@ -929,4 +929,6 @@ img.emojione {

code {
padding: 0px 2px;
color: #444;
border: 1pt solid #444;
}
@@ -239,9 +239,9 @@ 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>';
var re = /`(.+?)`/g;
return text.replace(re, function(match, code) {
var rr = '<span class="hidden-bracket">`</span><code>' + code + '</code><span class="hidden-bracket">`</span>';
return rr;
});
};
@@ -99,11 +99,11 @@ describe('Filters', function() {
}));

it('should codify single snippets', inject(function(codifyFilter) {
expect(codifyFilter('z `foo` z')).toEqual('z <code>foo</code> z');
expect(codifyFilter('z `foo` z')).toEqual('z <span class="hidden-bracket">`</span><code>foo</code><span class="hidden-bracket">`</span> 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>');
expect(codifyFilter('z `foo` z `bar` `baz`')).toEqual('z <span class="hidden-bracket">`</span><code>foo</code><span class="hidden-bracket">`</span> z <span class="hidden-bracket">`</span><code>bar</code><span class="hidden-bracket">`</span> <span class="hidden-bracket">`</span><code>baz</code><span class="hidden-bracket">`</span>');
}));

it('should not codify empty snippets', inject(function(codifyFilter) {

0 comments on commit 6ab4ef7

Please sign in to comment.
You can’t perform that action at this time.