Sha256: 4c47f65dfa3bbb1bb8a73f0603d1c83c50ba31b830969fa6f0762025d73216dc
Contents?: true
Size: 1.12 KB
Versions: 10
Compression:
Stored size: 1.12 KB
Contents
require_relative '../services/markdown_converter' require_relative '../services/markdown_scrubber' require 'redcarpet' module Parliament module Utils module Helpers module MarkdownHelper # Uses redcarpet gem to convert markdown into HTML, with chosen HTML extensions # Uses custom Parliament::Utils::Services::ParliamentMarkdownRenderer to override default autolink behaviour of redcarpet gem # Uses custom Parliament::Utils::Services::ParliamentMarkdownScrubber to allow additional HTML tags and attributes # # @return template [String] Template as HTML def self.markdown(template) parliament_renderer = Parliament::Utils::Services::ParliamentMarkdownRenderer parliament_scrubber = Parliament::Utils::Services::ParliamentMarkdownScrubber.new markdown = Redcarpet::Markdown.new(parliament_renderer, tables: true, autolink: true, lax_spacing: true) sanitized_template = ActionController::Base.helpers.sanitize(template, scrubber: parliament_scrubber) markdown.render(sanitized_template).html_safe end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems