Răsfoiți Sursa

removed createMarkdownSlide and slidify from growi-renderer plugin.

Yuto Iwata 7 ani în urmă
părinte
comite
b5f925361a

+ 3 - 96
src/client/js/util/reveal/plugins/growi-renderer.js

@@ -13,101 +13,8 @@ import GrowiRenderer from '../../GrowiRenderer';
   let growiRendererPlugin = factory(growiRenderer);
   let growiRendererPlugin = factory(growiRenderer);
   growiRendererPlugin.initialize();
   growiRendererPlugin.initialize();
 }(this, function(growiRenderer) {
 }(this, function(growiRenderer) {
-  const SCRIPT_END_PLACEHOLDER = '__SCRIPT_END__';
   let marked;
   let marked;
 
 
-  /**
-   * Helper function for constructing a markdown slide.
-   * Referred from The reveal.js markdown plugin.
-   * https://github.com/hakimel/reveal.js/blob/master/plugin/markdown/markdown.js
-   */
-  function createMarkdownSlide(content, options) {
-    options = marked.getSlidifyOptions(options);
-
-    let notesMatch = content.split(new RegExp(options.notesSeparator, 'mgi'));
-
-    if (notesMatch.length === 2) {
-      content = notesMatch[0] + '<aside class="notes">' + growiRenderer.process(notesMatch[1].trim()) + '</aside>';
-    }
-
-    // prevent script end tags in the content from interfering
-    // with parsing
-    content = content.replace(/<\/script>/g, SCRIPT_END_PLACEHOLDER);
-
-    return '<script type="text/template">' + content + '</script>';
-  }
-
-  /**
-   * Parses a data string into multiple slides based
-   * on the passed in separator arguments.
-   * Referred from The reveal.js markdown plugin.
-   * https://github.com/hakimel/reveal.js/blob/master/plugin/markdown/markdown.js
-   */
-  function slidify(markdown, options) {
-    options = marked.getSlidifyOptions(options);
-
-    let separatorRegex = new RegExp( options.separator + ( options.verticalSeparator ? '|' + options.verticalSeparator : '' ), 'mg' ),
-      horizontalSeparatorRegex = new RegExp( options.separator );
-
-    let matches,
-      lastIndex = 0,
-      isHorizontal,
-      wasHorizontal = true,
-      content,
-      sectionStack = [];
-
-    // iterate until all blocks between separators are stacked up
-    while ((matches = separatorRegex.exec(markdown)) != null) {
-      // notes = null;
-
-      // determine direction (horizontal by default)
-      isHorizontal = horizontalSeparatorRegex.test( matches[0] );
-
-      if (!isHorizontal && wasHorizontal) {
-        // create vertical stack
-        sectionStack.push([]);
-      }
-
-      // pluck slide content from markdown input
-      content = markdown.substring(lastIndex, matches.index);
-
-      if (isHorizontal && wasHorizontal) {
-        // add to horizontal stack
-        sectionStack.push(content);
-      }
-      else {
-        // add to vertical stack
-        sectionStack[sectionStack.length-1].push( content );
-      }
-
-      lastIndex = separatorRegex.lastIndex;
-      wasHorizontal = isHorizontal;
-    }
-
-    // add the remaining slide
-    (wasHorizontal ? sectionStack : sectionStack[sectionStack.length-1]).push(markdown.substring(lastIndex));
-
-    let markdownSections = '';
-
-    // flatten the hierarchical stack, and insert <section data-markdown> tags
-    for (let i = 0, len = sectionStack.length; i < len; i++ ) {
-      // vertical
-      if (sectionStack[i] instanceof Array) {
-        markdownSections += '<section '+ options.attributes +'>';
-
-        sectionStack[i].forEach(function(child) {
-          markdownSections += '<section data-markdown>' + createMarkdownSlide(child, options) + '</section>';
-        } );
-
-        markdownSections += '</section>';
-      }
-      else {
-        markdownSections += '<section '+ options.attributes +' data-markdown>' + createMarkdownSlide(sectionStack[i], options) + '</section>';
-      }
-    }
-    return markdownSections;
-  }
-
   /**
   /**
    * Add data separator before lines
    * Add data separator before lines
    * starting with '#' to markdown.
    * starting with '#' to markdown.
@@ -136,7 +43,7 @@ import GrowiRenderer from '../../GrowiRenderer';
       if (section.getAttribute('data-separator')
       if (section.getAttribute('data-separator')
         || section.getAttribute('data-separator-vertical')
         || section.getAttribute('data-separator-vertical')
         || section.getAttribute('data-separator-notes')) {
         || section.getAttribute('data-separator-notes')) {
-        section.outerHTML = slidify(markdown, {
+        section.outerHTML = marked.slidify(markdown, {
           separator: section.getAttribute('data-separator'),
           separator: section.getAttribute('data-separator'),
           verticalSeparator: section.getAttribute('data-separator-vertical'),
           verticalSeparator: section.getAttribute('data-separator-vertical'),
           notesSeparator: section.getAttribute('data-separator-notes')
           notesSeparator: section.getAttribute('data-separator-notes')
@@ -144,7 +51,7 @@ import GrowiRenderer from '../../GrowiRenderer';
         });
         });
       }
       }
       else {
       else {
-        section.innerHTML = createMarkdownSlide(markdown);
+        section.innerHTML = marked.createMarkdownSlide(markdown);
       }
       }
     }
     }
   }
   }
@@ -192,8 +99,8 @@ import GrowiRenderer from '../../GrowiRenderer';
   // API
   // API
   return {
   return {
     initialize: function() {
     initialize: function() {
-      marked = require('./markdown').default(growiRenderer.process);
       growiRenderer.setup();
       growiRenderer.setup();
+      marked = require('./markdown').default(growiRenderer.process);
       processSlides();
       processSlides();
       convertSlides();
       convertSlides();
     }
     }

+ 1 - 1
src/client/js/util/reveal/plugins/markdown.js

@@ -128,7 +128,7 @@ export default function( marked ) {
 
 
     // iterate until all blocks between separators are stacked up
     // iterate until all blocks between separators are stacked up
     while( matches = separatorRegex.exec( markdown ) ) {
     while( matches = separatorRegex.exec( markdown ) ) {
-      notes = null;
+      // notes = null;
 
 
       // determine direction (horizontal by default)
       // determine direction (horizontal by default)
       isHorizontal = horizontalSeparatorRegex.test( matches[0] );
       isHorizontal = horizontalSeparatorRegex.test( matches[0] );