|
29 | 29 | var DEFAULT_SLIDE_SEPARATOR = '^\n---\n$',
|
30 | 30 | DEFAULT_NOTES_SEPARATOR = 'note:',
|
31 | 31 | DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR = '{\\\.\s*?([^}]+?)}',
|
32 |
| - DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR = '^.*?<!--\\\sslide-attributes:\\\s(.*?)-->'; |
| 32 | + DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR = 'slide-attributes:\\\s(.*?)$'; |
33 | 33 |
|
34 | 34 |
|
35 | 35 | /**
|
|
73 | 73 | value = attributes[i].value;
|
74 | 74 |
|
75 | 75 | // disregard attributes that are used for markdown loading/parsing
|
76 |
| - if( /data\-(markdown|separator|vertical|notes|attributes)/gi.test( name ) ) continue; |
| 76 | + if( /data\-(markdown|separator|vertical|notes)/gi.test( name ) ) continue; |
77 | 77 |
|
78 | 78 | if( value ) {
|
79 | 79 | result.push( name + '=' + value );
|
|
282 | 282 | var mardownClassesInElementsRegex = new RegExp( separator, 'mg' );
|
283 | 283 | var mardownClassRegex = new RegExp( "([^\"= ]+?)=\"([^\"=]+?)\"", 'mg' );
|
284 | 284 | var nodeValue = node.nodeValue;
|
| 285 | + console.log("=== node.nodeValue='" + nodeValue + "' vs. separator '" + separator + "'"); |
285 | 286 | if( matches = mardownClassesInElementsRegex.exec( nodeValue ) ) {
|
286 | 287 |
|
287 | 288 | var classes = matches[1];
|
288 | 289 | nodeValue = nodeValue.substring( 0, matches.index ) + nodeValue.substring( mardownClassesInElementsRegex.lastIndex );
|
289 | 290 | node.nodeValue = nodeValue;
|
290 |
| - |
| 291 | + console.log("=========== classes='" + classes + "'"); |
291 | 292 | while( matchesClass = mardownClassRegex.exec( classes ) ) {
|
292 | 293 | elementTarget.setAttribute( matchesClass[1], matchesClass[2] );
|
293 | 294 | }
|
|
302 | 303 | */
|
303 | 304 | function addAttributes( section, element, previousElement, separatorElementAttributes, separatorSectionAttributes ) {
|
304 | 305 |
|
305 |
| - console.log("element='" + element.innerHTML + "', nodeType='" + element.nodeType + "'"); |
| 306 | + console.log("*** element='" + element.innerHTML + "', nodeType='" + element.nodeType + "'"); |
306 | 307 | console.log("previousElement="+previousElement)
|
307 | 308 | console.log("section=****"+section.outerHTML+"****");
|
308 |
| - if( element != null && element.childNodes != undefined && element.childNodes.length > 0 ) { |
| 309 | + if ( element != null && element.childNodes != undefined && element.childNodes.length > 0 ) { |
309 | 310 | previousParentElement = element;
|
310 | 311 | for( var i = 0; i < element.childNodes.length; i++ ) {
|
311 | 312 | childElement = element.childNodes[i];
|
312 |
| - console.log(" Child element='" + childElement.innerHTML + "'"); |
313 |
| - if ( i > 0 ) { |
| 313 | + console.log(" Child element='" + childElement.innerHTML + "', type " + childElement.nodeType); |
| 314 | + if ( i > 0 && typeof element.childNodes[i-1].setAttribute == 'function' ) { |
314 | 315 | previousParentElement = element.childNodes[i-1];
|
315 | 316 | }
|
316 | 317 | parentSection = section;
|
317 | 318 | if( childElement.nodeName == "section" ) {
|
318 | 319 | parentSection = childElement ;
|
319 | 320 | previousParentElement = childElement ;
|
320 | 321 | }
|
321 |
| - addAttributes( parentSection, childElement, previousParentElement, separatorElementAttributes, separatorSectionAttributes ); |
| 322 | + if ( typeof childElement.setAttribute == 'function' || childElement.nodeType == Node.COMMENT_NODE ) { |
| 323 | + console.log(" CALL addAttributes") |
| 324 | + addAttributes( parentSection, childElement, previousParentElement, separatorElementAttributes, separatorSectionAttributes ); |
| 325 | + } |
322 | 326 | }
|
323 | 327 | }
|
324 | 328 |
|
|
328 | 332 | }
|
329 | 333 | }
|
330 | 334 | // From http://stackoverflow.com/questions/9178174/find-all-text-nodes
|
331 |
| - if( element.nodeType == Node.TEXT_NODE && /\S/.test(element.nodeValue) ) { |
332 |
| - addAttributeInElement( element, element.parentNode, separatorElementAttributes ); |
333 |
| - } |
334 |
| - if( element.nodeType == Node.ELEMENT_NODE && element.attributes.length > 0 ) { |
335 |
| - for( var j = 0; j < element.attributes.length; j++ ){ |
336 |
| - var attr = element.attributes[j]; |
337 |
| - addAttributeInElement( attr, element, separatorElementAttributes ); |
338 |
| - } |
339 |
| - } |
| 335 | + //if( element.nodeType == Node.TEXT_NODE && /\S/.test(element.nodeValue) ) { |
| 336 | + // addAttributeInElement( element, element.parentNode, separatorElementAttributes ); |
| 337 | + //} |
| 338 | + //if( element.nodeType == Node.ELEMENT_NODE && element.attributes.length > 0 ) { |
| 339 | + // for( var j = 0; j < element.attributes.length; j++ ){ |
| 340 | + // var attr = element.attributes[j]; |
| 341 | + // addAttributeInElement( attr, element, separatorElementAttributes ); |
| 342 | + // } |
| 343 | + //} |
340 | 344 |
|
341 | 345 | }
|
342 | 346 |
|
|
0 commit comments