aboutsummaryrefslogtreecommitdiff
path: root/lib/js
diff options
context:
space:
mode:
authorHakim El Hattab <hakim.elhattab@gmail.com>2012-10-08 09:15:36 -0400
committerHakim El Hattab <hakim.elhattab@gmail.com>2012-10-08 09:15:36 -0400
commit25efef8c4f1275db62925ed18bab7282a5b767b2 (patch)
treeec8fcf715ddef526d62f6dc8e412da09102bf7d3 /lib/js
parentf22e5f85e8284aaca724c372e8f9efdfd9b11943 (diff)
downloadfosdem-2018-presentation-25efef8c4f1275db62925ed18bab7282a5b767b2.tar
fosdem-2018-presentation-25efef8c4f1275db62925ed18bab7282a5b767b2.tar.gz
wrap markdown in script text/template to fix parsing errors (closes #146 #155 #162)
Diffstat (limited to 'lib/js')
-rw-r--r--lib/js/data-markdown.js13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/js/data-markdown.js b/lib/js/data-markdown.js
index 84398a0..80f8eb0 100644
--- a/lib/js/data-markdown.js
+++ b/lib/js/data-markdown.js
@@ -2,13 +2,15 @@
// Modified by Hakim to handle Markdown indented with tabs
(function(){
- var slides = document.querySelectorAll('[data-markdown]');
+ var sections = document.querySelectorAll( '[data-markdown]' );
- for( var i = 0, len = slides.length; i < len; i++ ) {
- var elem = slides[i];
+ for( var i = 0, len = sections.length; i < len; i++ ) {
+ var section = sections[i];
+
+ var template = section.querySelector( 'script' );
// strip leading whitespace so it isn't evaluated as code
- var text = elem.innerHTML;
+ var text = ( template || section ).innerHTML;
var leadingWs = text.match(/^\n?(\s*)/)[1].length,
leadingTabs = text.match(/^\n?(\t*)/)[1].length;
@@ -20,8 +22,7 @@
text = text.replace( new RegExp('\\n? {' + leadingWs + '}','g'), '\n' );
}
- // here, have sum HTML
- elem.innerHTML = (new Showdown.converter()).makeHtml(text);
+ section.innerHTML = (new Showdown.converter()).makeHtml(text);
}
})(); \ No newline at end of file