diff options
author | Samy Pesse <samypesse@gmail.com> | 2016-04-30 22:06:16 +0200 |
---|---|---|
committer | Samy Pesse <samypesse@gmail.com> | 2016-04-30 22:06:16 +0200 |
commit | c1d53ec11fbe085932df911bda5686b7bf671f53 (patch) | |
tree | 97ae6db641eb79ec9b061af136a0b2e3c549db55 /lib/parse | |
parent | 36b49c66c6b75515bc84dd678fd52121a313e8d2 (diff) | |
download | gitbook-c1d53ec11fbe085932df911bda5686b7bf671f53.zip gitbook-c1d53ec11fbe085932df911bda5686b7bf671f53.tar.gz gitbook-c1d53ec11fbe085932df911bda5686b7bf671f53.tar.bz2 |
Switch parsers to a model
Diffstat (limited to 'lib/parse')
-rw-r--r-- | lib/parse/parseStructureFile.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/parse/parseStructureFile.js b/lib/parse/parseStructureFile.js index bdb97db..fe8c935 100644 --- a/lib/parse/parseStructureFile.js +++ b/lib/parse/parseStructureFile.js @@ -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 ]; }); } |