var fs = require('fs');
var dictionary = {};

var trim = function(string) {
	return string.replace(/^\s+|\s+$/g, '');
};

var hasParser = function(key) {
	return !!dictionary[key];
};

var getParser = function(key) {
	return dictionary[key];
};

var parseContents = function(buffer, page, callback) {
	var array = buffer.toString().split(/---+\n/);
	for (var i = 0; i < array.length; i++) {
		var matches = array[i].match(/^([^:]+)\:[\s]*([\s\S]+)/);
		if (matches && matches.length == 3) {
			var key = matches[1];
			var value = trim(matches[2]);
			// If there is a parser registered for this
			// property, have it take care of things.
			// Otherwise store the value directly on the
			// data property of the page.
			if (hasParser(key)) {
				getParser(key)(value, page);
			} else {
				page.data[key] = value;
			}
		}
	}
};

var readIfExists = function(file, callback) {
	fs.stat(file, function(err, stats) {
		if (stats) {
			fs.readFile(file, function(err, buffer) {
				callback(null, buffer);
			});
		} else {
			callback(new Error('File not found: ' + file));
		}
	});
};

var parsers = {
	parse: function(file, page, callback) {
		readIfExists(file, function(err, buffer) {
			if (!err)
				parseContents(buffer, page, callback);
		});
	},

	register: function(name, parse) {
		dictionary[name] = parse;
	}
};

parsers.register('type', function(type, page) {
	page.data.type = type;
	page.site.addType(type);
});

var Cromag = require('Cromag');
parsers.register('date', function(dateString, page) {
	if (!dateString)
		return;
	var ms = Cromag.parse(dateString, 'dd/MM/y');
	page.data.ms = ms;
	page.data.date = new Cromag(ms);
});

module.exports = parsers;
@@ -1429,40 +1429,8 @@
 );%0A%0A
-var Cromag = require('Cromag');%0A
 pars
@@ -1459,21 +1459,17 @@
 unction(
-dateS
+s
 tring, p
@@ -1480,79 +1480,92 @@
  %7B%0A%09
-if (!dateString)%0A%09%09return;%0A%09var ms = Cromag.parse(dateString, 'dd/MM/y'
+var parts = string.split('/'),%0A%09%09date = new Date(+parts%5B2%5D, +parts%5B0%5D - 1, +parts%5B1%5D
 );%0A%09
@@ -1578,15 +1578,19 @@
 ata.
-ms = ms
+date = date
 ;%0A%09p
@@ -1606,25 +1606,21 @@
 date
- = new Cromag(ms)
+Text = string
 ;%0A%7D)

Remove Cromag dependency.