update syntax highlight after editing (#210), move markdown and highlight scripts from lib to plugin
This commit is contained in:
32
plugin/markdown/markdown.js
Normal file
32
plugin/markdown/markdown.js
Normal file
@ -0,0 +1,32 @@
|
||||
// From https://gist.github.com/1343518
|
||||
// Modified by Hakim to handle Markdown indented with tabs
|
||||
(function(){
|
||||
|
||||
if( typeof Showdown === 'undefined' ) {
|
||||
throw 'The reveal.js Markdown plugin requires Showdown to be loaded';
|
||||
}
|
||||
|
||||
var sections = document.querySelectorAll( '[data-markdown]' );
|
||||
|
||||
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 = ( template || section ).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' );
|
||||
}
|
||||
|
||||
section.innerHTML = (new Showdown.converter()).makeHtml(text);
|
||||
}
|
||||
|
||||
})();
|
62
plugin/markdown/showdown.js
Normal file
62
plugin/markdown/showdown.js
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user