diff options
Diffstat (limited to 'plugin')
-rwxr-xr-x | plugin/markdown/markdown.js | 3 | ||||
-rwxr-xr-x | plugin/math/math.js | 2 | ||||
-rw-r--r-- | plugin/notes/notes.js | 29 | ||||
-rw-r--r-- | plugin/print-pdf/print-pdf.js | 50 |
4 files changed, 55 insertions, 29 deletions
diff --git a/plugin/markdown/markdown.js b/plugin/markdown/markdown.js index 29aabf5..d9ff1ba 100755 --- a/plugin/markdown/markdown.js +++ b/plugin/markdown/markdown.js @@ -31,7 +31,8 @@ */ function getMarkdownFromSlide( section ) { - var template = section.querySelector( 'script' ); + // look for a <script> or <textarea data-template> wrapper + var template = section.querySelector( '[data-template]' ) || section.querySelector( 'script' ); // strip leading whitespace so it isn't evaluated as code var text = ( template || section ).textContent; diff --git a/plugin/math/math.js b/plugin/math/math.js index c0a691d..e3b4089 100755 --- a/plugin/math/math.js +++ b/plugin/math/math.js @@ -7,7 +7,7 @@ var RevealMath = window.RevealMath || (function(){ var options = Reveal.getConfig().math || {}; - options.mathjax = options.mathjax || 'https://cdn.mathjax.org/mathjax/latest/MathJax.js'; + options.mathjax = options.mathjax || 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js'; options.config = options.config || 'TeX-AMS_HTML-full'; loadScript( options.mathjax + '?config=' + options.config, function() { diff --git a/plugin/notes/notes.js b/plugin/notes/notes.js index 46bf5de..44efe15 100644 --- a/plugin/notes/notes.js +++ b/plugin/notes/notes.js @@ -50,10 +50,11 @@ var RevealNotes = (function() { /** * Posts the current slide data to the notes window */ - function post(event) { + function post( event ) { var slideElement = Reveal.getCurrentSlide(), - notesElement = slideElement.querySelector( 'aside.notes' ); + notesElement = slideElement.querySelector( 'aside.notes' ), + fragmentElement = slideElement.querySelector( '.current-fragment' ); var messageData = { namespace: 'reveal-notes', @@ -64,21 +65,27 @@ var RevealNotes = (function() { state: Reveal.getState() }; - // Look for notes defined in a fragment, if it is a fragmentshown event - if (event && event.hasOwnProperty('fragment')) { - var innerNotes = event.fragment.querySelector( 'aside.notes' ); - - if ( innerNotes) { - notesElement = innerNotes; - } - } - // Look for notes defined in a slide attribute if( slideElement.hasAttribute( 'data-notes' ) ) { messageData.notes = slideElement.getAttribute( 'data-notes' ); messageData.whitespace = 'pre-wrap'; } + // Look for notes defined in a fragment + if( fragmentElement ) { + var fragmentNotes = fragmentElement.querySelector( 'aside.notes' ); + if( fragmentNotes ) { + notesElement = fragmentNotes; + } + else if( fragmentElement.hasAttribute( 'data-notes' ) ) { + messageData.notes = fragmentElement.getAttribute( 'data-notes' ); + messageData.whitespace = 'pre-wrap'; + + // In case there are slide notes + notesElement = null; + } + } + // Look for notes defined in an aside element if( notesElement ) { messageData.notes = notesElement.innerHTML; diff --git a/plugin/print-pdf/print-pdf.js b/plugin/print-pdf/print-pdf.js index c3c5d94..9ffc261 100644 --- a/plugin/print-pdf/print-pdf.js +++ b/plugin/print-pdf/print-pdf.js @@ -6,6 +6,7 @@ * * @author Manuel Bieh (https://github.com/manuelbieh) * @author Hakim El Hattab (https://github.com/hakimel) + * @author Manuel Riezebosch (https://github.com/riezebosch) */ // html2pdf.js @@ -21,31 +22,48 @@ if( outputFile.match( /\.pdf$/gi ) === null ) { outputFile += '.pdf'; } -console.log( 'Export PDF: Reading reveal.js config [1/3]' ); +console.log( 'Export PDF: Reading reveal.js config [1/4]' ); probePage.open( inputFile, function( status ) { - console.log( 'Export PDF: Preparing print layout [2/3]' ); + console.log( 'Export PDF: Preparing print layout [2/4]' ); var config = probePage.evaluate( function() { return Reveal.getConfig(); } ); - printPage.paperSize = { - width: config.width * ( 1 + config.margin ), - height: config.height * ( 1 + config.margin ), - border: 0 - }; - - printPage.open( inputFile, function( status ) { - window.setTimeout( function() { - console.log( 'Export PDF: Writing file [3/3]' ); - printPage.render( outputFile ); - console.log( 'Export PDF: Finished successfully!' ); - phantom.exit(); - }, 1000 ); - } ); + if( config ) { + + printPage.paperSize = { + width: Math.floor( config.width * ( 1 + config.margin ) ), + height: Math.floor( config.height * ( 1 + config.margin ) ), + border: 0 + }; + + printPage.open( inputFile, function( status ) { + console.log( 'Export PDF: Preparing pdf [3/4]') + printPage.evaluate(function() { + Reveal.isReady() ? window.callPhantom() : Reveal.addEventListener( 'pdf-ready', window.callPhantom ); + }); + } ); + + printPage.onCallback = function(data) { + // For some reason we need to "jump the queue" for syntax highlighting to work. + // See: http://stackoverflow.com/a/3580132/129269 + setTimeout(function() { + console.log( 'Export PDF: Writing file [4/4]' ); + printPage.render( outputFile ); + console.log( 'Export PDF: Finished successfully!' ); + phantom.exit(); + }, 0); + }; + } + else { + + console.log( 'Export PDF: Unable to read reveal.js config. Make sure the input address points to a reveal.js page.' ); + phantom.exit(1); + } } ); |