Add 'data-element-attributes' attr. to 'section'.
By default '{\\\.\s*?([^}]+?)}'.
			
			
This commit is contained in:
		| @@ -28,6 +28,7 @@ | |||||||
|  |  | ||||||
| 	var DEFAULT_SLIDE_SEPARATOR = '^\n---\n$', | 	var DEFAULT_SLIDE_SEPARATOR = '^\n---\n$', | ||||||
| 		DEFAULT_NOTES_SEPARATOR = 'note:'; | 		DEFAULT_NOTES_SEPARATOR = 'note:'; | ||||||
|  | 		DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR = '{\\\.\s*?([^}]+?)}'; | ||||||
|  |  | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -218,7 +219,6 @@ | |||||||
| 				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' ), | ||||||
| @@ -277,8 +277,8 @@ | |||||||
| 	 * directly on refresh (F5) | 	 * directly on refresh (F5) | ||||||
| 	 * http://stackoverflow.com/questions/5690269/disabling-chrome-cache-for-website-development/7000899#answer-11786277 | 	 * http://stackoverflow.com/questions/5690269/disabling-chrome-cache-for-website-development/7000899#answer-11786277 | ||||||
| 	 */ | 	 */ | ||||||
| 	function addAttributeInElement( node, elementTarget ){ | 	function addAttributeInElement( node, elementTarget, separator ){ | ||||||
| 		var mardownClassesInElementsRegex = new RegExp( "{\\\.\s*?([^}]+?)}", 'mg' ); | 		var mardownClassesInElementsRegex = new RegExp( separator, 'mg' ); | ||||||
| 		var mardownClassRegex = new RegExp( "([^\"= ]+?)=\"([^\"=]+?)\"", 'mg' ); | 		var mardownClassRegex = new RegExp( "([^\"= ]+?)=\"([^\"=]+?)\"", 'mg' ); | ||||||
| 		var nodeValue = node.nodeValue; | 		var nodeValue = node.nodeValue; | ||||||
| 		if ( matches = mardownClassesInElementsRegex.exec( nodeValue ) ) { | 		if ( matches = mardownClassesInElementsRegex.exec( nodeValue ) ) { | ||||||
| @@ -297,24 +297,24 @@ | |||||||
| 	 * Add attributes to the parent element of a text node, | 	 * Add attributes to the parent element of a text node, | ||||||
| 	 * or the element of an attribute node. | 	 * or the element of an attribute node. | ||||||
| 	 */ | 	 */ | ||||||
| 	function addAttributes( element ) | 	function addAttributes( element, separator ) | ||||||
| 	{ | 	{ | ||||||
| 		if ( element.childNodes.length > 0 ) { | 		if ( element.childNodes.length > 0 ) { | ||||||
|  |  | ||||||
| 			for ( var i = 0; i < element.childNodes.length; i++ ) { | 			for ( var i = 0; i < element.childNodes.length; i++ ) { | ||||||
| 				addAttributes( element.childNodes[i] ); | 				addAttributes( element.childNodes[i], separator ); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		var nodeValue; | 		var nodeValue; | ||||||
| 		var elementTarget; | 		var elementTarget; | ||||||
| 		// From http://stackoverflow.com/questions/9178174/find-all-text-nodes | 		// From http://stackoverflow.com/questions/9178174/find-all-text-nodes | ||||||
| 		if ( element.nodeType == Node.TEXT_NODE && /\S/.test(element.nodeValue) ) { | 		if ( element.nodeType == Node.TEXT_NODE && /\S/.test(element.nodeValue) ) { | ||||||
| 			addAttributeInElement( element, element.parentNode ); | 			addAttributeInElement( element, element.parentNode, separator ); | ||||||
| 		} | 		} | ||||||
| 		if ( element.nodeType == Node.ELEMENT_NODE && element.attributes.length > 0 ) { | 		if ( element.nodeType == Node.ELEMENT_NODE && element.attributes.length > 0 ) { | ||||||
| 			for ( iattr=0; iattr<element.attributes.length; iattr++ ){ | 			for ( iattr=0; iattr<element.attributes.length; iattr++ ){ | ||||||
| 				var attr = element.attributes[iattr]; | 				var attr = element.attributes[iattr]; | ||||||
| 				addAttributeInElement(attr, element) | 				addAttributeInElement(attr, element, separator ) | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @@ -340,7 +340,9 @@ | |||||||
| 				var markdown = getMarkdownFromSlide( section ); | 				var markdown = getMarkdownFromSlide( section ); | ||||||
|  |  | ||||||
| 				section.innerHTML = marked( markdown ); | 				section.innerHTML = marked( markdown ); | ||||||
| 				addAttributes( section ); | 				addAttributes( 	section, section.getAttribute( 'data-element-attributes' ) || | ||||||
|  | 								section.parentNode.getAttribute( 'data-element-attributes' ) || | ||||||
|  | 								DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR ); | ||||||
|  |  | ||||||
| 				// If there were notes, we need to re-add them after | 				// If there were notes, we need to re-add them after | ||||||
| 				// having overwritten the section's HTML | 				// having overwritten the section's HTML | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user