Sha256: a797703668b092eea3773ad70db135bdd90c180a67a6775efc319a45fd259e60
Contents?: true
Size: 778 Bytes
Versions: 10
Compression:
Stored size: 778 Bytes
Contents
# frozen_string_literal: true require 'bbcoder' module HTML class Pipeline class BbcodeFilter < TextFilter def initialize(text, context = {}, result = nil) super text, context, result end def call html = BBCoder.new(@text).to_html html = remove_url_link_contents(html) html = preserve_mkdn_comments(html) html.delete('<br>') html.rstrip! html end def remove_url_link_contents(html) doc = Nokogiri::HTML::DocumentFragment.parse(html) doc.css('a').each do |link| link.content = link.content.gsub(%r{https?://}, '') end doc.to_html end def preserve_mkdn_comments(html) html.gsub(/^> /, '> ') end end end end
Version data entries
10 entries across 10 versions & 1 rubygems