It's possible to write your slides using Markdown. To enable Markdown simply add the ```data-markdown``` attribute to your ```<section>``` elements and reveal.js will automatically load the JavaScript parser.
-This is based on [data-markdown](https://gist.github.com/1343518) from [Paul Irish](https://github.com/paulirish) which in turn uses [showdown](https://github.com/coreyti/showdown/). Syntax support seems limited judging by my initial tests, this may be due to conflicts with the reveal.js styles. Updates to come.
+This is based on [data-markdown](https://gist.github.com/1343518) from [Paul Irish](https://github.com/paulirish) which in turn uses [showdown](https://github.com/coreyti/showdown/). This is sensitive to indentation (avoid mixing tabs and spaces) and line breaks (avoid consecutive breaks). Updates to come.
```html
<section data-markdown>
<section data-markdown>
## 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).
+ 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).
<pre><code contenteditable style="margin-top: 20px;"><section data-markdown>
## Markdown support
hljs.initHighlightingOnLoad();
} );
</script>
-
+
</body>
</html>
\ No newline at end of file
-// From https://gist.github.com/1343518, modified to not load showdown
+// From https://gist.github.com/1343518
+// Modified by Hakim to handle markdown indented with tabs
(function(){
[].forEach.call( document.querySelectorAll('[data-markdown]'), function fn(elem){
// strip leading whitespace so it isn't evaluated as code
- var text = elem.innerHTML.replace(/\n\s*\n/g,'\n'),
- // set indentation level so your markdown can be indented within your HTML
- leadingws = text.match(/^\n?(\s*)/)[1].length,
- regex = new RegExp('\\n?\\s{' + leadingws + '}','g'),
- md = text.replace(regex,'\n'),
- html = (new Showdown.converter()).makeHtml(md);
+ var text = elem.innerHTML;
+
+ var leadingWs = text.match(/^\n?(\s*)/)[1].length,
+ leadingTabs = text.match(/^\n?(\t*)/)[1].length;
+
+ if( leadingTabs > 0 ) {
+ text = text.replace( new RegExp('\\n?\\t{' + leadingTabs + '}','g'), '\n' );
+ }
+ else if( leadingWs > 1 ) {
+ text = text.replace( new RegExp('\\n? {' + leadingWs + '}','g'), '\n' );
+ }
// here, have sum HTML
- elem.innerHTML = html;
+ elem.innerHTML = (new Showdown.converter()).makeHtml(text);
});