Replace the ShowDown Markdown engine with marked

edit
Amit Kotlovski 2013-05-01 23:10:31 +03:00
parent 247771e129
commit 381da383d9
8 changed files with 1138 additions and 73 deletions

View File

@ -37,7 +37,7 @@ Markup hierarchy needs to be ``<div class="reveal"> <div class="slides"> <sectio
It's possible to write your slides using Markdown. To enable Markdown, add the ```data-markdown``` attribute to your ```<section>``` elements and wrap the contents in a ```<script type="text/template">``` like the example below. It's possible to write your slides using Markdown. To enable Markdown, add the ```data-markdown``` attribute to your ```<section>``` elements and wrap the contents in a ```<script type="text/template">``` like the example below.
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/). Sensitive to indentation (avoid mixing tabs and spaces) and line breaks (avoid consecutive breaks). This is based on [data-markdown](https://gist.github.com/1343518) from [Paul Irish](https://github.com/paulirish) modified to use [marked](https://github.com/chjj/marked) to support [Github Flavoured Markdown](https://help.github.com/articles/github-flavored-markdown). Sensitive to indentation (avoid mixing tabs and spaces) and line breaks (avoid consecutive breaks).
```html ```html
<section data-markdown> <section data-markdown>
@ -161,7 +161,7 @@ Reveal.initialize({
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } }, { src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
// Interpret Markdown in <section> elements // Interpret Markdown in <section> elements
{ src: 'plugin/markdown/showdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, { src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, { src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
// Syntax highlight for <code> elements // Syntax highlight for <code> elements

View File

@ -363,7 +363,7 @@ function linkify( selector ) {
// Optional libraries used to extend on reveal.js // Optional libraries used to extend on reveal.js
dependencies: [ dependencies: [
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } }, { src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'plugin/markdown/showdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, { src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, { src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, { src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } }, { src: 'plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } },

View File

@ -86,7 +86,7 @@
// Optional libraries used to extend on reveal.js // Optional libraries used to extend on reveal.js
dependencies: [ dependencies: [
{ src: '../../lib/js/classList.js', condition: function() { return !document.body.classList; } }, { src: '../../lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'showdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, { src: 'marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } } { src: 'markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }
] ]
}); });

View File

@ -2,8 +2,8 @@
// Modified by Hakim to handle Markdown indented with tabs // Modified by Hakim to handle Markdown indented with tabs
(function(){ (function(){
if( typeof Showdown === 'undefined' ) { if( typeof marked === 'undefined' ) {
throw 'The reveal.js Markdown plugin requires Showdown to be loaded'; throw 'The reveal.js Markdown plugin requires marked to be loaded';
} }
var stripLeadingWhitespace = function(section) { var stripLeadingWhitespace = function(section) {
@ -175,7 +175,7 @@
var markdown = stripLeadingWhitespace(section); var markdown = stripLeadingWhitespace(section);
section.innerHTML = (new Showdown.converter()).makeHtml(markdown); section.innerHTML = marked(markdown);
if( notes ) { if( notes ) {
section.appendChild( notes ); section.appendChild( notes );

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -99,7 +99,7 @@
<div id="notes"></div> <div id="notes"></div>
<script src="/socket.io/socket.io.js"></script> <script src="/socket.io/socket.io.js"></script>
<script src="/plugin/markdown/showdown.js"></script> <script src="/plugin/markdown/marked.js"></script>
<script> <script>
var socketId = '{{socketId}}'; var socketId = '{{socketId}}';
@ -113,7 +113,7 @@
if (data.socketId !== socketId) { return; } if (data.socketId !== socketId) { return; }
if (data.markdown) { if (data.markdown) {
notes.innerHTML = (new Showdown.converter()).makeHtml(data.notes); notes.innerHTML = marked(data.notes);
} }
else { else {
notes.innerHTML = data.notes; notes.innerHTML = data.notes;

View File

@ -159,7 +159,7 @@
<div id="notes"></div> <div id="notes"></div>
<script src="../../plugin/markdown/showdown.js"></script> <script src="../../plugin/markdown/marked.js"></script>
<script> <script>
window.addEventListener( 'load', function() { window.addEventListener( 'load', function() {
@ -175,7 +175,7 @@
// No need for updating the notes in case of fragment changes // No need for updating the notes in case of fragment changes
if ( data.notes !== undefined) { if ( data.notes !== undefined) {
if( data.markdown ) { if( data.markdown ) {
notes.innerHTML = (new Showdown.converter()).makeHtml( data.notes ); notes.innerHTML = marked( data.notes );
} }
else { else {
notes.innerHTML = data.notes; notes.innerHTML = data.notes;