OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openproject/lib/redmine/wiki_formatting/xml/formatter.rb

33 lines
772 B

require 'loofah'
module Redmine
module WikiFormatting
module Xml
class Formatter
include ActionView::Helpers::TagHelper
include ActionView::Helpers::TextHelper
include ActionView::Helpers::UrlHelper
def initialize(text)
@text = text
end
def to_html(*args)
args.include?(:edit) ? with_edit_transformation(@text).to_s : with_release_transformation(@text).to_s
end
def with_edit_transformation(text)
common_transformation(text)
end
def with_release_transformation(text)
common_transformation(text)
end
def common_transformation(text)
Loofah.fragment(@text).scrub!(:prune)
end
end
end
end
end