Sha256: 315dc75bca452857be2c6c16a8e2aeb32f2e46d6954a49550cab7e05e6e57720
Contents?: true
Size: 977 Bytes
Versions: 3
Compression:
Stored size: 977 Bytes
Contents
require 'html/pipeline/filter' require 'html/pipeline/text_filter' require 'pygments' require 'redcarpet' module GhPreview class HTMLwithPygments < Redcarpet::Render::HTML def block_code(code, language) Pygments.highlight(code, lexer: language) end end class RedcarpetFilter < HTML::Pipeline::TextFilter def initialize(text, context = nil, result = nil) super text, context, result @text = @text.gsub "\r", '' end # Convert Markdown to HTML using the best available implementation # and convert into a DocumentFragment. # def call Redcarpet::Markdown.new(HTMLwithPygments, mk_options).render(@text) end private def mk_options { strikethrough: true, autolink: true, tables: true, underline: true, highlight: true, lax_spacing: true, fenced_code_blocks: true } end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
gh-preview-1.0.2 | lib/gh_preview/redcarpet_filter.rb |
gh-preview-1.0.1 | lib/gh_preview/redcarpet_filter.rb |
gh-preview-1.0.0 | lib/gh_preview/redcarpet_filter.rb |