summaryrefslogtreecommitdiffstats
path: root/packages/gitbook-html/lib
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-03-18 10:20:56 +0100
committerSamy Pessé <samypesse@gmail.com>2016-12-22 12:32:16 +0100
commitb1776fbf8b54430f103372864b0fc4ccef15db6d (patch)
tree3d125053242404aa8126a7a5d438addfe54d07fa /packages/gitbook-html/lib
parent7f06926a3bc159e8073fd6a93e8b3b84aef8b390 (diff)
downloadgitbook-b1776fbf8b54430f103372864b0fc4ccef15db6d.zip
gitbook-b1776fbf8b54430f103372864b0fc4ccef15db6d.tar.gz
gitbook-b1776fbf8b54430f103372864b0fc4ccef15db6d.tar.bz2
Add support for inline renderer
Diffstat (limited to 'packages/gitbook-html/lib')
-rwxr-xr-xpackages/gitbook-html/lib/index.js22
-rwxr-xr-xpackages/gitbook-html/lib/page.js2
2 files changed, 16 insertions, 8 deletions
diff --git a/packages/gitbook-html/lib/index.js b/packages/gitbook-html/lib/index.js
index 1c2b0e0..2658914 100755
--- a/packages/gitbook-html/lib/index.js
+++ b/packages/gitbook-html/lib/index.js
@@ -9,7 +9,7 @@ var htmlParser = {
page: require('./page')
};
-// Compose a function with a transform function for the first args
+// Compose a function with a transform function for the first argument only
function compose(toHTML, fn) {
return function() {
var args = _.toArray(arguments);
@@ -19,14 +19,22 @@ function compose(toHTML, fn) {
}
}
-// Create a GitBook parser
+// Create a GitBook parser from an HTML converter
function createParser(toHTML, toText) {
+ if (_.isFunction(toHTML)) {
+ toHTML = {
+ inline: toHTML,
+ block: toHTML
+ };
+ }
+
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)
+ summary: compose(toHTML.block, htmlParser.summary),
+ glossary: compose(toHTML.block, htmlParser.glossary),
+ langs: compose(toHTML.block, htmlParser.langs),
+ readme: compose(toHTML.block, htmlParser.readme),
+ page: compose(toHTML.block, htmlParser.page),
+ inline: compose(toHTML.inline, htmlParser.page)
};
var _toText = new ToText(toText);
diff --git a/packages/gitbook-html/lib/page.js b/packages/gitbook-html/lib/page.js
index 6f056fc..ae8923e 100755
--- a/packages/gitbook-html/lib/page.js
+++ b/packages/gitbook-html/lib/page.js
@@ -1,7 +1,7 @@
var Q = require('q');
var _ = require('lodash');
-// HTML -> HTML
+// HTML -> Page
function parsePage(html) {
return {
content: html