summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/models/__tests__/page.js2
-rw-r--r--lib/models/page.js5
-rw-r--r--lib/parse/parsePageFromString.js10
-rw-r--r--package.json3
4 files changed, 11 insertions, 9 deletions
diff --git a/lib/models/__tests__/page.js b/lib/models/__tests__/page.js
index 15a13ad..e75f8a8 100644
--- a/lib/models/__tests__/page.js
+++ b/lib/models/__tests__/page.js
@@ -20,7 +20,7 @@ describe('Page', function() {
})
});
- expect(page.toText()).toBe('---\nhello: world\n---\nHello World\n');
+ expect(page.toText()).toBe('---\nhello: world\n---\nHello World');
});
});
});
diff --git a/lib/models/page.js b/lib/models/page.js
index 3f54f43..43a2c1f 100644
--- a/lib/models/page.js
+++ b/lib/models/page.js
@@ -1,5 +1,5 @@
var Immutable = require('immutable');
-var matter = require('gray-matter');
+var yaml = require('js-yaml');;
var File = require('./file');
@@ -44,7 +44,8 @@ Page.prototype.toText = function() {
return content;
}
- return matter.stringify(content, attrs.toJS());
+ var frontMatter = '---\n' + yaml.safeDump(attrs.toJS(), { skipInvalid: true }) + '---\n';
+ return (frontMatter + content);
};
/**
diff --git a/lib/parse/parsePageFromString.js b/lib/parse/parsePageFromString.js
index 2e0c48c..80c147b 100644
--- a/lib/parse/parsePageFromString.js
+++ b/lib/parse/parsePageFromString.js
@@ -1,5 +1,5 @@
var Immutable = require('immutable');
-var matter = require('gray-matter');
+var fm = require('front-matter');
var direction = require('direction');
/**
@@ -9,12 +9,12 @@ var direction = require('direction');
* @return {Page}
*/
function parsePageFromString(page, content) {
- var parsed = matter(content);
+ var parsed = fm(content);
return page.merge({
- content: parsed.content,
- attributes: Immutable.fromJS(parsed.data),
- dir: direction(parsed.content)
+ content: parsed.body,
+ attributes: Immutable.fromJS(parsed.attributes),
+ dir: direction(parsed.body)
});
}
diff --git a/package.json b/package.json
index 3681745..6a66659 100644
--- a/package.json
+++ b/package.json
@@ -20,6 +20,7 @@
"escape-string-regexp": "1.0.5",
"extend": "^3.0.0",
"fresh-require": "1.0.3",
+ "front-matter": "^2.1.0",
"gitbook-asciidoc": "1.2.1",
"gitbook-markdown": "1.3.1",
"gitbook-plugin-fontsettings": "2.0.0",
@@ -31,11 +32,11 @@
"gitbook-plugin-theme-default": "1.0.4",
"github-slugid": "1.0.1",
"graceful-fs": "4.1.4",
- "gray-matter": "^2.0.2",
"i18n-t": "1.0.1",
"ignore": "3.1.2",
"immutable": "^3.8.1",
"is": "^3.1.0",
+ "js-yaml": "^3.6.1",
"json-schema-defaults": "0.1.1",
"jsonschema": "1.1.0",
"juice": "2.0.0",