23341.patch

Takenori TAKAKI, 2018-11-14 14:19

Download (1.27 KB)

View differences:

lib/redmine/wiki_formatting/markdown/formatter.rb
24 24
        include ActionView::Helpers::TagHelper
25 25
        include Redmine::Helpers::URL
26 26

  
27
        def preprocess(full_document)
28
          replace_wiki_links(full_document, '\|', '|')
29
        end
30

  
31
        def postprocess(full_document)
32
          replace_wiki_links(full_document, '|', '|')
33
        end
34

  
27 35
        def link(link, title, content)
28 36
          return nil unless uri_with_safe_scheme?(link)
29 37

  
......
49 57

  
50 58
          tag('img', :src => link, :alt => alt_text || "", :title => title)
51 59
        end
60

  
61
        private
62

  
63
        def replace_wiki_links(full_document, pattern, replacement)
64
          full_document.gsub(/(\[\[([^\]\n#{pattern}]+)(#{pattern})(([^\]\n#{pattern}]+))?\]\])/) do |m|
65
            all, page, separater, title = $1, $2, $3, $4
66
            if page && separater && title
67
              "[[#{page}#{replacement}#{title}]]"
68
            else
69
              all
70
            end
71
          end
72
        end
52 73
      end
53 74

  
54 75
      class Formatter