ERROR: The attempt to fetch ' + url + ' failed with the HTTP status ' + xhr.status +
- '. Check your browser\'s JavaScript console for more details.' +
- 'Remember that you need to serve the presentation HTML from a HTTP server and the Markdown file must be there too.
';
- }
- }
- };
+ var sections = document.querySelectorAll( '[data-markdown]'),
+ section;
- xhr.open('GET', url, false);
- try {
- xhr.send();
- } 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);
- }
+ for( var j = 0, jlen = sections.length; j < jlen; j++ ) {
- } else if( section.getAttribute('data-separator') ) {
+ section = sections[j];
- var markdown = stripLeadingWhitespace(section);
- section.outerHTML = slidifyMarkdown( markdown, section.getAttribute('data-separator'), section.getAttribute('data-vertical'), section.getAttribute('data-notes'), getForwardedAttributes(section) );
+ if( section.getAttribute( 'data-markdown' ).length ) {
- }
- }
+ var xhr = new XMLHttpRequest(),
+ url = section.getAttribute( 'data-markdown' );
- };
+ datacharset = section.getAttribute( 'data-charset' );
- var queryMarkdownSlides = function() {
+ // see https://developer.mozilla.org/en-US/docs/Web/API/element.getAttribute#Notes
+ if( datacharset != null && datacharset != '' ) {
+ xhr.overrideMimeType( 'text/html; charset=' + datacharset );
+ }
- var sections = document.querySelectorAll( '[data-markdown]');
+ xhr.onreadystatechange = function() {
+ 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 {
+ section.outerHTML = '