diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-06-07 12:31:21 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-06-07 12:31:21 +0200 |
commit | ca70c934d6a92f12e0f826cd3f6f32d562f66b2f (patch) | |
tree | d28e83efdca7983d128a59b603aee47314243c1b /lib/parse/parsePage.js | |
parent | 1cc48fa314782312883af00cf64a56929b62f057 (diff) | |
download | gitbook-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.js | 24 |
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); }); } |