Remove section attribute implementation.
This commit is contained in:
parent
dd9fa3e22b
commit
3330c2a764
|
@ -97,7 +97,6 @@
|
||||||
options.separator = options.separator || DEFAULT_SLIDE_SEPARATOR;
|
options.separator = options.separator || DEFAULT_SLIDE_SEPARATOR;
|
||||||
options.notesSeparator = options.notesSeparator || DEFAULT_NOTES_SEPARATOR;
|
options.notesSeparator = options.notesSeparator || DEFAULT_NOTES_SEPARATOR;
|
||||||
options.attributes = options.attributes || '';
|
options.attributes = options.attributes || '';
|
||||||
options.slideAttributesSeparator = options.slideAttributesSeparator || DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR;
|
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
|
|
||||||
|
@ -129,17 +128,14 @@
|
||||||
options = getSlidifyOptions( options );
|
options = getSlidifyOptions( options );
|
||||||
|
|
||||||
var separatorRegex = new RegExp( options.separator + ( options.verticalSeparator ? '|' + options.verticalSeparator : '' ), 'mg' ),
|
var separatorRegex = new RegExp( options.separator + ( options.verticalSeparator ? '|' + options.verticalSeparator : '' ), 'mg' ),
|
||||||
horizontalSeparatorRegex = new RegExp( options.separator ),
|
horizontalSeparatorRegex = new RegExp( options.separator );
|
||||||
slideAttributesSeparatorRegex = new RegExp( options.slideAttributesSeparator, 'm' );
|
|
||||||
|
|
||||||
var matches,
|
var matches,
|
||||||
lastIndex = 0,
|
lastIndex = 0,
|
||||||
isHorizontal,
|
isHorizontal,
|
||||||
wasHorizontal = true,
|
wasHorizontal = true,
|
||||||
content,
|
content,
|
||||||
sectionStack = [],
|
sectionStack = [];
|
||||||
matchAttributes,
|
|
||||||
slideAttributes = "";
|
|
||||||
|
|
||||||
// iterate until all blocks between separators are stacked up
|
// iterate until all blocks between separators are stacked up
|
||||||
while( matches = separatorRegex.exec( markdown ) ) {
|
while( matches = separatorRegex.exec( markdown ) ) {
|
||||||
|
@ -178,35 +174,19 @@
|
||||||
for( var i = 0, len = sectionStack.length; i < len; i++ ) {
|
for( var i = 0, len = sectionStack.length; i < len; i++ ) {
|
||||||
// vertical
|
// vertical
|
||||||
if( sectionStack[i] instanceof Array ) {
|
if( sectionStack[i] instanceof Array ) {
|
||||||
// The 'data-xxx' attributes of the first child must be set on the wrapping parent section to be effective
|
markdownSections += '<section '+ options.attributes +'>';
|
||||||
// Mainly for data-transition (otherwise, it is ignored for the first vertical slide)
|
|
||||||
firstChild = sectionStack[i][0];
|
|
||||||
matchAttributes = slideAttributesSeparatorRegex.exec( firstChild );
|
|
||||||
slideAttributes = matchAttributes ? matchAttributes[1] : "";
|
|
||||||
dataAttributes = "";
|
|
||||||
if( slideAttributes != "" ) {
|
|
||||||
// http://stackoverflow.com/questions/18025762/javascript-regex-replace-all-word-characters-except-word-characters-between-ch
|
|
||||||
// Keep only data-attributes for the parent slide section.
|
|
||||||
dataAttributes = slideAttributes.replace( /(data-\S+=\"[^\"]+?\")|\w|[\"=]/g, function(a, b) { return b || ''; });
|
|
||||||
}
|
|
||||||
markdownSections += '<section '+ options.attributes + ' ' + dataAttributes + '>';
|
|
||||||
|
|
||||||
sectionStack[i].forEach( function( child ) {
|
sectionStack[i].forEach( function( child ) {
|
||||||
matchAttributes = slideAttributesSeparatorRegex.exec( child );
|
markdownSections += '<section data-markdown>' + createMarkdownSlide( child, options ) + '</section>';
|
||||||
slideAttributes = matchAttributes ? matchAttributes[1] : "";
|
|
||||||
child = matchAttributes ? child.replace( slideAttributesSeparatorRegex,"" ) : child
|
|
||||||
markdownSections += '<section ' + slideAttributes + ' data-markdown>' + createMarkdownSlide( child, options ) + '</section>';
|
|
||||||
} );
|
} );
|
||||||
|
|
||||||
markdownSections += '</section>';
|
markdownSections += '</section>';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
matchAttributes = slideAttributesSeparatorRegex.exec( sectionStack[i] );
|
markdownSections += '<section '+ options.attributes +' data-markdown>' + createMarkdownSlide( sectionStack[i], options ) + '</section>';
|
||||||
slideAttributes = matchAttributes ? matchAttributes[1] : "";
|
|
||||||
content = matchAttributes ? sectionStack[i].replace( slideAttributesSeparatorRegex,"" ) : sectionStack[i]
|
|
||||||
markdownSections += '<section '+ options.attributes + ' ' + slideAttributes +' data-markdown>' + createMarkdownSlide( content, options ) + '</section>';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return markdownSections;
|
return markdownSections;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -240,12 +220,12 @@
|
||||||
xhr.onreadystatechange = function() {
|
xhr.onreadystatechange = function() {
|
||||||
if( xhr.readyState === 4 ) {
|
if( xhr.readyState === 4 ) {
|
||||||
if ( xhr.status >= 200 && xhr.status < 300 ) {
|
if ( xhr.status >= 200 && xhr.status < 300 ) {
|
||||||
|
|
||||||
section.outerHTML = slidify( xhr.responseText, {
|
section.outerHTML = slidify( xhr.responseText, {
|
||||||
separator: section.getAttribute( 'data-separator' ),
|
separator: section.getAttribute( 'data-separator' ),
|
||||||
verticalSeparator: section.getAttribute( 'data-vertical' ),
|
verticalSeparator: section.getAttribute( 'data-vertical' ),
|
||||||
notesSeparator: section.getAttribute( 'data-notes' ),
|
notesSeparator: section.getAttribute( 'data-notes' ),
|
||||||
attributes: getForwardedAttributes( section ),
|
attributes: getForwardedAttributes( section )
|
||||||
slideAttributesSeparator: section.getAttribute( 'data-attributes' ),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -277,24 +257,12 @@
|
||||||
separator: section.getAttribute( 'data-separator' ),
|
separator: section.getAttribute( 'data-separator' ),
|
||||||
verticalSeparator: section.getAttribute( 'data-vertical' ),
|
verticalSeparator: section.getAttribute( 'data-vertical' ),
|
||||||
notesSeparator: section.getAttribute( 'data-notes' ),
|
notesSeparator: section.getAttribute( 'data-notes' ),
|
||||||
attributes: getForwardedAttributes( section ),
|
attributes: getForwardedAttributes( section )
|
||||||
slideAttributesSeparator: section.getAttribute( 'data-attributes' ),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var content = getMarkdownFromSlide( section );
|
section.innerHTML = createMarkdownSlide( getMarkdownFromSlide( section ) );
|
||||||
var slideAttributesSeparatorRegex = new RegExp( section.getAttribute( 'data-attributes' ) || DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR, 'm' );
|
|
||||||
var matchAttributes = slideAttributesSeparatorRegex.exec( content );
|
|
||||||
if ( matchAttributes ) {
|
|
||||||
var slideAttributes = matchAttributes[1];
|
|
||||||
content = content.replace( slideAttributesSeparatorRegex,"" );
|
|
||||||
var slideAttributesRegex = new RegExp( "([^\"= ]+?)=\"([^\"=]+?)\"", 'mg' );
|
|
||||||
while( matchesAttributes = slideAttributesRegex.exec( slideAttributes ) ) {
|
|
||||||
section.setAttribute( matchesAttributes[1], matchesAttributes[2] );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
section.innerHTML = createMarkdownSlide( content );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user