diff --git a/css/glowingbear.css b/css/glowingbear.css index bee10d0..65a89b8 100644 --- a/css/glowingbear.css +++ b/css/glowingbear.css @@ -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; +} \ No newline at end of file diff --git a/index.html b/index.html index 17d51a0..92c7594 100644 --- a/index.html +++ b/index.html @@ -336,7 +336,7 @@ npm run build-electron-{windows, darwin, linux} <>
+ --> diff --git a/js/filters.js b/js/filters.js index 272f61a..9e5db35 100644 --- a/js/filters.js +++ b/js/filters.js @@ -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 = '' + z.slice(1, z.length-1) + ''; + return rr; + }); + }; +}); + })(); diff --git a/test/unit/filters.js b/test/unit/filters.js index 2b1358f..74c402d 100644 --- a/test/unit/filters.js +++ b/test/unit/filters.js @@ -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 foo z'); + })); + + it('should codify multiple snippets', inject(function(codifyFilter) { + expect(codifyFilter('z `foo` z `bar` `baz`')).toEqual('z foo z bar baz'); + })); + + 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'); + })); + + + }); });