1
0
Fork 0

format tweaks markdown.js, remove extra image asset

This commit is contained in:
Hakim El Hattab 2013-10-28 09:06:43 -04:00
parent 6cf5269bfc
commit d844195be1
3 changed files with 22 additions and 20 deletions

View File

@ -28,7 +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*?([^}]+?)}'; DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR = '{_\s*?([^}]+?)}';
/** /**
@ -278,6 +278,7 @@
* 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, separator ) { function addAttributeInElement( node, elementTarget, separator ) {
var mardownClassesInElementsRegex = new RegExp( separator, '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;
@ -291,32 +292,35 @@
elementTarget.setAttribute( matchesClass[1], matchesClass[2] ); elementTarget.setAttribute( matchesClass[1], matchesClass[2] );
} }
} }
} }
/** /**
* 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, separator ) 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], separator ); 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, separator ); 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( var j = 0; j < element.attributes.length; j++ ){
var attr = element.attributes[iattr]; var attr = element.attributes[j];
addAttributeInElement(attr, element, separator ) addAttributeInElement( attr, element, separator );
} }
} }
} }
/** /**

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -22,9 +22,7 @@
<!-- <section data-markdown="example.md" data-separator="^\n\n\n" data-vertical="^\n\n"></section> --> <!-- <section data-markdown="example.md" data-separator="^\n\n\n" data-vertical="^\n\n"></section> -->
<!-- Slides are separated by newline + three dashes + newline, vertical slides identical but two dashes --> <!-- Slides are separated by newline + three dashes + newline, vertical slides identical but two dashes -->
<section data-markdown data-separator="^\n---\n$" <section data-markdown data-separator="^\n---\n$" data-vertical="^\n--\n$">
data-vertical="^\n--\n$"
data-element-attributes="{_\s*?([^}]+?)}">
<script type="text/template"> <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"}
@ -63,7 +61,7 @@
Test Test
![Example Picture{_class="reveal stretch"}](red-curtain-50x50.jpg) ![Example Picture{_class="reveal stretch"}](assets/image2.png)
</script> </script>
</section> </section>