diff options
author | Hakim El Hattab <hakim.elhattab@gmail.com> | 2013-09-06 08:24:03 -0400 |
---|---|---|
committer | Hakim El Hattab <hakim.elhattab@gmail.com> | 2013-09-06 08:24:03 -0400 |
commit | ef9168c7c481805f57feb78853dfdd3dd1409705 (patch) | |
tree | a7cbeed276942a0426914dab23c308d412c841b6 /plugin | |
parent | a3e6c95e79525ec76e39c29390abb66ba737b751 (diff) | |
download | fosdem-2018-presentation-ef9168c7c481805f57feb78853dfdd3dd1409705.tar fosdem-2018-presentation-ef9168c7c481805f57feb78853dfdd3dd1409705.tar.gz |
fix issue with notes on last slide of external markdown #589
Diffstat (limited to 'plugin')
-rwxr-xr-x | plugin/markdown/markdown.js | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/plugin/markdown/markdown.js b/plugin/markdown/markdown.js index c5c2358..739cc91 100755 --- a/plugin/markdown/markdown.js +++ b/plugin/markdown/markdown.js @@ -27,6 +27,10 @@ }); } + var DEFAULT_SLIDE_SEPARATOR = '^\n---\n$', + DEFAULT_NOTES_SEPARATOR = 'note:'; + + /** * Retrieves the markdown contents of a slide section * element. Normalizes leading tabs/whitespace. @@ -83,10 +87,27 @@ } /** + * 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 ) { @@ -103,10 +124,7 @@ */ 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 ); @@ -232,7 +250,7 @@ } } - 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' ), @@ -242,6 +260,11 @@ }); } + else { + + section.innerHTML = createMarkdownSlide( getMarkdownFromSlide( section ) ); + + } } } |