diff options
Diffstat (limited to 'plugin/markdown/markdown.js')
-rwxr-xr-x | plugin/markdown/markdown.js | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/plugin/markdown/markdown.js b/plugin/markdown/markdown.js index 4847c7a..ab8f2e9 100755 --- a/plugin/markdown/markdown.js +++ b/plugin/markdown/markdown.js @@ -4,10 +4,13 @@ * of external markdown documents. */ (function( root, factory ) { - if( typeof exports === 'object' ) { + if (typeof define === 'function' && define.amd) { + root.marked = require( './marked' ); + root.RevealMarkdown = factory( root.marked ); + root.RevealMarkdown.initialize(); + } else if( typeof exports === 'object' ) { module.exports = factory( require( './marked' ) ); - } - else { + } else { // Browser globals (root is window) root.RevealMarkdown = factory( root.marked ); root.RevealMarkdown.initialize(); @@ -26,11 +29,13 @@ }); } - var DEFAULT_SLIDE_SEPARATOR = '^\n---\n$', + var DEFAULT_SLIDE_SEPARATOR = '^\r?\n---\r?\n$', DEFAULT_NOTES_SEPARATOR = 'note:', DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR = '\\\.element\\\s*?(.+?)$', DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR = '\\\.slide:\\\s*?(\\\S.+?)$'; + var SCRIPT_END_PLACEHOLDER = '__SCRIPT_END__'; + /** * Retrieves the markdown contents of a slide section @@ -43,6 +48,9 @@ // strip leading whitespace so it isn't evaluated as code var text = ( template || section ).textContent; + // restore script end tags + text = text.replace( new RegExp( SCRIPT_END_PLACEHOLDER, 'g' ), '</script>' ); + var leadingWs = text.match( /^\n?(\s*)/ )[1].length, leadingTabs = text.match( /^\n?(\t*)/ )[1].length; @@ -76,7 +84,7 @@ if( /data\-(markdown|separator|vertical|notes)/gi.test( name ) ) continue; if( value ) { - result.push( name + '=' + value ); + result.push( name + '="' + value + '"' ); } else { result.push( name ); @@ -115,6 +123,10 @@ content = notesMatch[0] + '<aside class="notes" data-markdown>' + notesMatch[1].trim() + '</aside>'; } + // prevent script end tags in the content from interfering + // with parsing + content = content.replace( /<\/script>/g, SCRIPT_END_PLACEHOLDER ); + return '<script type="text/template">' + content + '</script>'; } |