diff --git a/css/themes/dark.css b/css/themes/dark.css index c03e47a..da260c8 100644 --- a/css/themes/dark.css +++ b/css/themes/dark.css @@ -2114,6 +2114,11 @@ button.close:hover { font-weight: bold; } +code { + background-color: #444; + color: #fff; +} + /* */ /* Mobile layout */ /* */ diff --git a/index.html b/index.html index 92c7594..3e6ba8f 100644 --- a/index.html +++ b/index.html @@ -336,7 +336,7 @@ npm run build-electron-{windows, darwin, linux}
' + code + '
`';
+ // The groups of this regex are:
+ // 1. Start of line or space, to prevent codifying weird`stuff` like this
+ // 2. Opening single or triple backticks (not 2, not more than 3)
+ // 3. The code block, does not start with another backtick, non-greedy expansion
+ // 4. The closing backticks, identical to group 2
+ var re = /(^|\s)(```|`)([^`].*?)\2/g;
+ return text.replace(re, function(match, ws, open, code) {
+ var rr = ws + '' + open + '' + code + '
' + open + '';
return rr;
});
};
diff --git a/test/unit/filters.js b/test/unit/filters.js
index 404fc57..ebd6e39 100644
--- a/test/unit/filters.js
+++ b/test/unit/filters.js
@@ -100,6 +100,8 @@ describe('Filters', function() {
it('should codify single snippets', inject(function(codifyFilter) {
expect(codifyFilter('z `foo` z')).toEqual('z `foo
` z');
+ expect(codifyFilter('z `a` z')).toEqual('z `a
` z');
+ expect(codifyFilter('z ```foo``` z')).toEqual('z ```foo
``` z');
}));
it('should codify multiple snippets', inject(function(codifyFilter) {
@@ -114,6 +116,21 @@ describe('Filters', function() {
expect(codifyFilter('foo`bar')).toEqual('foo`bar');
}));
+
+ it('should not codify double backticks', inject(function(codifyFilter) {
+ expect(codifyFilter('some ``non-code``')).toEqual('some ``non-code``');
+ }));
+
+
+ it('should not codify pseudo-fancy quotes', inject(function(codifyFilter) {
+ expect(codifyFilter('some ``fancy qoutes\'\'')).toEqual('some ``fancy qoutes\'\'');
+ }));
+
+ it('should not codify stuff in the middle of a word or URL', inject(function(codifyFilter) {
+ expect(codifyFilter('https://foo.bar/`wat`')).toEqual('https://foo.bar/`wat`');
+ expect(codifyFilter('Weird`ness`')).toEqual('Weird`ness`');
+ }));
+
});
});