diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-02-20 15:30:27 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-12-22 12:32:14 +0100 |
commit | c1c17a273ae45c653a0c7d2cc64fabbb5b42e224 (patch) | |
tree | 526eff188d5799762191b46d2dfb8009b6c57398 /packages/gitbook-html/lib/index.js | |
parent | 21fe8961d7ac91a49c49c28052fc2de4f251f409 (diff) | |
download | gitbook-c1c17a273ae45c653a0c7d2cc64fabbb5b42e224.zip gitbook-c1c17a273ae45c653a0c7d2cc64fabbb5b42e224.tar.gz gitbook-c1c17a273ae45c653a0c7d2cc64fabbb5b42e224.tar.bz2 |
Improve gitbook -> text
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; |