Sha256: 13fd18ae90c0e34fddc06151d67cbfc8b8e8bdda9a4c03178c97c28aadcc311c

Contents?: true

Size: 1.16 KB

Versions: 6

Compression:

Stored size: 1.16 KB

Contents

// 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 notes = section.querySelector( 'aside.notes' );

        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);

        if( notes ) {
            section.appendChild( notes );
        }
    }

})();

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
reveal-ck-0.1.2 reveal.js/plugin/markdown/markdown.js
reveal-ck-0.1.1 reveal.js/plugin/markdown/markdown.js
reveal-ck-0.1.0 reveal.js/plugin/markdown/markdown.js
briefing-0.0.3 lib/briefing/public/plugin/markdown/markdown.js
briefing-0.0.2 lib/briefing/public/plugin/markdown/markdown.js
briefing-0.0.1 lib/briefing/public/plugin/markdown/markdown.js