diff --git a/css/options.css b/css/options.css index bbf3f42..9fa666f 100644 --- a/css/options.css +++ b/css/options.css @@ -12,6 +12,10 @@ select { margin-bottom: 10px; } +textarea { + margin-bottom: 10px; +} + pre { left: -10px; top: 10px; diff --git a/js/background.js b/js/background.js index 6192283..92bc039 100644 --- a/js/background.js +++ b/js/background.js @@ -77,7 +77,8 @@ theme: 'sunburst', font: 'Inconsolata', fontSize: 'medium', - lineNumbers: true + lineNumbers: true, + ignoreLanguages: '' }; const OPTIONS = Object.keys(OPTIONS_DEFAULTS); @@ -121,6 +122,17 @@ return filename.split('.').pop(); } + function isLanguageIgnored(language) { + var ignored = localStorage.getItem('ignoreLanguages').split(/[\s,]+/); + var index, length = ignored.length; + for (index = 0; index < length; index++) { + if (ignored[index].toLowerCase() === language) { + return true; + } + } + return false; + } + function getFragmentFromUrl(url) { var fragment = /#ft=(\w+)/.exec(url); return fragment && fragment[1]; @@ -156,7 +168,7 @@ var filename = getFilenameFromUrl(details.url); var extension = getExtensionFromFilename(filename); var language = detectLanguage(contentType, fragment, filename, extension); - if (!language) { + if (!language || isLanguageIgnored(language)) { return; } diff --git a/js/options.js b/js/options.js index d5272ec..5dd2f94 100644 --- a/js/options.js +++ b/js/options.js @@ -2,6 +2,7 @@ function id(a) { return a } function eq(b) { return function(a) { return a === b } } function val(obj, key) { return obj[key] } + function noop() {} function set(sel, path, fn) { var parts = path.split('.'); var target = parts[parts.length-1]; @@ -43,6 +44,12 @@ codeEl.innerHTML = codeEl.textContent; hljs.highlightBlock(codeEl); } + }, + ignoreLanguages: { + selector: '#ignore-languages', + value: 'value', + decode: id, + render: noop } }; diff --git a/options.html b/options.html index d1b00fc..77b7bf4 100644 --- a/options.html +++ b/options.html @@ -91,6 +91,8 @@

Select your font size

+

Ignore Languages

+

Line numbers:

 package main