From 29c6cc1e8269e5847f62db61a0ced152152fe649 Mon Sep 17 00:00:00 2001 From: Serafeim Papastefanos Date: Wed, 3 Jul 2019 10:01:05 +0300 Subject: [PATCH 1/5] Add a simple codify filter --- index.html | 2 +- js/filters.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 17d51a0..bd587f5 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..d261c09 100644 --- a/js/filters.js +++ b/js/filters.js @@ -237,4 +237,15 @@ 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; + }) + }; +}); + })(); From aaa49b7f5bb2894d6c33888bdd06b3f4b8f36a7d Mon Sep 17 00:00:00 2001 From: Serafeim Papastefanos Date: Wed, 3 Jul 2019 10:11:18 +0300 Subject: [PATCH 2/5] Add test for codify filter --- test/unit/filters.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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'); + })); + + + }); }); From 8067e3973e4bd58f245de836056eba98d83c2258 Mon Sep 17 00:00:00 2001 From: Serafeim Papastefanos Date: Wed, 3 Jul 2019 10:20:14 +0300 Subject: [PATCH 3/5] Fix linting errors --- js/filters.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/filters.js b/js/filters.js index d261c09..8383769 100644 --- a/js/filters.js +++ b/js/filters.js @@ -239,12 +239,12 @@ weechat.filter('prefixlimit', function() { weechat.filter('codify', function() { return function(text) { - var re = /(`[^``]+`)/g + var re = /(`[^``]+`)/g; return text.replace(re, function(z) { var rr = '' + z.slice(1, z.length-1) + ''; return rr; - }) + }); }; }); From 9ff05110cb3c47d61c7a0455f808e18a72b14786 Mon Sep 17 00:00:00 2001 From: Serafeim Papastefanos Date: Wed, 3 Jul 2019 13:56:46 +0300 Subject: [PATCH 4/5] Improve inline code disply for multiline text... By removing y-padding --- css/glowingbear.css | 4 ++++ 1 file changed, 4 insertions(+) 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 From 98cebb5b33d94294fc555ce8e4b07f8f41d2c76d Mon Sep 17 00:00:00 2001 From: Serafeim Papastefanos Date: Thu, 4 Jul 2019 08:45:13 +0300 Subject: [PATCH 5/5] Improve behavior with links --- index.html | 2 +- js/filters.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index bd587f5..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 8383769..9e5db35 100644 --- a/js/filters.js +++ b/js/filters.js @@ -239,8 +239,7 @@ weechat.filter('prefixlimit', function() { weechat.filter('codify', function() { return function(text) { - var re = /(`[^``]+`)/g; - + var re = /(`.+?`)/g; return text.replace(re, function(z) { var rr = '' + z.slice(1, z.length-1) + ''; return rr;