Skip to content

Commit c7871db

Browse files
committed
fix($parser): fix jonschlinkert#92
1 parent 8a22958 commit c7871db

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,8 @@ function parseMatter(file, options) {
104104
file.empty = file.content;
105105
file.data = {};
106106
} else {
107-
108107
// create file.data by parsing the raw file.matter block
109-
file.data = parse(file.language, file.matter, opts);
108+
file.data = parse(file.language, file.matter.trim(), opts);
110109
}
111110

112111
// update file.content

test/matter-windows.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ require('mocha');
44
var assert = require('assert');
55
var utils = require('../lib/utils');
66
var matter = require('..');
7+
var toml = require('toml');
78

89
describe('gray-matter (windows carriage returns)', function() {
910
it('should extract YAML front matter', function() {
@@ -84,4 +85,17 @@ describe('gray-matter (windows carriage returns)', function() {
8485
assert.equal(actual.content, '-----------name--------------value\r\nfoo');
8586
assert.equal(String(actual.orig), '-----------name--------------value\r\nfoo');
8687
});
88+
89+
it('should parse toml front matter.', function() {
90+
var actual = matter('---toml\r\ntitle = "TOML"\r\ndescription = "Front matter"\r\ncategories = "front matter toml"\r\n---\r\n\r\n# This file has toml front matter!\r\n', {
91+
engines: {
92+
toml: toml.parse.bind(toml)
93+
}
94+
});
95+
console.log(actual);
96+
assert.equal(actual.data.title, 'TOML');
97+
assert(actual.hasOwnProperty('data'));
98+
assert(actual.hasOwnProperty('content'));
99+
assert(actual.hasOwnProperty('orig'));
100+
});
87101
});

0 commit comments

Comments
 (0)