mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-16 15:45:13 +00:00
ca70c934d6
Add tests for parsePageFromString
23 lines
495 B
JavaScript
23 lines
495 B
JavaScript
var Immutable = require('immutable');
|
|
var fm = require('front-matter');
|
|
var direction = require('direction');
|
|
|
|
/**
|
|
* Parse a page, its content and the YAMl header
|
|
*
|
|
* @param {Page} page
|
|
* @return {Page}
|
|
*/
|
|
function parsePageFromString(page, content) {
|
|
var parsed = fm(content);
|
|
|
|
return page.merge({
|
|
content: parsed.body,
|
|
attributes: Immutable.fromJS(parsed.attributes),
|
|
dir: direction(parsed.body)
|
|
});
|
|
}
|
|
|
|
|
|
module.exports = parsePageFromString;
|