Sha256: 55876a6b4cc28ed3e4469fca1e02fd902d7da5132fa7ad3ca45ade2f5482aa61
Contents?: true
Size: 1.15 KB
Versions: 6
Compression:
Stored size: 1.15 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) html = markdown.render(ActionController::Base.helpers.sanitize(template, scrubber: parliament_scrubber)) ActionController::Base.helpers.sanitize(html, scrubber: parliament_scrubber).html_safe end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems