aboutsummaryrefslogtreecommitdiff
path: root/plugin/markdown
diff options
context:
space:
mode:
authorVonC <vonc@laposte.net>2013-10-10 10:57:18 +0200
committerVonC <vonc@laposte.net>2013-11-04 16:31:18 +0100
commitf6445a04a0270b83e46243c0d1ed23f27d64396b (patch)
tree7f011c439b2fe237a4b87da063401cb4f6f2d174 /plugin/markdown
parentc51ab74d7293642b2b8d5267b9355df6c45e0102 (diff)
downloadfreenode-live-2017-presentation-f6445a04a0270b83e46243c0d1ed23f27d64396b.tar
freenode-live-2017-presentation-f6445a04a0270b83e46243c0d1ed23f27d64396b.tar.gz
Fix bug on data attributes for first vertical slide.
The first slide of a vertical stack see some data attributes ignored. Mainly the data-transition one. Repeat all data-attributes on the wrapping section element. Ignore any other attributes (like 'id="xxx"'), in order to not mess with internal links (by repeating twice an id).
Diffstat (limited to 'plugin/markdown')
-rwxr-xr-xplugin/markdown/markdown.js15
1 files changed, 14 insertions, 1 deletions
diff --git a/plugin/markdown/markdown.js b/plugin/markdown/markdown.js
index b5476aa..537a0c5 100755
--- a/plugin/markdown/markdown.js
+++ b/plugin/markdown/markdown.js
@@ -178,12 +178,25 @@
for( var i = 0, len = sectionStack.length; i < len; i++ ) {
// vertical
if( sectionStack[i] instanceof Array ) {
- markdownSections += '<section '+ options.attributes +'>';
+ // 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] : "";
+ if( slideAttributes != "") {
+ // console.log('all attr=' + 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 || ''; });
+ // console.log('new attr=' + dataAttributes );
+ markdownSections += '<section '+ options.attributes + ' ' + dataAttributes + '>';
+ }
sectionStack[i].forEach( function( child ) {
matchAttributes = slideAttributesSeparatorRegex.exec(child);
slideAttributes = matchAttributes ? matchAttributes[1] : "";
child = matchAttributes ? child.replace(slideAttributesSeparatorRegex,"") : child
+ // console.log('slide attributes ' + options.slideAttributesSeparator + ' => ' + slideAttributes)
markdownSections += '<section ' + slideAttributes + ' data-markdown>' + createMarkdownSlide( child, options ) + '</section>';
} );