This commit is contained in:
Karel Pičman 2019-05-22 13:31:55 +02:00
parent fc6f8ccde4
commit 3e8594a832
2 changed files with 34 additions and 10 deletions

View File

@ -0,0 +1,32 @@
# encoding: utf-8
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
module DmsfFilesHelper
def clean_wiki_text(text)
# If there is <p> tag, the text is moved one column to the right by Redmin's CSS. A new line causes double new line.
text.gsub! '<p>', ''
text.gsub! '</p>', ''
text.gsub! "\n\n", '<br/>'
text.gsub "\n\t", '<br/>'
end
end

View File

@ -112,12 +112,7 @@
<% if revision.description.present? %>
<div class="status attribute">
<%= content_tag :div, l(:label_description), :class => 'label' %>
<% text = textilizable(revision.description) %>
<%# If there is <p> tag, the text is moved one column to the right by Redmin's CSS. A new line causes double new line. %>
<% text.gsub! '<p>', '' %>
<% text.gsub! '</p>', '' %>
<% text.gsub! "\n\n", '<br/>' %>
<% text.gsub! "\n\t", '<br/>' %>
<% text = clean_wiki_text(textilizable(revision.description)) %>
<%= content_tag :div, text.html_safe, :class => 'value wiki' %>
</div>
<% end %>
@ -146,10 +141,7 @@
<% if revision.comment.present? %>
<div class="status attribute">
<%= content_tag :div, l(:label_comment), :class => 'label' %>
<% text = textilizable(revision.comment) %>
<% if text =~ /^<p>(.*)<\/p>$/ %>
<% text = $1 %>
<% end %>
<% text = clean_wiki_text(textilizable(revision.comment)) %>
<%= content_tag :div, text.html_safe, :class => 'value wiki' %>
</div>
<% end %>