Merge pull request #1054 from spapas/master

Small codify improvements
This commit is contained in:
Tor Hveem 2019-07-04 14:21:29 +02:00 committed by GitHub
commit 6ab4ef7d88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 5 deletions

View File

@ -929,4 +929,6 @@ img.emojione {
code {
padding: 0px 2px;
color: #444;
border: 1pt solid #444;
}

View File

@ -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;
});
};

View File

@ -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) {