Add slide attributes for single slide section case.
This commit is contained in:
parent
efbb31cf29
commit
4b0fe47bb6
|
@ -283,9 +283,18 @@
|
|||
|
||||
}
|
||||
else {
|
||||
|
||||
section.innerHTML = createMarkdownSlide( getMarkdownFromSlide( section ) );
|
||||
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -87,6 +87,31 @@
|
|||
</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>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -36,6 +36,11 @@ Reveal.addEventListener( 'ready', function() {
|
|||
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"' );
|
||||
});
|
||||
|
||||
} );
|
||||
|
||||
Reveal.initialize();
|
||||
|
|
Loading…
Reference in New Issue