var fs = require('fs');

var colours = JSON.parse(fs.readFileSync(__dirname + '/colours.json', 'utf8'));

var defaultColour = "#ececec";

function ext(ext) {
	// Turn extension to colour
	var keys = Object.keys(colours);
	for (i=0; i<keys.length; i++) {
		var extensions = colours[keys[i]].extensions;
		try {
			for (j=0; j<extensions.length; j++) {
				if (extensions[j] == ext) {
					if (colours[keys[i]].color != undefined) {
						return colours[keys[i]].color;
					} else {
						return defaultColour;
					}
				}
			}
		} catch(err) {
			// Nothing
		}
	}
	return defaultColour;
}

function get(lang) {
	// Turn language to colour
	return colours[lang].color;
}

function lang(ext) {
	// Turn extension to language
	var keys = Object.keys(colours);
	for (i=0; i<keys.length; i++) {
		var extensions = colours[keys[i]].extensions;
		try {
			for (j=0; j<extensions.length; j++) {
				if (extensions[j] == ext) {
					return keys[i];
				}
			}
		} catch(err) {
			// Nothing
		}
	}
	return null;
}

module.exports = {
	ext: ext,
	get: get,
	lang: lang
};

console.log("== Testing ext() with '.agda' (Should Be #315665) ==");
console.log(module.exports.ext(".agda"));
console.log("== Testing get() with 'Agda' (Should Be #315665) ==");
console.log(module.exports.get("Agda"));
console.log("== Testing lang() with '.agda' (Should Be Agda) ==");
console.log(module.exports.lang(".agda"));
@@ -1058,16 +1058,19 @@
 ang%0A%7D;%0A%0A
+// 
 console.
@@ -1122,32 +1122,35 @@
  #315665) ==%22);%0A
+// 
 console.log(modu
@@ -1167,32 +1167,35 @@
 .ext(%22.agda%22));%0A
+// 
 console.log(%22== 
@@ -1238,32 +1238,35 @@
  #315665) ==%22);%0A
+// 
 console.log(modu
@@ -1290,16 +1290,19 @@
 gda%22));%0A
+// 
 console.
@@ -1360,16 +1360,19 @@
 ) ==%22);%0A
+// 
 console.

Remove debugging for extensions lib