You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
551 B
16 lines
551 B
9 years ago
|
const JsonML = require('jsonml.js/lib/utils');
|
||
|
|
||
|
module.exports = (markdownData) => {
|
||
|
const contentChildren = JsonML.getChildren(markdownData.content);
|
||
|
const apiStartIndex = contentChildren.findIndex((node) => {
|
||
|
return JsonML.getTagName(node) === 'h2' &&
|
||
|
JsonML.getChildren(node)[0] === 'API';
|
||
|
});
|
||
|
const content = contentChildren.slice(0, apiStartIndex);
|
||
|
const api = contentChildren.slice(apiStartIndex);
|
||
|
|
||
|
markdownData.content = ['section'].concat(content);
|
||
|
markdownData.api = ['section'].concat(api);
|
||
|
return markdownData;
|
||
|
};
|