diff options
Diffstat (limited to '')
-rwxr-xr-x | public/js/reveal-markdown.js | 28 | ||||
-rw-r--r-- | public/js/slide.js | 65 |
2 files changed, 73 insertions, 20 deletions
diff --git a/public/js/reveal-markdown.js b/public/js/reveal-markdown.js index a3f2505a..ca22e09c 100755 --- a/public/js/reveal-markdown.js +++ b/public/js/reveal-markdown.js @@ -5,27 +5,15 @@ */ (function( root, factory ) { if( typeof exports === 'object' ) { - module.exports = factory( require( './marked' ) ); + module.exports = factory(); } else { // Browser globals (root is window) - root.RevealMarkdown = factory( root.marked ); + root.RevealMarkdown = factory(); root.RevealMarkdown.initialize(); } -}( this, function( marked ) { - - if( typeof marked === 'undefined' ) { - throw 'The reveal.js Markdown plugin requires marked to be loaded'; - } - - if( typeof hljs !== 'undefined' ) { - marked.setOptions({ - highlight: function( lang, code ) { - return hljs.highlightAuto( lang, code ).value; - } - }); - } - +}( this, function() { + var DEFAULT_SLIDE_SEPARATOR = '^\r?\n---\r?\n$', DEFAULT_NOTES_SEPARATOR = 'note:', DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR = '\\\.element\\\s*?(.+?)$', @@ -364,10 +352,10 @@ var notes = section.querySelector( 'aside.notes' ); var markdown = getMarkdownFromSlide( section ); - var rendered = marked( markdown ); - rendered = preventXSS(rendered); - - section.innerHTML = rendered; + var rendered = md.render(markdown); + rendered = preventXSS(rendered); + var result = postProcess(rendered); + section.innerHTML = result[0].outerHTML; addAttributes( section, section, null, section.getAttribute( 'data-element-attributes' ) || section.parentNode.getAttribute( 'data-element-attributes' ) || DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR, diff --git a/public/js/slide.js b/public/js/slide.js new file mode 100644 index 00000000..f5f8a14d --- /dev/null +++ b/public/js/slide.js @@ -0,0 +1,65 @@ +var body = $(".slides").html(); +$(".slides").html(S(body).unescapeHTML().s); + +function extend() { + var target = {}; + for (var i = 0; i < arguments.length; i++) { + var source = arguments[i]; + for (var key in source) { + if (source.hasOwnProperty(key)) { + target[key] = source[key]; + } + } + } + return target; +} + +// Optional libraries used to extend on reveal.js +var deps = [{ + src: serverurl + '/vendor/reveal.js/lib/js/classList.js', + condition: function() { + return !document.body.classList; + } +}, { + src: serverurl + '/js/reveal-markdown.js', + condition: function() { + return !!document.querySelector('[data-markdown]'); + } +}, { + src: serverurl + '/vendor/reveal.js/plugin/notes/notes.js', + async: true, + condition: function() { + return !!document.body.classList; + } +}]; + +// default options to init reveal.js +var defaultOptions = { + controls: true, + progress: true, + slideNumber: true, + history: true, + center: true, + transition: 'none', + dependencies: deps +}; + +// options from URL query string +var queryOptions = Reveal.getQueryHash() || {}; + +var options = extend(defaultOptions, queryOptions); +Reveal.initialize(options); + +viewAjaxCallback = function () { + Reveal.layout(); +}; + +function renderSlide() { + var title = document.title; + finishView($(event.currentSlide)); + document.title = title; + Reveal.layout(); +} + +Reveal.addEventListener('ready', renderSlide); +Reveal.addEventListener('slidechanged', renderSlide);
\ No newline at end of file |