Sha256: 5f4de2ad1ac09039ba070098ec67988365c1bb7021b9eac2ba6c6c8c091b0b48
Contents?: true
Size: 698 Bytes
Versions: 9
Compression:
Stored size: 698 Bytes
Contents
require 'coderay' require 'htmlentities' module Thredded module Filter module Syntax def filtered_content content = String.new(super) content = HTMLEntities.new.decode(content) content = content.to_s .gsub(/\<pre\>\<code( lang="(.+?)")?\>(.+?)\<\/code\>\<\/pre\>/m) do filter = $2.nil? ? :ruby : $2.to_sym temp_code = $3.gsub(/"/, '"'). gsub(/'/,"'"). gsub(/&/, "&"). gsub(/>/, ">"). gsub(/</, "<"). gsub(/\<br \/\>/, "") ::CodeRay.scan(temp_code, filter).div(css: :class) end content.html_safe end end end end
Version data entries
9 entries across 9 versions & 1 rubygems