Benjy Cui
9 years ago
13 changed files with 81 additions and 30 deletions
@ -0,0 +1,11 @@ |
|||
const path = require('path'); |
|||
const processDoc = require('./process-doc'); |
|||
const processDemo = require('./process-demo'); |
|||
|
|||
module.exports = (markdownData) => { |
|||
const isDemo = path.dirname(markdownData.meta.filename).endsWith('/demo'); |
|||
if (isDemo) { |
|||
return processDemo(markdownData); |
|||
} |
|||
return processDoc(markdownData); |
|||
}; |
@ -0,0 +1,3 @@ |
|||
module.exports = (markdownData) => { |
|||
return markdownData; |
|||
}; |
@ -0,0 +1,15 @@ |
|||
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; |
|||
}; |
Loading…
Reference in new issue