Sha256: 431d1b38d1527258b1160709b401c84bc2fd88a3ff0165a2398c5cc721ac2e3e
Contents?: true
Size: 1.28 KB
Versions: 6
Compression:
Stored size: 1.28 KB
Contents
module RevealCK module Markdown # This class embodies the preprocessing that starts with a # traditional Markdown document and turns it into something that # can later "become" reveal.js slides. class PreProcessorForDividers attr_reader :doc def initialize(doc) @doc = doc end def process add_first_slide_divider_if_needed add_last_slide_vertical_if_needed add_last_slide_divider_if_needed end private def add_first_slide_divider_if_needed return if doc.start_with?(slide_divider) return if doc.start_with?(slide_vertical) prepend(slide_divider) end def add_last_slide_divider_if_needed return if doc.end_with?(slide_divider) return if doc.end_with?(slide_vertical) append(slide_divider) end def add_last_slide_vertical_if_needed return unless doc.scan(slide_vertical_regex).size.odd? append(slide_vertical) end def slide_divider '---' end def slide_vertical '***' end def slide_vertical_regex /^\*\*\*$/ end def prepend(s) doc.insert(0, "#{s}\n") end def append(s) doc.insert(doc.size, "\n#{s}") end end end end
Version data entries
6 entries across 6 versions & 1 rubygems