Sha256: a2a45241ee197e69ba62cef609c9126766174d3f826b60596657bda6bfe8c242
Contents?: true
Size: 774 Bytes
Versions: 1
Compression:
Stored size: 774 Bytes
Contents
require 'kramdown' require 'sanitize' module FriendlyMarkdown module_function def compile input, mconfig: markdown_config, sconfig: sanitize_config sanitize(markdown(autolink(input.strip), mconfig), sconfig) end def autolink text text.gsub(%r{\<?\bhttps?://\S+[\b/]?}) do |m| if m =~ /\A<.+>\z$/ s = m[1..-2] %Q{<<a href="#{s}">#{s}</a>>} else %Q{<a href="#{m}">#{m}</a>} end end end def markdown md, config=markdown_config Kramdown::Document.new(md, config).to_html end def sanitize html, config=sanitize_config Sanitize.fragment(html, config) end def markdown_config {:input => 'GFM', :hard_wrap => true} end def sanitize_config Sanitize::Config::RELAXED end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
friendly_markdown-0.1.0 | lib/friendly_markdown.rb |