diff options
author | Aaron O'Mullan <aaron.omullan@friendco.de> | 2014-07-10 14:27:34 +0200 |
---|---|---|
committer | Aaron O'Mullan <aaron.omullan@friendco.de> | 2014-07-11 01:22:07 +0200 |
commit | 925a9b1388dbe0f3495ddfca228bfd8508ef54ef (patch) | |
tree | 7a0b89da98b6e85e9eeb3fe114560e6a2bce2235 /lib/parse/renderer.js | |
parent | 520045441b9401fadfba2b1b03696bd15b60027d (diff) | |
download | gitbook-925a9b1388dbe0f3495ddfca228bfd8508ef54ef.zip gitbook-925a9b1388dbe0f3495ddfca228bfd8508ef54ef.tar.gz gitbook-925a9b1388dbe0f3495ddfca228bfd8508ef54ef.tar.bz2 |
Support importing code snippets
Allowing to keep code in separate files, which can be cleaner in a
quite a few scenarios
Diffstat (limited to 'lib/parse/renderer.js')
-rw-r--r-- | lib/parse/renderer.js | 13 |
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; |