Sha256: cf869de11dcd8d692b58f3741b28a1482590041d8403ea3a3ad66e9581a43d36

Contents?: true

Size: 946 Bytes

Versions: 2

Compression:

Stored size: 946 Bytes

Contents

require 'redcarpet'

module RevealCK
  module Markdown
    # This class defines what "Slide Markdown" is.
    class SlideMarkdown < Redcarpet::Render::HTML
      HR = '<hr>'
      HR_NEWLINE = "<hr>\n"

      SLIDE_START = '<section>'
      SLIDE_END = '</section>'
      SLIDE_DIVIDER = "#{SLIDE_END}\n#{SLIDE_START}"

      def postprocess(doc)
        doc = doc[HR.size, doc.size - 1] if doc.start_with?(HR)

        if doc.end_with?(HR_NEWLINE)
          doc = doc[0, doc.size - 1 - HR_NEWLINE.size]
        end
        doc = doc.gsub(HR, SLIDE_DIVIDER)
        "#{SLIDE_START}\n#{doc}\n#{SLIDE_END}"
      end

      def block_code(code, language)
        if language.nil?
          "<pre><code>#{code}</code></pre>"
        elsif language == 'notes' || language == 'note'
          "<aside class='notes'>#{code}</aside>"
        else
          "<pre><code class=\"#{language}\">#{code}</code></pre>"
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
reveal-ck-0.4.1 lib/reveal-ck/markdown/slide_markdown.rb
reveal-ck-0.4.0 lib/reveal-ck/markdown/slide_markdown.rb