Browse Source

update markdown plugin formatting to match reveal.js core

embed
Hakim El Hattab 11 years ago
parent
commit
b968dfef15
  1. 25
      plugin/markdown/markdown.js

25
plugin/markdown/markdown.js

@ -36,12 +36,19 @@
};
var twrap = function( el ) {
var content = el.content || el;
content += el.asideContent ? ('<aside class="notes" data-markdown>' + el.asideContent + '</aside>') : '';
if( el.asideContent ) {
content += '<aside class="notes" data-markdown>' + el.asideContent + '</aside>';
}
return '<script type="text/template">' + content + '</script>';
};
var getForwardedAttributes = function( section ) {
var attributes = section.attributes;
var result = [];
@ -61,6 +68,7 @@
}
return result.join( ' ' );
};
var slidifyMarkdown = function( markdown, separator, vertical, notes, attributes ) {
@ -105,7 +113,7 @@
slide = {
content: content,
asideContent: asideContent || ""
asideContent: asideContent || ''
};
if( isHorizontal && wasHorizontal ) {
@ -138,7 +146,7 @@
return markdownSections;
};
var querySlidingMarkdown = function() {
var queryExternalMarkdown = function() {
var sections = document.querySelectorAll( '[data-markdown]'),
section;
@ -153,6 +161,7 @@
url = section.getAttribute( 'data-markdown' );
datacharset = section.getAttribute( 'data-charset' );
// see https://developer.mozilla.org/en-US/docs/Web/API/element.getAttribute#Notes
if( datacharset != null && datacharset != '' ) {
xhr.overrideMimeType( 'text/html; charset=' + datacharset );
@ -162,7 +171,8 @@
if( xhr.readyState === 4 ) {
if ( xhr.status >= 200 && xhr.status < 300 ) {
section.outerHTML = slidifyMarkdown( xhr.responseText, section.getAttribute( 'data-separator' ), section.getAttribute( 'data-vertical' ), section.getAttribute( 'data-notes' ), getForwardedAttributes( section ) );
} else {
}
else {
section.outerHTML = '<section data-state="alert">ERROR: The attempt to fetch ' + url + ' failed with the HTTP status ' + xhr.status +
'. Check your browser\'s JavaScript console for more details.' +
'<p>Remember that you need to serve the presentation HTML from a HTTP server and the Markdown file must be there too.</p></section>';
@ -171,9 +181,11 @@
};
xhr.open( 'GET', url, false );
try {
xhr.send();
} catch (e) {
}
catch ( e ) {
alert( 'Failed to get the Markdown file ' + url + '. Make sure that the presentation and the file are served by a HTTP server and the file can be found there. ' + e );
}
@ -213,8 +225,7 @@
};
querySlidingMarkdown();
queryExternalMarkdown();
queryMarkdownSlides();
})();

Loading…
Cancel
Save