summaryrefslogtreecommitdiffstats
path: root/packages/gitbook-html/lib/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'packages/gitbook-html/lib/index.js')
-rwxr-xr-xpackages/gitbook-html/lib/index.js56
1 files changed, 38 insertions, 18 deletions
diff --git a/packages/gitbook-html/lib/index.js b/packages/gitbook-html/lib/index.js
index 2658914..b6fa18c 100755
--- a/packages/gitbook-html/lib/index.js
+++ b/packages/gitbook-html/lib/index.js
@@ -1,4 +1,5 @@
-var _ = require('lodash');
+'use strict';
+
var ToText = require('./totext');
var htmlParser = {
@@ -11,22 +12,26 @@ var htmlParser = {
// Compose a function with a transform function for the first argument only
function compose(toHTML, fn) {
- return function() {
- var args = _.toArray(arguments);
- args[0] = toHTML(args[0]);
+ return function () {
+ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
+ args[_key] = arguments[_key];
+ }
- return fn.apply(null, args);
- }
+ args[0] = toHTML(args[0]);
+ return fn.apply(undefined, args);
+ };
}
-// Create a GitBook parser from an HTML converter
-function createParser(toHTML, toText) {
- if (_.isFunction(toHTML)) {
- toHTML = {
- inline: toHTML,
- block: toHTML
- };
- }
+/**
+ * Create a GitBook parser from an HTML converter.
+ * @param {Object} toHTML
+ * {Function} [toHTML.inline]
+ * {Function} [toHTML.block]
+ * @param {Object} toText
+ * @return {[type]} [description]
+ */
+function createParser(toHTML) {
+ var toText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var parser = {
summary: compose(toHTML.block, htmlParser.summary),
@@ -38,12 +43,27 @@ function createParser(toHTML, toText) {
};
var _toText = new ToText(toText);
- parser.summary.toText =_toText.summary;
- parser.langs.toText =_toText.langs;
- parser.glossary.toText =_toText.glossary;
+
+ parser.summary.toText = function (summary) {
+ return _toText.summary(summary);
+ };
+ parser.langs.toText = function (langs) {
+ return _toText.langs(langs);
+ };
+ parser.glossary.toText = function (glossary) {
+ return _toText.glossary(glossary);
+ };
return parser;
}
-module.exports = createParser(_.identity);
+module.exports = createParser({
+ block: function block(html) {
+ return html;
+ },
+ inline: function inline(html) {
+ return html;
+ }
+});
module.exports.createParser = createParser;
+//# sourceMappingURL=index.js.map \ No newline at end of file