summaryrefslogtreecommitdiffstats
path: root/lib/parse/renderer.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2014-07-10 17:59:34 -0700
committerSamy Pessé <samypesse@gmail.com>2014-07-10 17:59:34 -0700
commita9f473260cdbf7944a8d95c4292a93897f9210eb (patch)
tree83e78b9028850606722da6ec66c45e453ee28693 /lib/parse/renderer.js
parent520045441b9401fadfba2b1b03696bd15b60027d (diff)
parentd16577e8bf2e404cbc2cabb78fc1bf6c8a36d3ea (diff)
downloadgitbook-a9f473260cdbf7944a8d95c4292a93897f9210eb.zip
gitbook-a9f473260cdbf7944a8d95c4292a93897f9210eb.tar.gz
gitbook-a9f473260cdbf7944a8d95c4292a93897f9210eb.tar.bz2
Merge pull request #356 from GitbookIO/feature/includes
Support importing code snippets
Diffstat (limited to 'lib/parse/renderer.js')
-rw-r--r--lib/parse/renderer.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/parse/renderer.js b/lib/parse/renderer.js
index 397ab80..dcbc261 100644
--- a/lib/parse/renderer.js
+++ b/lib/parse/renderer.js
@@ -1,6 +1,7 @@
var url = require('url');
var inherits = require('util').inherits;
var links = require('../utils').links;
+var codeInclude = require('./code_include');
var path = require('path');
@@ -125,7 +126,7 @@ GitBookRenderer.prototype._createCheckboxAndRadios = function(text) {
var length = splittedText.length;
var label = '<label class="quiz-label" for="' + quizIdentifier + '">' + splittedText[length - 1] + '</label>';
return text.replace(fieldRegex, field).replace(splittedText[length - 1], label);
-}
+};
GitBookRenderer.prototype.tablecell = function(content, flags) {
return GitBookRenderer.super_.prototype.tablecell(this._createCheckboxAndRadios(content), flags);
@@ -135,5 +136,15 @@ GitBookRenderer.prototype.listitem = function(text) {
return GitBookRenderer.super_.prototype.listitem(this._createCheckboxAndRadios(text));
};
+GitBookRenderer.prototype.code = function(code, lang, escaped) {
+ return GitBookRenderer.super_.prototype.code.call(
+ this,
+ // Import code snippets
+ codeInclude(code, this._extra_options.dir),
+ lang,
+ escaped
+ );
+};
+
// Exports
module.exports = GitBookRenderer;