summaryrefslogtreecommitdiffstats
path: root/lib/parse/parsePage.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-06-07 12:31:21 +0200
committerSamy Pessé <samypesse@gmail.com>2016-06-07 12:31:21 +0200
commitca70c934d6a92f12e0f826cd3f6f32d562f66b2f (patch)
treed28e83efdca7983d128a59b603aee47314243c1b /lib/parse/parsePage.js
parent1cc48fa314782312883af00cf64a56929b62f057 (diff)
downloadgitbook-ca70c934d6a92f12e0f826cd3f6f32d562f66b2f.zip
gitbook-ca70c934d6a92f12e0f826cd3f6f32d562f66b2f.tar.gz
gitbook-ca70c934d6a92f12e0f826cd3f6f32d562f66b2f.tar.bz2
Split page parsing into parsePageFromString and parsePage
Add tests for parsePageFromString
Diffstat (limited to 'lib/parse/parsePage.js')
-rw-r--r--lib/parse/parsePage.js24
1 files changed, 8 insertions, 16 deletions
diff --git a/lib/parse/parsePage.js b/lib/parse/parsePage.js
index 1d515d6..fdc56a3 100644
--- a/lib/parse/parsePage.js
+++ b/lib/parse/parsePage.js
@@ -1,27 +1,19 @@
-var Immutable = require('immutable');
-var fm = require('front-matter');
-var direction = require('direction');
+var parsePageFromString = require('./parsePageFromString');
/**
- Parse a page, read its content and parse the YAMl header
-
- @param {Book} book
- @param {Page} page
- @return {Promise<Page>}
-*/
+ * Parse a page, read its content and parse the YAMl header
+ *
+ * @param {Book} book
+ * @param {Page} page
+ * @return {Promise<Page>}
+ */
function parsePage(book, page) {
var fs = book.getContentFS();
var file = page.getFile();
return fs.readAsString(file.getPath())
.then(function(content) {
- var parsed = fm(content);
-
- return page.merge({
- content: parsed.body,
- attributes: Immutable.fromJS(parsed.attributes),
- dir: direction(parsed.body)
- });
+ return parsePageFromString(page, content);
});
}