|
323 | 323 | while( matchesClass = mardownClassRegex.exec( classes ) ) {
|
324 | 324 | elementTarget.setAttribute( matchesClass[1], matchesClass[2] );
|
325 | 325 | }
|
| 326 | + return true; |
326 | 327 | }
|
327 |
| - |
| 328 | + return false; |
328 | 329 | }
|
329 | 330 |
|
330 | 331 | /**
|
331 | 332 | * Add attributes to the parent element of a text node,
|
332 | 333 | * or the element of an attribute node.
|
333 | 334 | */
|
334 |
| - function addAttributes( element, separator ) { |
| 335 | + function addAttributes( section, element, previousElement, separatorElementAttributes, separatorSectionAttributes ) { |
335 | 336 |
|
336 |
| - if( element.childNodes.length > 0 ) { |
| 337 | + console.log("element='" + element.innerHTML + "', nodeType='" + element.nodeType + "'"); |
| 338 | + console.log("previousElement="+previousElement) |
| 339 | + console.log("section=****"+section.outerHTML+"****"); |
| 340 | + if( element != null && element.childNodes != undefined && element.childNodes.length > 0 ) { |
| 341 | + previousParentElement = element; |
337 | 342 | for( var i = 0; i < element.childNodes.length; i++ ) {
|
338 |
| - addAttributes( element.childNodes[i], separator ); |
| 343 | + childElement = element.childNodes[i]; |
| 344 | + console.log(" Child element='" + childElement.innerHTML + "'"); |
| 345 | + if ( i > 0 ) { |
| 346 | + previousParentElement = element.childNodes[i-1]; |
| 347 | + } |
| 348 | + parentSection = section; |
| 349 | + if( childElement.nodeName == "section" ) { |
| 350 | + parentSection = childElement ; |
| 351 | + previousParentElement = childElement ; |
| 352 | + } |
| 353 | + addAttributes( parentSection, childElement, previousParentElement, separatorElementAttributes, separatorSectionAttributes ); |
339 | 354 | }
|
340 | 355 | }
|
341 | 356 |
|
342 |
| - var nodeValue; |
343 |
| - var elementTarget; |
344 |
| - |
| 357 | + if ( element.nodeType == Node.COMMENT_NODE ) { |
| 358 | + if ( addAttributeInElement( element, previousElement, separatorElementAttributes ) == false ) { |
| 359 | + addAttributeInElement( element, section, separatorSectionAttributes); |
| 360 | + } |
| 361 | + } |
345 | 362 | // From http://stackoverflow.com/questions/9178174/find-all-text-nodes
|
346 | 363 | if( element.nodeType == Node.TEXT_NODE && /\S/.test(element.nodeValue) ) {
|
347 |
| - addAttributeInElement( element, element.parentNode, separator ); |
| 364 | + addAttributeInElement( element, element.parentNode, separatorElementAttributes ); |
348 | 365 | }
|
349 | 366 | if( element.nodeType == Node.ELEMENT_NODE && element.attributes.length > 0 ) {
|
350 | 367 | for( var j = 0; j < element.attributes.length; j++ ){
|
351 | 368 | var attr = element.attributes[j];
|
352 |
| - addAttributeInElement( attr, element, separator ); |
| 369 | + addAttributeInElement( attr, element, separatorElementAttributes ); |
353 | 370 | }
|
354 | 371 | }
|
355 | 372 |
|
|
376 | 393 | var markdown = getMarkdownFromSlide( section );
|
377 | 394 |
|
378 | 395 | section.innerHTML = marked( markdown );
|
379 |
| - addAttributes( section, section.getAttribute( 'data-element-attributes' ) || |
| 396 | + //console.log("markdown="+markdown); |
| 397 | + addAttributes( section, section, null, section.getAttribute( 'data-element-attributes' ) || |
380 | 398 | section.parentNode.getAttribute( 'data-element-attributes' ) ||
|
381 |
| - DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR ); |
| 399 | + DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR, |
| 400 | + section.getAttribute( 'data-attributes' ) || |
| 401 | + section.parentNode.getAttribute( 'data-attributes' ) || |
| 402 | + DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR); |
382 | 403 |
|
383 | 404 | // If there were notes, we need to re-add them after
|
384 | 405 | // having overwritten the section's HTML
|
|
0 commit comments