markdown plugin can now process slides that are added at runtime

edit
Hakim El Hattab 2013-09-06 08:40:43 -04:00
parent ef9168c7c4
commit c453bc4770
1 changed files with 25 additions and 10 deletions

View File

@ -9,9 +9,8 @@
} }
else { else {
// Browser globals (root is window) // Browser globals (root is window)
root.returnExports = factory( root.marked ); root.RevealMarkdown = factory( root.marked );
root.returnExports.processSlides(); root.RevealMarkdown.initialize();
root.returnExports.convertSlides();
} }
}( this, function( marked ) { }( this, function( marked ) {
@ -281,25 +280,41 @@
var section = sections[i]; var section = sections[i];
var notes = section.querySelector( 'aside.notes' ); // Only parse the same slide once
var markdown = getMarkdownFromSlide( section ); if( !section.getAttribute( 'data-markdown-parsed' ) ) {
section.innerHTML = marked( markdown ); section.setAttribute( 'data-markdown-parsed', true )
var notes = section.querySelector( 'aside.notes' );
var markdown = getMarkdownFromSlide( section );
section.innerHTML = marked( markdown );
// If there were notes, we need to re-add them after
// having overwritten the section's HTML
if( notes ) {
section.appendChild( notes );
}
// If there were notes, we need to re-add them after
// having overwritten the section's HTML
if( notes ) {
section.appendChild( notes );
} }
} }
} }
// API
return { return {
initialize: function() {
processSlides();
convertSlides();
},
// TODO: Do these belong in the API?
processSlides: processSlides, processSlides: processSlides,
convertSlides: convertSlides, convertSlides: convertSlides,
slidify: slidify slidify: slidify
}; };
})); }));