Sha256: ddbef9f8f94833946c6438a7630d9735b77779ea1b8e2572abf006018e789ab3
Contents?: true
Size: 738 Bytes
Versions: 6
Compression:
Stored size: 738 Bytes
Contents
require "redcarpet" module Lookbook class MarkdownRenderer < Service attr_reader :text, :opts def initialize(text, opts = {}) @text = text @opts = opts.to_h end def call clean_text = ActionViewAnnotationsStripper.call(text) md = Redcarpet::Markdown.new(LookbookMarkdownRenderer, opts) md.render(clean_text).html_safe end class LookbookMarkdownRenderer < 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
6 entries across 6 versions & 1 rubygems