Allow arbitrary metadata separator

Separator is any character sequence from start of file to first newline.

For example:
    title = "Whatever"
    # Hello
is now possible
parent 4ba9d437
......@@ -5,16 +5,15 @@ var jsesc = require('jsesc')
var readPageWorker = function(content, obj) {
if(content === undefined) throw new Error('content is undefined');
var head = content.substring(0,4)
if(head !== '+++\n')
throw new Error('Failed to parse file '+obj.filename+':\n'+
'Wrong header (expected "+++\\n" got "'+jsesc(head)+'")')
content = content.substring(4);
var fmEnd = content.indexOf('+++\n');
var headLength = content.indexOf('\n')+1;
var head = content.substring(0,headLength)
content = content.substring(headLength);
var fmEnd = content.indexOf(head);
if(fmEnd < 0) {
throw new Error('Cannot find terminating +++\n in file '+obj.filename);
throw new Error('Cannot find terminating '+
'\n in file '+obj.filename);
obj.content = content.substring(fmEnd+4);
try {
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment