update markdown plugin formatting to match reveal.js core

This commit is contained in:
Hakim El Hattab 2013-08-23 17:49:19 -04:00
parent f215528575
commit b968dfef15
1 changed files with 170 additions and 159 deletions

View File

@ -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();
})();