mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-22 02:23:30 +00:00
Switch parsers to a model
This commit is contained in:
@@ -24,9 +24,22 @@ function parseFile(fs, file, type) {
|
||||
|
||||
return fs.readAsString(filepath)
|
||||
.then(function(content) {
|
||||
if (type === 'readme') {
|
||||
return parser.parseReadme(content);
|
||||
} else if (type === 'glossary') {
|
||||
return parser.parseGlossary(content);
|
||||
} else if (type === 'summary') {
|
||||
return parser.parseSummary(content);
|
||||
} else if (type === 'langs') {
|
||||
return parser.parseLanguages(content);
|
||||
} else {
|
||||
throw new Error('Parsing invalid type "' + type + '"');
|
||||
}
|
||||
})
|
||||
.then(function(result) {
|
||||
return [
|
||||
file,
|
||||
parser[type](content)
|
||||
result
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user