Sha256: 2a8eff1f63513fee94cd0db27739137d7c9b9f92470be1f2026d2cd558911284
Contents?: true
Size: 768 Bytes
Versions: 18
Compression:
Stored size: 768 Bytes
Contents
require 'kramdown' require 'htmlentities' require_relative 'mastalk/extensions' module Mastalk # Document class to preprocess # mastalk specific syntax class Document include Mastalk::Extensions attr_reader :source def initialize(source) @source = source.dup end def to_html ::HTMLEntities.new.decode( kramdown.to_html ) end private def kramdown Kramdown::Document.new(preprocess(source)) end def preprocess(source) extensions.map do |regex, block| if source.match(regex) source.sub!(regex, block.call(Regexp.last_match.captures.first).strip) end end preprocess(source) if extensions.any? {|regex, _| source.match(regex)} source end end end
Version data entries
18 entries across 18 versions & 1 rubygems