fix issue with notes on last slide of external markdown #589
authorHakim El Hattab <hakim.elhattab@gmail.com>
Fri, 6 Sep 2013 12:24:03 +0000 (08:24 -0400)
committerHakim El Hattab <hakim.elhattab@gmail.com>
Fri, 6 Sep 2013 12:24:03 +0000 (08:24 -0400)
plugin/markdown/markdown.js

index c5c2358689aec95bda3e72bb03a037dc50e30d05..739cc919718fd31ea22a9c39b5c517399eedce6c 100755 (executable)
                });
        }
 
+       var DEFAULT_SLIDE_SEPARATOR = '^\n---\n$',
+               DEFAULT_NOTES_SEPARATOR = 'note:';
+
+
        /**
         * Retrieves the markdown contents of a slide section
         * element. Normalizes leading tabs/whitespace.
 
        }
 
+       /**
+        * Inspects the given options and fills out default
+        * values for what's not defined.
+        */
+       function getSlidifyOptions( options ) {
+
+               options = options || {};
+               options.separator = options.separator || DEFAULT_SLIDE_SEPARATOR;
+               options.notesSeparator = options.notesSeparator || DEFAULT_NOTES_SEPARATOR;
+               options.attributes = options.attributes || '';
+
+               return options;
+
+       }
+
        /**
         * Helper function for constructing a markdown slide.
         */
        function createMarkdownSlide( content, options ) {
 
+               options = getSlidifyOptions( options );
+
                var notesMatch = content.split( new RegExp( options.notesSeparator, 'mgi' ) );
 
                if( notesMatch.length === 2 ) {
         */
        function slidify( markdown, options ) {
 
-               options = options || {};
-               options.separator = options.separator || '^\n---\n$';
-               options.notesSeparator = options.notesSeparator || 'note:';
-               options.attributes = options.attributes || '';
+               options = getSlidifyOptions( options );
 
                var separatorRegex = new RegExp( options.separator + ( options.verticalSeparator ? '|' + options.verticalSeparator : '' ), 'mg' ),
                        horizontalSeparatorRegex = new RegExp( options.separator );
                                }
 
                        }
-                       else if( section.getAttribute( 'data-separator' ) ) {
+                       else if( section.getAttribute( 'data-separator' ) || section.getAttribute( 'data-vertical' ) || section.getAttribute( 'data-notes' ) ) {
 
                                section.outerHTML = slidify( getMarkdownFromSlide( section ), {
                                        separator: section.getAttribute( 'data-separator' ),
                                });
 
                        }
+                       else {
+
+                               section.innerHTML = createMarkdownSlide( getMarkdownFromSlide( section ) );
+
+                       }
                }
 
        }