Sha256: d96a56cb49aaf17595c64871fa98e65a02ce60502fd3800c562d61d3c1d9440e
Contents?: true
Size: 885 Bytes
Versions: 3
Compression:
Stored size: 885 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, lax_spacing: true } def self.render(text) text&.gsub!(/\<\!\-\- (BEGIN|END) (.*) \-\-\>/, "") 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
lookbook-1.0.0.beta.7 | lib/lookbook/markdown.rb |
lookbook-1.0.0.beta.6 | lib/lookbook/markdown.rb |
lookbook-1.0.0.beta.5 | lib/lookbook/markdown.rb |