update markdown plugin formatting to match reveal.js core
This commit is contained in:
parent
f215528575
commit
b968dfef15
@ -36,12 +36,19 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
var twrap = function( el ) {
|
var twrap = function( el ) {
|
||||||
|
|
||||||
var content = el.content || 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>';
|
return '<script type="text/template">' + content + '</script>';
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var getForwardedAttributes = function( section ) {
|
var getForwardedAttributes = function( section ) {
|
||||||
|
|
||||||
var attributes = section.attributes;
|
var attributes = section.attributes;
|
||||||
var result = [];
|
var result = [];
|
||||||
|
|
||||||
@ -61,6 +68,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
return result.join( ' ' );
|
return result.join( ' ' );
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var slidifyMarkdown = function( markdown, separator, vertical, notes, attributes ) {
|
var slidifyMarkdown = function( markdown, separator, vertical, notes, attributes ) {
|
||||||
@ -105,7 +113,7 @@
|
|||||||
|
|
||||||
slide = {
|
slide = {
|
||||||
content: content,
|
content: content,
|
||||||
asideContent: asideContent || ""
|
asideContent: asideContent || ''
|
||||||
};
|
};
|
||||||
|
|
||||||
if( isHorizontal && wasHorizontal ) {
|
if( isHorizontal && wasHorizontal ) {
|
||||||
@ -138,7 +146,7 @@
|
|||||||
return markdownSections;
|
return markdownSections;
|
||||||
};
|
};
|
||||||
|
|
||||||
var querySlidingMarkdown = function() {
|
var queryExternalMarkdown = function() {
|
||||||
|
|
||||||
var sections = document.querySelectorAll( '[data-markdown]'),
|
var sections = document.querySelectorAll( '[data-markdown]'),
|
||||||
section;
|
section;
|
||||||
@ -153,6 +161,7 @@
|
|||||||
url = section.getAttribute( 'data-markdown' );
|
url = section.getAttribute( 'data-markdown' );
|
||||||
|
|
||||||
datacharset = section.getAttribute( 'data-charset' );
|
datacharset = section.getAttribute( 'data-charset' );
|
||||||
|
|
||||||
// see https://developer.mozilla.org/en-US/docs/Web/API/element.getAttribute#Notes
|
// see https://developer.mozilla.org/en-US/docs/Web/API/element.getAttribute#Notes
|
||||||
if( datacharset != null && datacharset != '' ) {
|
if( datacharset != null && datacharset != '' ) {
|
||||||
xhr.overrideMimeType( 'text/html; charset=' + datacharset );
|
xhr.overrideMimeType( 'text/html; charset=' + datacharset );
|
||||||
@ -162,7 +171,8 @@
|
|||||||
if( xhr.readyState === 4 ) {
|
if( xhr.readyState === 4 ) {
|
||||||
if ( xhr.status >= 200 && xhr.status < 300 ) {
|
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 ) );
|
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 +
|
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.' +
|
'. 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>';
|
'<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 );
|
xhr.open( 'GET', url, false );
|
||||||
|
|
||||||
try {
|
try {
|
||||||
xhr.send();
|
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 );
|
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();
|
queryMarkdownSlides();
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
Loading…
Reference in New Issue
Block a user