From dd9fa3e22bd57fa7c5d16eeff4d84abf60f35fd6 Mon Sep 17 00:00:00 2001
From: VonC
Date: Sun, 24 Nov 2013 21:27:30 +0100
Subject: First refactoring

---
 plugin/markdown/markdown.js                | 43 ++++++++++++++++++++++--------
 test/test-markdown-attributes.html         |  2 +-
 test/test-markdown-element-attributes.html |  4 +--
 3 files changed, 35 insertions(+), 14 deletions(-)

diff --git a/plugin/markdown/markdown.js b/plugin/markdown/markdown.js
index 9564208..d399569 100755
--- a/plugin/markdown/markdown.js
+++ b/plugin/markdown/markdown.js
@@ -323,33 +323,50 @@
 			while( matchesClass = mardownClassRegex.exec( classes ) ) {
 				elementTarget.setAttribute( matchesClass[1], matchesClass[2] );
 			}
+			return true;
 		}
-
+		return false;
 	}
 
 	/**
 	 * Add attributes to the parent element of a text node,
 	 * or the element of an attribute node.
 	 */
-	function addAttributes( element, separator ) {
+	function addAttributes( section, element, previousElement, separatorElementAttributes, separatorSectionAttributes ) {
 
-		if( element.childNodes.length > 0 ) {
+        console.log("element='" + element.innerHTML + "', nodeType='" + element.nodeType + "'");
+		console.log("previousElement="+previousElement)
+		console.log("section=****"+section.outerHTML+"****");
+		if( element != null && element.childNodes != undefined && element.childNodes.length > 0 ) {
+			previousParentElement = element;
 			for( var i = 0; i < element.childNodes.length; i++ ) {
-				addAttributes( element.childNodes[i], separator );
+				childElement = element.childNodes[i];
+				console.log("  Child element='" + childElement.innerHTML + "'");
+				if ( i > 0 ) {
+					previousParentElement = element.childNodes[i-1];
+				}
+				parentSection = section;
+				if( childElement.nodeName ==  "section" ) {
+					parentSection = childElement ;
+					previousParentElement = childElement ;
+				}
+				addAttributes( parentSection, childElement, previousParentElement, separatorElementAttributes, separatorSectionAttributes );
 			}
 		}
 
-		var nodeValue;
-		var elementTarget;
-
+		if ( element.nodeType == Node.COMMENT_NODE ) {
+			if ( addAttributeInElement( element, previousElement, separatorElementAttributes ) == false ) {
+				addAttributeInElement( element, section, separatorSectionAttributes);
+			}
+		}
 		// From http://stackoverflow.com/questions/9178174/find-all-text-nodes
 		if( element.nodeType == Node.TEXT_NODE && /\S/.test(element.nodeValue) ) {
-			addAttributeInElement( element, element.parentNode, separator );
+			addAttributeInElement( element, element.parentNode, separatorElementAttributes );
 		}
 		if( element.nodeType == Node.ELEMENT_NODE && element.attributes.length > 0 ) {
 			for( var j = 0; j < element.attributes.length; j++ ){
 				var attr = element.attributes[j];
-				addAttributeInElement( attr, element, separator );
+				addAttributeInElement( attr, element, separatorElementAttributes );
 			}
 		}
 
@@ -376,9 +393,13 @@
 				var markdown = getMarkdownFromSlide( section );
 
 				section.innerHTML = marked( markdown );
-				addAttributes( 	section, section.getAttribute( 'data-element-attributes' ) ||
+				//console.log("markdown="+markdown);
+				addAttributes( 	section, section, null, section.getAttribute( 'data-element-attributes' ) ||
 								section.parentNode.getAttribute( 'data-element-attributes' ) ||
-								DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR );
+								DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR,
+								section.getAttribute( 'data-attributes' ) ||
+								section.parentNode.getAttribute( 'data-attributes' ) ||
+								DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR);
 
 				// If there were notes, we need to re-add them after
 				// having overwritten the section's HTML
diff --git a/test/test-markdown-attributes.html b/test/test-markdown-attributes.html
index cc03177..8f77dac 100644
--- a/test/test-markdown-attributes.html
+++ b/test/test-markdown-attributes.html
@@ -15,7 +15,7 @@
 		<div id="qunit"></div>
   		<div id="qunit-fixture"></div>
 
-		<div class="reveal" style="display: none;">
+		<div class="reveal" style="display: true;">
 
 			<div class="slides">
 
diff --git a/test/test-markdown-element-attributes.html b/test/test-markdown-element-attributes.html
index 417ce30..e9f4038 100644
--- a/test/test-markdown-element-attributes.html
+++ b/test/test-markdown-element-attributes.html
@@ -15,7 +15,7 @@
 		<div id="qunit"></div>
   		<div id="qunit-fixture"></div>
 
-		<div class="reveal" style="display: none;">
+		<div class="reveal" style="display: true;">
 
 			<div class="slides">
 
@@ -44,7 +44,7 @@
 						## Slide 2
 
 
-						Paragraph 1.2  
+						Paragraph 1.2
 						multi-line {_class="fragment highlight-red"}
 
 						Paragraph 2.2 {_class="fragment highlight-red"}
-- 
cgit v1.2.3


From 3330c2a7648767f0ef8298c152ae4f2dd2c38ba0 Mon Sep 17 00:00:00 2001
From: VonC
Date: Mon, 25 Nov 2013 22:05:23 +0100
Subject: Remove section attribute implementation.

---
 plugin/markdown/markdown.js | 54 +++++++++------------------------------------
 1 file changed, 11 insertions(+), 43 deletions(-)

diff --git a/plugin/markdown/markdown.js b/plugin/markdown/markdown.js
index d399569..d606a4b 100755
--- a/plugin/markdown/markdown.js
+++ b/plugin/markdown/markdown.js
@@ -97,7 +97,6 @@
 		options.separator = options.separator || DEFAULT_SLIDE_SEPARATOR;
 		options.notesSeparator = options.notesSeparator || DEFAULT_NOTES_SEPARATOR;
 		options.attributes = options.attributes || '';
-		options.slideAttributesSeparator = options.slideAttributesSeparator || DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR;
 
 		return options;
 
@@ -129,17 +128,14 @@
 		options = getSlidifyOptions( options );
 
 		var separatorRegex = new RegExp( options.separator + ( options.verticalSeparator ? '|' + options.verticalSeparator : '' ), 'mg' ),
-			horizontalSeparatorRegex = new RegExp( options.separator ),
-			slideAttributesSeparatorRegex = new RegExp( options.slideAttributesSeparator, 'm' );
+			horizontalSeparatorRegex = new RegExp( options.separator );
 
 		var matches,
 			lastIndex = 0,
 			isHorizontal,
 			wasHorizontal = true,
 			content,
-			sectionStack = [],
-			matchAttributes,
-			slideAttributes = "";
+			sectionStack = [];
 
 		// iterate until all blocks between separators are stacked up
 		while( matches = separatorRegex.exec( markdown ) ) {
@@ -178,35 +174,19 @@
 		for( var i = 0, len = sectionStack.length; i < len; i++ ) {
 			// vertical
 			if( sectionStack[i] instanceof Array ) {
-				// The 'data-xxx' attributes of the first child must be set on the wrapping parent section to be effective
-				// 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 + '>';
+				markdownSections += '<section '+ options.attributes +'>';
 
 				sectionStack[i].forEach( function( child ) {
-					matchAttributes = slideAttributesSeparatorRegex.exec( child );
-					slideAttributes = matchAttributes ? matchAttributes[1] : "";
-					child = matchAttributes ? child.replace( slideAttributesSeparatorRegex,"" ) : child
-					markdownSections += '<section ' + slideAttributes + ' data-markdown>' +  createMarkdownSlide( child, options ) + '</section>';
+					markdownSections += '<section data-markdown>' +  createMarkdownSlide( child, options ) + '</section>';
 				} );
 
 				markdownSections += '</section>';
 			}
 			else {
-				matchAttributes = slideAttributesSeparatorRegex.exec( sectionStack[i] );
-				slideAttributes = matchAttributes ? matchAttributes[1] : "";
-				content = matchAttributes ? sectionStack[i].replace( slideAttributesSeparatorRegex,"" ) : sectionStack[i]
-				markdownSections += '<section '+ options.attributes + ' ' + slideAttributes +' data-markdown>' + createMarkdownSlide( content, options ) + '</section>';
+				markdownSections += '<section '+ options.attributes +' data-markdown>' + createMarkdownSlide( sectionStack[i], options ) + '</section>';
 			}
 		}
+
 		return markdownSections;
 
 	}
@@ -240,12 +220,12 @@
 				xhr.onreadystatechange = function() {
 					if( xhr.readyState === 4 ) {
 						if ( xhr.status >= 200 && xhr.status < 300 ) {
+
 							section.outerHTML = slidify( xhr.responseText, {
 								separator: section.getAttribute( 'data-separator' ),
 								verticalSeparator: section.getAttribute( 'data-vertical' ),
 								notesSeparator: section.getAttribute( 'data-notes' ),
-								attributes: getForwardedAttributes( section ),
-								slideAttributesSeparator: section.getAttribute( 'data-attributes' ),
+								attributes: getForwardedAttributes( section )
 							});
 
 						}
@@ -277,24 +257,12 @@
 					separator: section.getAttribute( 'data-separator' ),
 					verticalSeparator: section.getAttribute( 'data-vertical' ),
 					notesSeparator: section.getAttribute( 'data-notes' ),
-					attributes: getForwardedAttributes( section ),
-					slideAttributesSeparator: section.getAttribute( 'data-attributes' ),
+					attributes: getForwardedAttributes( section )
 				});
 
 			}
 			else {
-				var content = 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 );
+				section.innerHTML = createMarkdownSlide( getMarkdownFromSlide( section ) );
 			}
 		}
 
@@ -334,7 +302,7 @@
 	 */
 	function addAttributes( section, element, previousElement, separatorElementAttributes, separatorSectionAttributes ) {
 
-        console.log("element='" + element.innerHTML + "', nodeType='" + element.nodeType + "'");
+		console.log("element='" + element.innerHTML + "', nodeType='" + element.nodeType + "'");
 		console.log("previousElement="+previousElement)
 		console.log("section=****"+section.outerHTML+"****");
 		if( element != null && element.childNodes != undefined && element.childNodes.length > 0 ) {
-- 
cgit v1.2.3


From 8ad633e4f3cdc576601e9b9aa5cd85c1f08e427e Mon Sep 17 00:00:00 2001
From: VonC
Date: Wed, 27 Nov 2013 22:48:01 +0100
Subject: Fix element attributes, except for multi-line.

---
 plugin/markdown/markdown.js                | 38 +++++++++++----------
 test/test-markdown-attributes.html         |  8 ++---
 test/test-markdown-element-attributes.html | 53 ++++++++++++++++++++----------
 3 files changed, 60 insertions(+), 39 deletions(-)

diff --git a/plugin/markdown/markdown.js b/plugin/markdown/markdown.js
index d606a4b..34458f2 100755
--- a/plugin/markdown/markdown.js
+++ b/plugin/markdown/markdown.js
@@ -29,7 +29,7 @@
 	var DEFAULT_SLIDE_SEPARATOR = '^\n---\n$',
 		DEFAULT_NOTES_SEPARATOR = 'note:',
 		DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR = '{\\\.\s*?([^}]+?)}',
-		DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR = '^.*?<!--\\\sslide-attributes:\\\s(.*?)-->';
+		DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR = 'slide-attributes:\\\s(.*?)$';
 
 
 	/**
@@ -73,7 +73,7 @@
 				value = attributes[i].value;
 
 			// disregard attributes that are used for markdown loading/parsing
-			if( /data\-(markdown|separator|vertical|notes|attributes)/gi.test( name ) ) continue;
+			if( /data\-(markdown|separator|vertical|notes)/gi.test( name ) ) continue;
 
 			if( value ) {
 				result.push( name + '=' + value );
@@ -282,12 +282,13 @@
 		var mardownClassesInElementsRegex = new RegExp( separator, 'mg' );
 		var mardownClassRegex = new RegExp( "([^\"= ]+?)=\"([^\"=]+?)\"", 'mg' );
 		var nodeValue = node.nodeValue;
+		console.log("=== node.nodeValue='" + nodeValue + "' vs. separator '" + separator + "'");
 		if( matches = mardownClassesInElementsRegex.exec( nodeValue ) ) {
 
 			var classes = matches[1];
 			nodeValue = nodeValue.substring( 0, matches.index ) + nodeValue.substring( mardownClassesInElementsRegex.lastIndex );
 			node.nodeValue = nodeValue;
-
+			console.log("=========== classes='" + classes + "'");
 			while( matchesClass = mardownClassRegex.exec( classes ) ) {
 				elementTarget.setAttribute( matchesClass[1], matchesClass[2] );
 			}
@@ -302,15 +303,15 @@
 	 */
 	function addAttributes( section, element, previousElement, separatorElementAttributes, separatorSectionAttributes ) {
 
-		console.log("element='" + element.innerHTML + "', nodeType='" + element.nodeType + "'");
+		console.log("*** element='" + element.innerHTML + "', nodeType='" + element.nodeType + "'");
 		console.log("previousElement="+previousElement)
 		console.log("section=****"+section.outerHTML+"****");
-		if( element != null && element.childNodes != undefined && element.childNodes.length > 0 ) {
+		if ( element != null && element.childNodes != undefined && element.childNodes.length > 0 ) {
 			previousParentElement = element;
 			for( var i = 0; i < element.childNodes.length; i++ ) {
 				childElement = element.childNodes[i];
-				console.log("  Child element='" + childElement.innerHTML + "'");
-				if ( i > 0 ) {
+				console.log("  Child element='" + childElement.innerHTML + "', type " + childElement.nodeType);
+				if ( i > 0 && typeof element.childNodes[i-1].setAttribute == 'function' ) {
 					previousParentElement = element.childNodes[i-1];
 				}
 				parentSection = section;
@@ -318,7 +319,10 @@
 					parentSection = childElement ;
 					previousParentElement = childElement ;
 				}
-				addAttributes( parentSection, childElement, previousParentElement, separatorElementAttributes, separatorSectionAttributes );
+				if ( typeof childElement.setAttribute == 'function' || childElement.nodeType == Node.COMMENT_NODE ) {
+					console.log("   CALL addAttributes")
+					addAttributes( parentSection, childElement, previousParentElement, separatorElementAttributes, separatorSectionAttributes );
+				}
 			}
 		}
 
@@ -328,15 +332,15 @@
 			}
 		}
 		// From http://stackoverflow.com/questions/9178174/find-all-text-nodes
-		if( element.nodeType == Node.TEXT_NODE && /\S/.test(element.nodeValue) ) {
-			addAttributeInElement( element, element.parentNode, separatorElementAttributes );
-		}
-		if( element.nodeType == Node.ELEMENT_NODE && element.attributes.length > 0 ) {
-			for( var j = 0; j < element.attributes.length; j++ ){
-				var attr = element.attributes[j];
-				addAttributeInElement( attr, element, separatorElementAttributes );
-			}
-		}
+		//if( element.nodeType == Node.TEXT_NODE && /\S/.test(element.nodeValue) ) {
+		//	addAttributeInElement( element, element.parentNode, separatorElementAttributes );
+		//}
+		//if( element.nodeType == Node.ELEMENT_NODE && element.attributes.length > 0 ) {
+		//	for( var j = 0; j < element.attributes.length; j++ ){
+		//		var attr = element.attributes[j];
+		//		addAttributeInElement( attr, element, separatorElementAttributes );
+		//	}
+		//}
 
 	}
 
diff --git a/test/test-markdown-attributes.html b/test/test-markdown-attributes.html
index 8f77dac..6818cd5 100644
--- a/test/test-markdown-attributes.html
+++ b/test/test-markdown-attributes.html
@@ -25,7 +25,7 @@
 				<section 	data-markdown data-separator="^\n\n\n"
 									data-vertical="^\n\n"
 									data-notes="^Note:"
-									data-attributes="^\s*?--\s(.*?)$"
+									data-attributes="--\s(.*?)$"
 									data-charset="utf-8">
 					<script type="text/template">
 						# Test attributes in Markdown
@@ -34,11 +34,11 @@
 
 
 						## Slide 2
-						-- id="slide2" data-transition="zoom" data-background="#A0C66B"
+						<!-- -- id="slide2" data-transition="zoom" data-background="#A0C66B" -->
 
 
 						## Slide 2.1
-						-- data-background="#ff0000" data-transition="fade"
+						<!-- -- data-background="#ff0000" data-transition="fade" -->
 
 
 						## Slide 2.2
@@ -47,7 +47,7 @@
 
 
 						## Slide 3
-						-- data-transition="zoom" data-background="#C6916B"
+						<!-- -- data-transition="zoom" data-background="#C6916B" -->
 
 
 
diff --git a/test/test-markdown-element-attributes.html b/test/test-markdown-element-attributes.html
index e9f4038..6fe7f9a 100644
--- a/test/test-markdown-element-attributes.html
+++ b/test/test-markdown-element-attributes.html
@@ -24,19 +24,26 @@
 				<!-- Slides are separated by newline + three dashes + newline, vertical slides identical but two dashes -->
 				<section data-markdown data-separator="^\n---\n$" data-vertical="^\n--\n$" data-element-attributes="{_\s*?([^}]+?)}">>
 					<script type="text/template">
-						## Slide 1.1 {_class="fragment fade-out" data-fragment-index="1"}
+						## Slide 1.1
+						<!-- {_class="fragment fade-out" data-fragment-index="1"} -->
 
 						--
 
-						## Slide 1.2 {_class="fragment shrink"}
+						## Slide 1.2
+						<!-- {_class="fragment shrink"} -->
 
-						Paragraph 1 {_class="fragment grow"}
+						Paragraph 1
+						<!-- {_class="fragment grow"} -->
 
-						Paragraph 2 {_class="fragment grow"}
+						Paragraph 2
+						<!-- {_class="fragment grow"} -->
 
-						- list item 1  {_class="fragment roll-in"}
-						- list item 2  {_class="fragment roll-in"}
-						- list item 3  {_class="fragment roll-in"}
+						- list item 1
+						<!-- {_class="fragment roll-in"} -->
+						- list item 2
+						<!-- {_class="fragment roll-in"} -->
+						- list item 3
+						<!-- {_class="fragment roll-in"} -->
 
 
 						---
@@ -44,24 +51,34 @@
 						## Slide 2
 
 
-						Paragraph 1.2
-						multi-line {_class="fragment highlight-red"}
+						Paragraph 1.2  
+						multi-line
+						<!-- {_class="fragment highlight-red"} -->
 
-						Paragraph 2.2 {_class="fragment highlight-red"}
+						Paragraph 2.2
+						<!-- {_class="fragment highlight-red"} -->
 
-						Paragraph 2.3 {_class="fragment highlight-red"}
+						Paragraph 2.3
+						<!-- {_class="fragment highlight-red"} -->
 
-						Paragraph 2.4 {_class="fragment highlight-red"}
+						Paragraph 2.4
+						<!-- {_class="fragment highlight-red"} -->
 
-						- list item 1  {_class="fragment highlight-green"}
-						- list item 2  {_class="fragment highlight-green"}
-						- list item 3  {_class="fragment highlight-green"}
-						- list item 4  {_class="fragment highlight-green"}
-						- list item 5  {_class="fragment highlight-green"}
+						- list item 1
+						<!-- {_class="fragment highlight-green"} -->
+						- list item 2
+						<!-- {_class="fragment highlight-green"} -->
+						- list item 3
+						<!-- {_class="fragment highlight-green"} -->
+						- list item 4
+						<!-- {_class="fragment highlight-green"} -->
+						- list item 5
+						<!-- {_class="fragment highlight-green"} -->
 
 						Test
 
-						![Example Picture{_class="reveal stretch"}](assets/image2.png)
+						![Example Picture](examples/assets/image2.png)
+						<!-- {_class="reveal stretch"} -->
 
 					</script>
 				</section>
-- 
cgit v1.2.3


From d52eb599d1f732876540f2a22fa406b7293502e5 Mon Sep 17 00:00:00 2001
From: VonC
Date: Thu, 28 Nov 2013 22:10:23 +0100
Subject: Fix previous element selection.

---
 plugin/markdown/markdown.js | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/plugin/markdown/markdown.js b/plugin/markdown/markdown.js
index 34458f2..2f6fc44 100755
--- a/plugin/markdown/markdown.js
+++ b/plugin/markdown/markdown.js
@@ -303,16 +303,24 @@
 	 */
 	function addAttributes( section, element, previousElement, separatorElementAttributes, separatorSectionAttributes ) {
 
-		console.log("*** element='" + element.innerHTML + "', nodeType='" + element.nodeType + "'");
+		console.log("*** element='" + element.tagName + "', nodeType='" + element.nodeType + "'");
 		console.log("previousElement="+previousElement)
-		console.log("section=****"+section.outerHTML+"****");
+		//console.log("section=****"+section.outerHTML+"****");
 		if ( element != null && element.childNodes != undefined && element.childNodes.length > 0 ) {
 			previousParentElement = element;
 			for( var i = 0; i < element.childNodes.length; i++ ) {
 				childElement = element.childNodes[i];
-				console.log("  Child element='" + childElement.innerHTML + "', type " + childElement.nodeType);
-				if ( i > 0 && typeof element.childNodes[i-1].setAttribute == 'function' ) {
-					previousParentElement = element.childNodes[i-1];
+				console.log("  Child element='" + childElement.tagName + "', type " + childElement.nodeType);
+				if ( i > 0 ) {
+					j = i - 1;
+					while ( j >= 0 ) {
+						aPreviousChildElement = element.childNodes[j];
+						if ( typeof aPreviousChildElement.setAttribute == 'function' && aPreviousChildElement.tagName != "BR") {
+							previousParentElement = aPreviousChildElement;
+							break;
+						}
+						j = j - 1;
+					}
 				}
 				parentSection = section;
 				if( childElement.nodeName ==  "section" ) {
-- 
cgit v1.2.3


From 13da34cc6bf3b75cec3d4c2fd4f96b3f686fd8a9 Mon Sep 17 00:00:00 2001
From: VonC
Date: Thu, 28 Nov 2013 22:12:22 +0100
Subject: Removes console.log calls.

---
 plugin/markdown/markdown.js | 23 ++---------------------
 1 file changed, 2 insertions(+), 21 deletions(-)

diff --git a/plugin/markdown/markdown.js b/plugin/markdown/markdown.js
index 2f6fc44..6e12627 100755
--- a/plugin/markdown/markdown.js
+++ b/plugin/markdown/markdown.js
@@ -282,13 +282,11 @@
 		var mardownClassesInElementsRegex = new RegExp( separator, 'mg' );
 		var mardownClassRegex = new RegExp( "([^\"= ]+?)=\"([^\"=]+?)\"", 'mg' );
 		var nodeValue = node.nodeValue;
-		console.log("=== node.nodeValue='" + nodeValue + "' vs. separator '" + separator + "'");
 		if( matches = mardownClassesInElementsRegex.exec( nodeValue ) ) {
 
 			var classes = matches[1];
 			nodeValue = nodeValue.substring( 0, matches.index ) + nodeValue.substring( mardownClassesInElementsRegex.lastIndex );
 			node.nodeValue = nodeValue;
-			console.log("=========== classes='" + classes + "'");
 			while( matchesClass = mardownClassRegex.exec( classes ) ) {
 				elementTarget.setAttribute( matchesClass[1], matchesClass[2] );
 			}
@@ -303,19 +301,15 @@
 	 */
 	function addAttributes( section, element, previousElement, separatorElementAttributes, separatorSectionAttributes ) {
 
-		console.log("*** element='" + element.tagName + "', nodeType='" + element.nodeType + "'");
-		console.log("previousElement="+previousElement)
-		//console.log("section=****"+section.outerHTML+"****");
 		if ( element != null && element.childNodes != undefined && element.childNodes.length > 0 ) {
 			previousParentElement = element;
 			for( var i = 0; i < element.childNodes.length; i++ ) {
 				childElement = element.childNodes[i];
-				console.log("  Child element='" + childElement.tagName + "', type " + childElement.nodeType);
 				if ( i > 0 ) {
 					j = i - 1;
 					while ( j >= 0 ) {
 						aPreviousChildElement = element.childNodes[j];
-						if ( typeof aPreviousChildElement.setAttribute == 'function' && aPreviousChildElement.tagName != "BR") {
+						if ( typeof aPreviousChildElement.setAttribute == 'function' && aPreviousChildElement.tagName != "BR" ) {
 							previousParentElement = aPreviousChildElement;
 							break;
 						}
@@ -328,7 +322,6 @@
 					previousParentElement = childElement ;
 				}
 				if ( typeof childElement.setAttribute == 'function' || childElement.nodeType == Node.COMMENT_NODE ) {
-					console.log("   CALL addAttributes")
 					addAttributes( parentSection, childElement, previousParentElement, separatorElementAttributes, separatorSectionAttributes );
 				}
 			}
@@ -336,20 +329,9 @@
 
 		if ( element.nodeType == Node.COMMENT_NODE ) {
 			if ( addAttributeInElement( element, previousElement, separatorElementAttributes ) == false ) {
-				addAttributeInElement( element, section, separatorSectionAttributes);
+				addAttributeInElement( element, section, separatorSectionAttributes );
 			}
 		}
-		// From http://stackoverflow.com/questions/9178174/find-all-text-nodes
-		//if( element.nodeType == Node.TEXT_NODE && /\S/.test(element.nodeValue) ) {
-		//	addAttributeInElement( element, element.parentNode, separatorElementAttributes );
-		//}
-		//if( element.nodeType == Node.ELEMENT_NODE && element.attributes.length > 0 ) {
-		//	for( var j = 0; j < element.attributes.length; j++ ){
-		//		var attr = element.attributes[j];
-		//		addAttributeInElement( attr, element, separatorElementAttributes );
-		//	}
-		//}
-
 	}
 
 	/**
@@ -373,7 +355,6 @@
 				var markdown = getMarkdownFromSlide( section );
 
 				section.innerHTML = marked( markdown );
-				//console.log("markdown="+markdown);
 				addAttributes( 	section, section, null, section.getAttribute( 'data-element-attributes' ) ||
 								section.parentNode.getAttribute( 'data-element-attributes' ) ||
 								DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR,
-- 
cgit v1.2.3


From f2097417daca80b2caaed2661ee646e861d789c8 Mon Sep 17 00:00:00 2001
From: VonC
Date: Sat, 30 Nov 2013 22:29:04 +0100
Subject: Simpler default syntax for markdown attributes.

- on slides: .slide x=y
- on elements: .element x=y

Those are detected in html comment, in order to not be visible
if a markdown is edited in an html editor.
---
 plugin/markdown/markdown.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/plugin/markdown/markdown.js b/plugin/markdown/markdown.js
index 6e12627..19aea28 100755
--- a/plugin/markdown/markdown.js
+++ b/plugin/markdown/markdown.js
@@ -28,8 +28,8 @@
 
 	var DEFAULT_SLIDE_SEPARATOR = '^\n---\n$',
 		DEFAULT_NOTES_SEPARATOR = 'note:',
-		DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR = '{\\\.\s*?([^}]+?)}',
-		DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR = 'slide-attributes:\\\s(.*?)$';
+		DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR = '\\\.element\\\s*?(.+?)$',
+		DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR = '\\\.slide:\\\s*?(\\\S.+?)$';
 
 
 	/**
-- 
cgit v1.2.3


From d4e04b82dce155839dfca6aa933f012079fefe01 Mon Sep 17 00:00:00 2001
From: VonC
Date: Sat, 30 Nov 2013 23:06:47 +0100
Subject: test-markdown-attributes.*, new default separator

- Reformat.
- Change default separator test 'slide: x=y'
---
 test/test-markdown-attributes.html | 58 ++++++++++++++---------------
 test/test-markdown-attributes.js   | 76 +++++++++++++++++++-------------------
 2 files changed, 67 insertions(+), 67 deletions(-)

diff --git a/test/test-markdown-attributes.html b/test/test-markdown-attributes.html
index 6818cd5..94c146f 100644
--- a/test/test-markdown-attributes.html
+++ b/test/test-markdown-attributes.html
@@ -13,9 +13,9 @@
 	<body style="overflow: auto;">
 
 		<div id="qunit"></div>
-  		<div id="qunit-fixture"></div>
+		<div id="qunit-fixture"></div>
 
-		<div class="reveal" style="display: true;">
+		<div class="reveal" style="display: none;">
 
 			<div class="slides">
 
@@ -66,11 +66,11 @@
 
 
 						## Slide 2 Def
-						<!-- slide-attributes: id="slide2def" data-transition="concave" data-background="#A7C66B" -->
+						<!-- .slide: id="slide2def" data-transition="concave" data-background="#A7C66B" -->
 
 
 						## Slide 2.1 Def
-						<!-- slide-attributes: data-background="#f70000" data-transition="page" -->
+						<!-- .slide: data-background="#f70000" data-transition="page" -->
 
 
 						## Slide 2.2 Def
@@ -79,7 +79,7 @@
 
 
 						## Slide 3 Def
-						<!-- slide-attributes: data-transition="concave" data-background="#C7916B" -->
+						<!-- .slide: data-transition="concave" data-background="#C7916B" -->
 
 
 
@@ -87,30 +87,30 @@
 					</script>
 				</section>
 
-        <section data-markdown>
-          <script type="text/template">
-            <!-- slide-attributes: data-background="#ff0000" -->
-            ## Hello world
-          </script>
-        </section>
-
-        <section data-markdown>
-          <script type="text/template">
-            ## Hello world
-            <!-- slide-attributes: data-background="#ff0000" -->
-          </script>
-        </section>
-
-        <section data-markdown>
-          <script type="text/template">
-            ## Hello world
-
-            Test
-            <!-- slide-attributes: data-background="#ff0000" -->
-
-            More Test
-          </script>
-        </section>
+				<section data-markdown>
+					<script type="text/template">
+						<!-- .slide: data-background="#ff0000" -->
+						## Hello world
+					</script>
+				</section>
+
+				<section data-markdown>
+					<script type="text/template">
+						## Hello world
+						<!-- .slide: data-background="#ff0000" -->
+					</script>
+				</section>
+
+				<section data-markdown>
+					<script type="text/template">
+						## Hello world
+
+						Test
+						<!-- .slide: data-background="#ff0000" -->
+
+						More Test
+					</script>
+				</section>
 
 			</div>
 
diff --git a/test/test-markdown-attributes.js b/test/test-markdown-attributes.js
index a11f63b..3817fd3 100644
--- a/test/test-markdown-attributes.js
+++ b/test/test-markdown-attributes.js
@@ -2,44 +2,44 @@
 
 Reveal.addEventListener( 'ready', function() {
 
-  QUnit.module( 'Markdown' );
-
-  test( 'Vertical separator', function() {
-    strictEqual( document.querySelectorAll( '.reveal .slides>section>section' ).length, 6, 'found six vertical slides' );
-  });
-
-  test( 'Id on slide', function() {
-    strictEqual( document.querySelectorAll( '.reveal .slides>section>section#slide2' ).length, 1, 'found one slide with id slide2' );
-    strictEqual( document.querySelectorAll( '.reveal .slides>section>section a[href="#/slide2"]' ).length, 1, 'found one slide with a link to slide2' );
-  });
-
-  test( 'data-background attributes', function() {
-    strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-background="#A0C66B"]' ).length, 1, 'found one vertical slide with data-background="#A0C66B"' );
-    strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-background="#ff0000"]' ).length, 1, 'found one vertical slide with data-background="#ff0000"' );
-    strictEqual( document.querySelectorAll( '.reveal .slides>section[data-background="#C6916B"]' ).length, 1, 'found one slide with data-background="#C6916B"' );
-  });
-
-  test( 'data-transition attributes', function() {
-    strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-transition="zoom"]' ).length, 1, 'found one vertical slide with data-transition="zoom"' );
-    strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-transition="fade"]' ).length, 1, 'found one vertical slide with data-transition="fade"' );
-    strictEqual( document.querySelectorAll( '.reveal .slides section [data-transition="zoom"]' ).length, 1, 'found one slide with data-transition="zoom"' );
-  });
-
-  test( 'data-background attributes with default separator', function() {
-    strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-background="#A7C66B"]' ).length, 1, 'found one vertical slide with data-background="#A0C66B"' );
-    strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-background="#f70000"]' ).length, 1, 'found one vertical slide with data-background="#ff0000"' );
-    strictEqual( document.querySelectorAll( '.reveal .slides>section[data-background="#C7916B"]' ).length, 1, 'found one slide with data-background="#C6916B"' );
-  });
-
-  test( 'data-transition attributes with default separator', function() {
-    strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-transition="concave"]' ).length, 1, 'found one vertical slide with data-transition="zoom"' );
-    strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-transition="page"]' ).length, 1, 'found one vertical slide with data-transition="fade"' );
-    strictEqual( document.querySelectorAll( '.reveal .slides section [data-transition="concave"]' ).length, 1, 'found one slide with data-transition="zoom"' );
-  });
-
-  test( 'data-transition attributes with inline content', function() {
-    strictEqual( document.querySelectorAll( '.reveal .slides>section[data-background="#ff0000"]' ).length, 3, 'found three horizontal slides with data-background="#ff0000"' );
-  });
+	QUnit.module( 'Markdown' );
+
+	test( 'Vertical separator', function() {
+		strictEqual( document.querySelectorAll( '.reveal .slides>section>section' ).length, 6, 'found six vertical slides' );
+	});
+
+	test( 'Id on slide', function() {
+		strictEqual( document.querySelectorAll( '.reveal .slides>section>section#slide2' ).length, 1, 'found one slide with id slide2' );
+		strictEqual( document.querySelectorAll( '.reveal .slides>section>section a[href="#/slide2"]' ).length, 1, 'found one slide with a link to slide2' );
+	});
+
+	test( 'data-background attributes', function() {
+		strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-background="#A0C66B"]' ).length, 1, 'found one vertical slide with data-background="#A0C66B"' );
+		strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-background="#ff0000"]' ).length, 1, 'found one vertical slide with data-background="#ff0000"' );
+		strictEqual( document.querySelectorAll( '.reveal .slides>section[data-background="#C6916B"]' ).length, 1, 'found one slide with data-background="#C6916B"' );
+	});
+
+	test( 'data-transition attributes', function() {
+		strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-transition="zoom"]' ).length, 1, 'found one vertical slide with data-transition="zoom"' );
+		strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-transition="fade"]' ).length, 1, 'found one vertical slide with data-transition="fade"' );
+		strictEqual( document.querySelectorAll( '.reveal .slides section [data-transition="zoom"]' ).length, 1, 'found one slide with data-transition="zoom"' );
+	});
+
+	test( 'data-background attributes with default separator', function() {
+		strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-background="#A7C66B"]' ).length, 1, 'found one vertical slide with data-background="#A0C66B"' );
+		strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-background="#f70000"]' ).length, 1, 'found one vertical slide with data-background="#ff0000"' );
+		strictEqual( document.querySelectorAll( '.reveal .slides>section[data-background="#C7916B"]' ).length, 1, 'found one slide with data-background="#C6916B"' );
+	});
+
+	test( 'data-transition attributes with default separator', function() {
+		strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-transition="concave"]' ).length, 1, 'found one vertical slide with data-transition="zoom"' );
+		strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-transition="page"]' ).length, 1, 'found one vertical slide with data-transition="fade"' );
+		strictEqual( document.querySelectorAll( '.reveal .slides section [data-transition="concave"]' ).length, 1, 'found one slide with data-transition="zoom"' );
+	});
+
+	test( 'data-transition attributes with inline content', function() {
+		strictEqual( document.querySelectorAll( '.reveal .slides>section[data-background="#ff0000"]' ).length, 3, 'found three horizontal slides with data-background="#ff0000"' );
+	});
 
 } );
 
-- 
cgit v1.2.3


From 78dfbf520213d554eef6f1ab925742cf7035e803 Mon Sep 17 00:00:00 2001
From: VonC
Date: Sat, 30 Nov 2013 23:08:43 +0100
Subject: test-markdown-element-attributes: formats and test.

- Reformat
- Use new default separator format: '.element: x=y'
- Add new tests for testing that default format
---
 test/test-markdown-element-attributes.html | 85 +++++++++++++++++++++---------
 test/test-markdown-element-attributes.js   | 22 +++++---
 2 files changed, 75 insertions(+), 32 deletions(-)

diff --git a/test/test-markdown-element-attributes.html b/test/test-markdown-element-attributes.html
index 6fe7f9a..b638082 100644
--- a/test/test-markdown-element-attributes.html
+++ b/test/test-markdown-element-attributes.html
@@ -4,7 +4,7 @@
 	<head>
 		<meta charset="utf-8">
 
-		<title>reveal.js - Test Markdown</title>
+		<title>reveal.js - Test Markdown Element Attributes</title>
 
 		<link rel="stylesheet" href="../css/reveal.min.css">
 		<link rel="stylesheet" href="qunit-1.12.0.css">
@@ -13,9 +13,9 @@
 	<body style="overflow: auto;">
 
 		<div id="qunit"></div>
-  		<div id="qunit-fixture"></div>
+		<div id="qunit-fixture"></div>
 
-		<div class="reveal" style="display: true;">
+		<div class="reveal" style="display: none;">
 
 			<div class="slides">
 
@@ -38,12 +38,9 @@
 						Paragraph 2
 						<!-- {_class="fragment grow"} -->
 
-						- list item 1
-						<!-- {_class="fragment roll-in"} -->
-						- list item 2
-						<!-- {_class="fragment roll-in"} -->
-						- list item 3
-						<!-- {_class="fragment roll-in"} -->
+						- list item 1 <!-- {_class="fragment roll-in"} -->
+						- list item 2 <!-- {_class="fragment roll-in"} -->
+						- list item 3 <!-- {_class="fragment roll-in"} -->
 
 
 						---
@@ -52,28 +49,20 @@
 
 
 						Paragraph 1.2  
-						multi-line
-						<!-- {_class="fragment highlight-red"} -->
+						multi-line <!-- {_class="fragment highlight-red"} -->
 
-						Paragraph 2.2
-						<!-- {_class="fragment highlight-red"} -->
+						Paragraph 2.2 <!-- {_class="fragment highlight-red"} -->
 
-						Paragraph 2.3
-						<!-- {_class="fragment highlight-red"} -->
+						Paragraph 2.3 <!-- {_class="fragment highlight-red"} -->
 
-						Paragraph 2.4
-						<!-- {_class="fragment highlight-red"} -->
+						Paragraph 2.4 <!-- {_class="fragment highlight-red"} -->
 
-						- list item 1
-						<!-- {_class="fragment highlight-green"} -->
-						- list item 2
-						<!-- {_class="fragment highlight-green"} -->
-						- list item 3
-						<!-- {_class="fragment highlight-green"} -->
+						- list item 1 <!-- {_class="fragment highlight-green"} -->
+						- list item 2<!-- {_class="fragment highlight-green"} -->
+						- list item 3<!-- {_class="fragment highlight-green"} -->
 						- list item 4
 						<!-- {_class="fragment highlight-green"} -->
-						- list item 5
-						<!-- {_class="fragment highlight-green"} -->
+						- list item 5<!-- {_class="fragment highlight-green"} -->
 
 						Test
 
@@ -83,6 +72,52 @@
 					</script>
 				</section>
 
+
+
+				<section 	data-markdown data-separator="^\n\n\n"
+									data-vertical="^\n\n"
+									data-notes="^Note:"
+									data-charset="utf-8">
+					<script type="text/template">
+						# Test attributes in Markdown with default separator
+						## Slide 1 Def <!-- .element: class="fragment highlight-red" data-fragment-index="1" -->
+
+
+						## Slide 2 Def
+						<!-- .element: class="fragment highlight-red" -->
+
+					</script>
+				</section>
+
+				<section data-markdown>
+				  <script type="text/template">
+					## Hello world
+					A paragraph
+					<!-- .element: class="fragment highlight-blue" -->
+				  </script>
+				</section>
+
+				<section data-markdown>
+				  <script type="text/template">
+					## Hello world
+
+					Multiple  
+					Line
+					<!-- .element: class="fragment highlight-blue" -->
+				  </script>
+				</section>
+
+				<section data-markdown>
+				  <script type="text/template">
+					## Hello world
+
+					Test<!-- .element: class="fragment highlight-blue" -->
+
+					More Test
+				  </script>
+				</section>
+
+
 			</div>
 
 		</div>
diff --git a/test/test-markdown-element-attributes.js b/test/test-markdown-element-attributes.js
index e79806c..4541077 100644
--- a/test/test-markdown-element-attributes.js
+++ b/test/test-markdown-element-attributes.js
@@ -5,33 +5,41 @@ Reveal.addEventListener( 'ready', function() {
 	QUnit.module( 'Markdown' );
 
 	test( 'Vertical separator', function() {
-		strictEqual( document.querySelectorAll( '.reveal .slides>section>section' ).length, 2, 'found two slides' );
+		strictEqual( document.querySelectorAll( '.reveal .slides>section>section' ).length, 4, 'found four slides' );
 	});
 
 
-	test( 'Attributes on vertical slides header', function() {
+	test( 'Attributes on element header in vertical slides', function() {
 		strictEqual( document.querySelectorAll( '.reveal .slides section>section h2.fragment.fade-out' ).length, 1, 'found one vertical slide with class fragment.fade-out on header' );
 		strictEqual( document.querySelectorAll( '.reveal .slides section>section h2.fragment.shrink' ).length, 1, 'found one vertical slide with class fragment.shrink on header' );
 	});
 
-	test( 'Attributes on vertical slides paragraphs', function() {
+	test( 'Attributes on element paragraphs in vertical slides', function() {
 		strictEqual( document.querySelectorAll( '.reveal .slides section>section p.fragment.grow' ).length, 2, 'found a vertical slide with two paragraphs with class fragment.grow' );
 	});
 
-	test( 'Attributes on vertical slides list items', function() {
+	test( 'Attributes on element list items in vertical slides', function() {
 		strictEqual( document.querySelectorAll( '.reveal .slides section>section li.fragment.roll-in' ).length, 3, 'found a vertical slide with three list items with class fragment.roll-in' );
 	});
 
-	test( 'Attributes on horizontal slides paragraphs', function() {
+	test( 'Attributes on element paragraphs in horizontal slides', function() {
 		strictEqual( document.querySelectorAll( '.reveal .slides section p.fragment.highlight-red' ).length, 4, 'found a horizontal slide with four paragraphs with class fragment.grow' );
 	});
-	test( 'Attributes on horizontal slides list items', function() {
+	test( 'Attributes on element list items in horizontal slides', function() {
 		strictEqual( document.querySelectorAll( '.reveal .slides section li.fragment.highlight-green' ).length, 5, 'found a horizontal slide with five list items with class fragment.roll-in' );
 	});
-	test( 'Attributes on horizontal slides list items', function() {
+	test( 'Attributes on element list items in horizontal slides', function() {
 		strictEqual( document.querySelectorAll( '.reveal .slides section img.reveal.stretch' ).length, 1, 'found a horizontal slide with stretched image, class img.reveal.stretch' );
 	});
 
+	test( 'Attributes on elements in vertical slides with default element attribute separator', function() {
+		strictEqual( document.querySelectorAll( '.reveal .slides section h2.fragment.highlight-red' ).length, 2, 'found two h2 titles with fragment highlight-red in vertical slides with default element attribute separator' );
+	});
+
+	test( 'Attributes on elements in single slides with default element attribute separator', function() {
+		strictEqual( document.querySelectorAll( '.reveal .slides section p.fragment.highlight-blue' ).length, 3, 'found three elements with fragment highlight-blue in single slide with default element attribute separator' );
+	});
+
 } );
 
 Reveal.initialize();
-- 
cgit v1.2.3


From fdb03b4f1081508705c53ca31f679fb8793a8a95 Mon Sep 17 00:00:00 2001
From: VonC
Date: Sat, 30 Nov 2013 23:11:13 +0100
Subject: README.md mentions the new default separators.

- new default separator for slide attributes
- new default separator for element attributes
Illustrate both, in html comments.
---
 README.md | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/README.md b/README.md
index f224e5e..9c84a32 100644
--- a/README.md
+++ b/README.md
@@ -60,25 +60,25 @@ You can write your content as a separate file and have reveal.js load it at runt
 
 #### Element Attributes
 
-Special syntax is available for adding attributes to Markdown elements. This is useful for fragments, amongst other things.
+Special syntax (in html comment) is available for adding attributes to Markdown elements. This is useful for fragments, amongst other things.
 
 ```html
 <section data-markdown>
 	<script type="text/template">
-		- Item 1 {.class="fragment" data-fragment-index="2"}
-		- Item 2 {.class="fragment" data-fragment-index="1"}
+		- Item 1 <!-- .element: class="fragment" data-fragment-index="2" -->
+		- Item 2 <!-- .element: class="fragment" data-fragment-index="1" -->
 	</script>
 </section>
 ```
 
 #### Slide Attributes
 
-Special syntax is available for adding attributes to the slide `<section>` elements generated by your Markdown.
+Special syntax (in html comment) is available for adding attributes to the slide `<section>` elements generated by your Markdown.
 
 ```html
 <section data-markdown>
 	<script type="text/template">
-	<!-- slide-attributes: data-background="#ff0000" -->
+	<!-- slide: data-background="#ff0000" -->
 		Mardown content
 	</script>
 </section>
-- 
cgit v1.2.3