diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-02-19 16:12:43 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-12-22 12:32:14 +0100 |
commit | 4c44d677117d926b6dcc164f55fe34079c2ca3c7 (patch) | |
tree | 71d0fca56421f3a7b68d60a446f89d3735828f03 /packages/gitbook-html/lib/index.js | |
parent | 9e99b5850fd866fc2f9196993a0ae7e342311558 (diff) | |
download | gitbook-4c44d677117d926b6dcc164f55fe34079c2ca3c7.zip gitbook-4c44d677117d926b6dcc164f55fe34079c2ca3c7.tar.gz gitbook-4c44d677117d926b6dcc164f55fe34079c2ca3c7.tar.bz2 |
Improve summary parser
Diffstat (limited to 'packages/gitbook-html/lib/index.js')
-rwxr-xr-x | packages/gitbook-html/lib/index.js | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/packages/gitbook-html/lib/index.js b/packages/gitbook-html/lib/index.js index a7c478c..0e67c94 100755 --- a/packages/gitbook-html/lib/index.js +++ b/packages/gitbook-html/lib/index.js @@ -1,8 +1,33 @@ +var _ = require('lodash'); -module.exports = { +var htmlParser = { 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 +function compose(toHTML, fn) { + return function() { + var args = _.toArray(arguments); + args[0] = toHTML(args[0]); + + return fn.apply(null, args); + } +} + +// Create a GitBook parser +function createParser(toHTML) { + return { + 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) + } +} + +module.exports = htmlParser; +module.exports.createParser = createParser; |