diff options
Diffstat (limited to 'packages/gitbook-html/lib/index.js')
-rwxr-xr-x | packages/gitbook-html/lib/index.js | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/packages/gitbook-html/lib/index.js b/packages/gitbook-html/lib/index.js index 0e67c94..1c2b0e0 100755 --- a/packages/gitbook-html/lib/index.js +++ b/packages/gitbook-html/lib/index.js @@ -1,11 +1,12 @@ var _ = require('lodash'); +var ToText = require('./totext'); var htmlParser = { - summary: require("./summary"), - glossary: require("./glossary"), - langs: require("./langs"), - readme: require("./readme"), - page: require("./page") + summary: require('./summary'), + glossary: require('./glossary'), + langs: require('./langs'), + readme: require('./readme'), + page: require('./page') }; // Compose a function with a transform function for the first args @@ -19,15 +20,22 @@ function compose(toHTML, fn) { } // Create a GitBook parser -function createParser(toHTML) { - return { +function createParser(toHTML, toText) { + var parser = { summary: compose(toHTML, htmlParser.summary), glossary: compose(toHTML, htmlParser.glossary), langs: compose(toHTML, htmlParser.langs), readme: compose(toHTML, htmlParser.readme), page: compose(toHTML, htmlParser.page) - } + }; + + var _toText = new ToText(toText); + parser.summary.toText =_toText.summary; + parser.langs.toText =_toText.langs; + parser.glossary.toText =_toText.glossary; + + return parser; } -module.exports = htmlParser; +module.exports = createParser(_.identity); module.exports.createParser = createParser; |