Redmine 4.1.1
This commit is contained in:
parent
33e7b881a5
commit
3d976f1b3b
1593 changed files with 36180 additions and 19489 deletions
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -28,13 +30,13 @@ module Redmine
|
|||
}
|
||||
|
||||
def self.to_text(html)
|
||||
html = html.gsub(/[\n\r]/, '').squeeze(' ')
|
||||
|
||||
html = html.gsub(/[\n\r]/, ' ')
|
||||
|
||||
doc = Loofah.document(html)
|
||||
doc.scrub!(WikiTags.new(tags))
|
||||
doc.scrub!(:newline_block_elements)
|
||||
|
||||
Loofah::Helpers.remove_extraneous_whitespace(doc.text).strip
|
||||
|
||||
Loofah.remove_extraneous_whitespace(doc.text(:encode_special_chars => false)).strip.squeeze(' ').gsub(/^ +/, '')
|
||||
end
|
||||
|
||||
class WikiTags < ::Loofah::Scrubber
|
||||
|
@ -42,7 +44,7 @@ module Redmine
|
|||
@direction = :bottom_up
|
||||
@tags_to_text = tags_to_text || {}
|
||||
end
|
||||
|
||||
|
||||
def scrub(node)
|
||||
formatting = @tags_to_text[node.name]
|
||||
case formatting
|
||||
|
@ -52,6 +54,9 @@ module Redmine
|
|||
when String
|
||||
node.add_next_sibling Nokogiri::XML::Text.new(formatting, node.document)
|
||||
node.remove
|
||||
when Proc
|
||||
node.add_next_sibling formatting.call(node)
|
||||
node.remove
|
||||
else
|
||||
CONTINUE
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue