From c5b52ec29fcb369e95bb640e7ed64710fbc07f6d Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 29 Mar 2014 14:35:47 +0000 Subject: [PATCH] Merged r12989 and r12997 (#16236). git-svn-id: http://svn.redmine.org/redmine/branches/2.5-stable@13020 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/application_helper.rb | 7 ++++--- test/unit/helpers/application_helper_test.rb | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 363653cd8..acb7ba9db 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -978,19 +978,20 @@ module ApplicationHelper end end - TOC_RE = /

\{\{([<>]?)toc\}\}<\/p>/i unless const_defined?(:TOC_RE) + TOC_RE = /

\{\{((<|<)|(>|>))?toc\}\}<\/p>/i unless const_defined?(:TOC_RE) # Renders the TOC with given headings def replace_toc(text, headings) text.gsub!(TOC_RE) do + left_align, right_align = $2, $3 # Keep only the 4 first levels headings = headings.select{|level, anchor, item| level <= 4} if headings.empty? '' else div_class = 'toc' - div_class << ' right' if $1 == '>' - div_class << ' left' if $1 == '<' + div_class << ' right' if right_align + div_class << ' left' if left_align out = "