diff --git a/bin/cli.js b/bin/cli.js
index 4122848..f25bb21 100755
--- a/bin/cli.js
+++ b/bin/cli.js
@@ -26,6 +26,7 @@ program
.option('-r, --print [filename]', 'Print')
.option('-s, --separator [separator]', 'Slide separator')
.option('-v, --verticalSeparator [vertical separator]', 'Vertical slide separator')
+ .option('-i, --scripts [list of scripts]', 'Scripts to inject into the page')
.option('--disableAutoOpen', 'Disable to automatically open your web browser')
.option('--static', 'Export static html to stdout. Save to reveal.js/index.html to' +
' match dependencies. HINT: printing does not work properly in this mode')
@@ -128,7 +129,10 @@ if (program.static) {
verticalSeparator: program.verticalSeparator,
printFile: program.print,
revealOptions: revealOptions,
- openWebBrowser: !program.disableAutoOpen
+ openWebBrowser: !program.disableAutoOpen,
+ scripts: (program.scripts || '').split(',').map(function (script) {
+ return script[0] === '/' ? script : path.resolve(process.cwd(), script);
+ })
});
}
diff --git a/bin/server.js b/bin/server.js
index 50fc98a..7bdb01c 100644
--- a/bin/server.js
+++ b/bin/server.js
@@ -28,7 +28,8 @@ var opts = {
title: 'reveal-md',
separator: '^(\r\n?|\n)---(\r\n?|\n)$',
verticalSeparator: '^(\r\n?|\n)----(\r\n?|\n)$',
- revealOptions: {}
+ revealOptions: {},
+ scripts: {}
};
var printPluginPath = path.join(serverBasePath, 'node_modules', 'reveal.js', 'plugin', 'print-pdf', 'print-pdf.js');
@@ -49,6 +50,11 @@ var fillOpts = function(options) {
opts.printMode = typeof options.printFile !== 'undefined' && options.printFile || opts.printMode;
opts.revealOptions = options.revealOptions || {};
opts.openWebBrowser = options.openWebBrowser;
+
+ opts.scripts = {};
+ options.scripts.forEach(function (script) {
+ opts.scripts[ path.basename(script) ] = script;
+ });
};
@@ -63,6 +69,7 @@ var startMarkdownServer = function(options) {
staticDir(path.join(serverBasePath, 'node_modules', 'highlight.js', 'styles', opts.highlightTheme + '.css')));
app.get(/(\w+\.md)$/, renderMarkdownAsSlides);
+ app.get('/scripts/*', getScript);
app.get('/', renderMarkdownFileListing);
app.get('/*', staticDir(opts.userBasePath));
@@ -142,6 +149,10 @@ var renderMarkdownAsSlides = function(req, res) {
}
};
+var getScript = function (req, res) {
+ res.sendFile( opts.scripts[req.url.substr( req.url.indexOf('/scripts/') + 9 )] );
+};
+
var render = function(res, markdown) {
var slides = md.slidify(markdown, opts);
@@ -150,7 +161,8 @@ var render = function(res, markdown) {
highlightTheme: opts.highlightTheme,
title: opts.title,
slides: slides,
- options: JSON.stringify(opts.revealOptions, null, 2)
+ options: JSON.stringify(opts.revealOptions, null, 2),
+ scripts: Object.keys(opts.scripts)
}));
};
diff --git a/template/reveal.html b/template/reveal.html
index 61ccb3d..ece11a9 100644
--- a/template/reveal.html
+++ b/template/reveal.html
@@ -12,6 +12,10 @@
+
+ {{#scripts}}
+
+ {{/scripts}}