front-matter
Advanced tools
Comparing version 2.0.2 to 2.0.3
@@ -7,3 +7,3 @@ # Hello World | ||
Some text here that is definitely not fromt matter. | ||
Some text here that is definitely not front matter. | ||
@@ -10,0 +10,0 @@ --- |
@@ -11,2 +11,4 @@ var parser = require('js-yaml') | ||
+ '(?:\\n)?)' | ||
// NOTE: If this pattern uses the 'g' flag the `regex` variable definition will | ||
// need to be moved down into the functions that use it. | ||
var regex = new RegExp(pattern, 'm') | ||
@@ -30,2 +32,9 @@ | ||
var match = regex.exec(string) | ||
if (! match) { | ||
return { | ||
body: string | ||
} | ||
} | ||
var yaml = match[match.length - 1].replace(/^\s+|\s+$/g, '') | ||
@@ -32,0 +41,0 @@ var attributes = parser.load(yaml) || {} |
@@ -11,3 +11,3 @@ { | ||
"license": "MIT", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"homepage": "https://github.com/jxson/front-matter", | ||
@@ -27,5 +27,5 @@ "bugs": "https://github.com/jxson/front-matter/issues", | ||
"devDependencies": { | ||
"coveralls": "^2.11.2", | ||
"coveralls": "^2.11.6", | ||
"istanbul": "^0.3.6", | ||
"tape": "^3.5.0" | ||
"tape": "^4.4.0" | ||
}, | ||
@@ -32,0 +32,0 @@ "contributors": [ |
@@ -144,2 +144,34 @@ var fm = require('../') | ||
test('Supports live updating', function(t) { | ||
var seperator = '---' | ||
var string = '' | ||
for (var i = 0; i < seperator.length; i++) { | ||
string += seperator[i] | ||
try { | ||
fm(string) | ||
} catch (e) { | ||
t.error(e) | ||
} | ||
} | ||
string += '\n' | ||
string += 'foo: bar' | ||
var content = fm(string) | ||
t.same(content, { | ||
body: string | ||
}) | ||
string += '\n---\n' | ||
content = fm(string) | ||
t.same(content, { | ||
attributes: { foo: 'bar' }, | ||
body: '' | ||
}) | ||
t.end() | ||
}) | ||
function read(file, callback){ | ||
@@ -146,0 +178,0 @@ var dir = path.resolve(__dirname, '../examples') |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16263
16
183