Sha256: a735d39a138c4f6a3d2b56f016df83cafa5695f40a2cc2493b2755fc584e6912

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

require 'mumukit/core'
require 'redcarpet'

module Mumukit
  module ContentType
    module BaseContentType
      def format_exception(e)
        "#{title e.message}\n#{code e.backtrace.join("\n")}"
      end

      def to_html(content, options={})
        content_html = htmlize content, options
        content_html = Mumukit::ContentType::Sanitizer.sanitize(content_html) unless options[:skip_sanitization]
        content_html&.html_safe
      end

      def to_s
        name
      end

      def as_json(_options={})
        name
      end
    end

    def self.parse(s)
      "Mumukit::ContentType::#{s.to_s.titlecase}".constantize
    rescue
      raise "unknown content_type #{s}"
    end

    def self.for(type)
      parse(type)
    end
  end
end

require_relative './content_type/sanitizer'
require_relative './content_type/emoji'
require_relative './content_type/markdown'
require_relative './content_type/with_markdown'
require_relative './content_type/plain'
require_relative './content_type/html'
require_relative './content_type/gobstones'
require_relative './content_type/python3'

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mumukit-content-type-1.12.1 lib/mumukit/content_type.rb
mumukit-content-type-1.12.0 lib/mumukit/content_type.rb
mumukit-content-type-1.11.1 lib/mumukit/content_type.rb
mumukit-content-type-1.11.0 lib/mumukit/content_type.rb