Sha256: 413b350415feaa4b74b9937cefb258a7d45452325abf50b674b934e1baad82ca
Contents?: true
Size: 802 Bytes
Versions: 5
Compression:
Stored size: 802 Bytes
Contents
require "redcarpet" module Lookbook class Markdown DEFAULT_OPTIONS = { tables: true, fenced_code_blocks: true, disable_indented_code_blocks: true, strikethrough: true, highlight: true, with_toc_data: true } def self.render(text) markdown = Redcarpet::Markdown.new(Renderer, Lookbook.config.markdown_options) markdown.render(text).html_safe end class Renderer < Redcarpet::Render::HTML def block_code(code, language = "ruby") line_numbers = language.to_s.end_with? "-numbered" ApplicationController.render(Lookbook::Code::Component.new(**{ source: code, language: language.to_s.chomp("-numbered"), line_numbers: line_numbers }), layout: nil) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems