From: Hakim El Hattab Date: Mon, 8 Oct 2012 13:15:36 +0000 (-0400) Subject: wrap markdown in script text/template to fix parsing errors (closes #146 #155 #162) X-Git-Tag: 2.1.0~51 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=25efef8c4f1275db62925ed18bab7282a5b767b2;p=reveal.js.git wrap markdown in script text/template to fix parsing errors (closes #146 #155 #162) --- diff --git a/README.md b/README.md index 5ad4a8a..8511f90 100644 --- a/README.md +++ b/README.md @@ -35,15 +35,17 @@ Markup heirarchy needs to be ``
``` elements and reveal.js will automatically load the JavaScript parser. +It's possible to write your slides using Markdown. To enable Markdown simply add the ```data-markdown``` attribute to your ```
``` elements and reveal.js will automatically load the JavaScript parser. Additionally, you should wrap the contents in a ```
``` diff --git a/index.html b/index.html index b5625c9..ce10815 100644 --- a/index.html +++ b/index.html @@ -36,6 +36,7 @@
+

Reveal.js

HTML Presentations Made Easy

@@ -129,17 +130,18 @@
- ## Markdown support - - For those of you who like that sort of thing. Instructions and a bit more info available [here](https://github.com/hakimel/reveal.js#markdown). +
@@ -314,6 +316,7 @@ function linkify( selector ) {

THE END

BY Hakim El Hattab / hakim.se

+
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