summaryrefslogtreecommitdiffhomepage
path: root/plugin
diff options
context:
space:
mode:
Diffstat (limited to 'plugin')
-rwxr-xr-xplugin/markdown/markdown.js81
-rw-r--r--plugin/notes/notes.html4
2 files changed, 50 insertions, 35 deletions
diff --git a/plugin/markdown/markdown.js b/plugin/markdown/markdown.js
index 31d22f1..c5c2358 100755
--- a/plugin/markdown/markdown.js
+++ b/plugin/markdown/markdown.js
@@ -3,7 +3,17 @@
* markdown inside of presentations as well as loading
* of external markdown documents.
*/
-(function(){
+(function( root, factory ) {
+ if( typeof exports === 'object' ) {
+ module.exports = factory( require( './marked' ) );
+ }
+ else {
+ // Browser globals (root is window)
+ root.returnExports = factory( root.marked );
+ root.returnExports.processSlides();
+ root.returnExports.convertSlides();
+ }
+}( this, function( marked ) {
if( typeof marked === 'undefined' ) {
throw 'The reveal.js Markdown plugin requires marked to be loaded';
@@ -75,12 +85,12 @@
/**
* Helper function for constructing a markdown slide.
*/
- function createMarkdownSlide( data ) {
+ function createMarkdownSlide( content, options ) {
- var content = data.content || data;
+ var notesMatch = content.split( new RegExp( options.notesSeparator, 'mgi' ) );
- if( data.notes ) {
- content += '<aside class="notes" data-markdown>' + data.notes + '</aside>';
+ if( notesMatch.length === 2 ) {
+ content = notesMatch[0] + '<aside class="notes" data-markdown>' + notesMatch[1].trim() + '</aside>';
}
return '<script type="text/template">' + content + '</script>';
@@ -91,7 +101,7 @@
* Parses a data string into multiple slides based
* on the passed in separator arguments.
*/
- function slidifyMarkdown( markdown, options ) {
+ function slidify( markdown, options ) {
options = options || {};
options.separator = options.separator || '^\n---\n$';
@@ -99,17 +109,13 @@
options.attributes = options.attributes || '';
var separatorRegex = new RegExp( options.separator + ( options.verticalSeparator ? '|' + options.verticalSeparator : '' ), 'mg' ),
- horizontalSeparatorRegex = new RegExp( options.separator ),
- notesSeparatorRegex = new RegExp( options.notesSeparator, 'mgi' );
+ horizontalSeparatorRegex = new RegExp( options.separator );
var matches,
- noteMatch,
lastIndex = 0,
isHorizontal,
wasHorizontal = true,
content,
- notes,
- slide,
sectionStack = [];
// iterate until all blocks between separators are stacked up
@@ -126,25 +132,14 @@
// pluck slide content from markdown input
content = markdown.substring( lastIndex, matches.index );
- noteMatch = content.split( notesSeparatorRegex );
-
- if( noteMatch.length === 2 ) {
- content = noteMatch[0];
- notes = noteMatch[1].trim();
- }
-
- slide = {
- content: content,
- notes: notes || ''
- };
if( isHorizontal && wasHorizontal ) {
// add to horizontal stack
- sectionStack.push( slide );
+ sectionStack.push( content );
}
else {
// add to vertical stack
- sectionStack[sectionStack.length-1].push( slide );
+ sectionStack[sectionStack.length-1].push( content );
}
lastIndex = separatorRegex.lastIndex;
@@ -160,12 +155,16 @@
for( var i = 0, len = sectionStack.length; i < len; i++ ) {
// vertical
if( sectionStack[i].propertyIsEnumerable( length ) && typeof sectionStack[i].splice === 'function' ) {
- markdownSections += '<section '+ options.attributes +'>' +
- '<section data-markdown>' + sectionStack[i].map( createMarkdownSlide ).join( '</section><section data-markdown>' ) + '</section>' +
- '</section>';
+ markdownSections += '<section '+ options.attributes +'>';
+
+ sectionStack[i].forEach( function( child ) {
+ markdownSections += '<section data-markdown>' + createMarkdownSlide( child, options ) + '</section>';
+ } );
+
+ markdownSections += '</section>';
}
else {
- markdownSections += '<section '+ options.attributes +' data-markdown>' + createMarkdownSlide( sectionStack[i] ) + '</section>';
+ markdownSections += '<section '+ options.attributes +' data-markdown>' + createMarkdownSlide( sectionStack[i], options ) + '</section>';
}
}
@@ -173,7 +172,12 @@
}
- function loadExternalMarkdown() {
+ /**
+ * Parses any current data-markdown slides, splits
+ * multi-slide markdown into separate sections and
+ * handles loading of external markdown.
+ */
+ function processSlides() {
var sections = document.querySelectorAll( '[data-markdown]'),
section;
@@ -198,7 +202,7 @@
if( xhr.readyState === 4 ) {
if ( xhr.status >= 200 && xhr.status < 300 ) {
- section.outerHTML = slidifyMarkdown( xhr.responseText, {
+ section.outerHTML = slidify( xhr.responseText, {
separator: section.getAttribute( 'data-separator' ),
verticalSeparator: section.getAttribute( 'data-vertical' ),
notesSeparator: section.getAttribute( 'data-notes' ),
@@ -230,7 +234,7 @@
}
else if( section.getAttribute( 'data-separator' ) ) {
- section.outerHTML = slidifyMarkdown( getMarkdownFromSlide( section ), {
+ section.outerHTML = slidify( getMarkdownFromSlide( section ), {
separator: section.getAttribute( 'data-separator' ),
verticalSeparator: section.getAttribute( 'data-vertical' ),
notesSeparator: section.getAttribute( 'data-notes' ),
@@ -242,7 +246,11 @@
}
- function convertMarkdownToHTML() {
+ /**
+ * Converts any current data-markdown slides in the
+ * DOM to HTML.
+ */
+ function convertSlides() {
var sections = document.querySelectorAll( '[data-markdown]');
@@ -265,7 +273,10 @@
}
- loadExternalMarkdown();
- convertMarkdownToHTML();
+ return {
+ processSlides: processSlides,
+ convertSlides: convertSlides,
+ slidify: slidify
+ };
-})();
+}));
diff --git a/plugin/notes/notes.html b/plugin/notes/notes.html
index 0ef285b..7e542e4 100644
--- a/plugin/notes/notes.html
+++ b/plugin/notes/notes.html
@@ -239,6 +239,10 @@
currentSlide.contentWindow.Reveal.addEventListener( 'fragmentshown', synchronizeMainWindow );
currentSlide.contentWindow.Reveal.addEventListener( 'fragmenthidden', synchronizeMainWindow );
+ // Reconfigure the notes window to remove needless UI
+ currentSlide.contentWindow.Reveal.configure({ controls: false, progress: false, overview: false });
+ nextSlide.contentWindow.Reveal.configure({ controls: false, progress: false, overview: false });
+
}
else {