Project

General

Profile

Patch #40197 » 0001-Updates-commonmark-gem-version-to-1.1.5-which-switch.patch

Marius BĂLTEANU, 2024-08-28 01:53

View differences:

Gemfile
51 51

  
52 52
# Optional CommonMark support, not for JRuby
53 53
group :common_mark do
54
  gem "commonmarker", '~> 0.23.8'
54
  gem "commonmarker", '~> 1.1.0'
55 55
  gem 'deckar01-task_list', '2.3.2'
56 56
end
57 57

  
lib/redmine.rb
30 30
  # Redcarpet is not available
31 31
end
32 32
begin
33
  require 'commonmarker' unless Object.const_defined?(:CommonMarker)
33
  require 'commonmarker' unless Object.const_defined?(:Commonmarker)
34 34
rescue LoadError
35 35
  # CommonMarker is not available
36 36
end
lib/redmine/preparation.rb
396 396
      WikiFormatting.map do |format|
397 397
        format.register :textile
398 398
        format.register :markdown, label: 'Markdown (deprecated)' if Object.const_defined?(:Redcarpet)
399
        if Object.const_defined?(:CommonMarker)
399
        if Object.const_defined?(:Commonmarker)
400 400
          format.register :common_mark, label: 'CommonMark Markdown (GitHub Flavored)'
401 401
        end
402 402
      end
lib/redmine/wiki_formatting/common_mark/formatter.rb
26 26
      # configuration of the rendering pipeline
27 27
      PIPELINE_CONFIG = {
28 28
        # https://github.com/gjtorikian/commonmarker#extension-options
29
        commonmarker_extensions: [
30
          :table,
31
          :strikethrough,
32
          :tagfilter,
33
          :autolink
34
        ].freeze,
29
        commonmarker_extensions: {
30
          table: true,
31
          strikethrough: true,
32
          tagfilter: true,
33
          autolink: true,
34
          footnotes: true,
35
        }.freeze,
35 36

  
36 37
        # https://github.com/gjtorikian/commonmarker#parse-options
37
        commonmarker_parse_options: [
38
          :FOOTNOTES,
39
          :STRIKETHROUGH_DOUBLE_TILDE,
40
          :UNSAFE,
41
          :VALIDATE_UTF8
42
        ].freeze,
38
        commonmarker_parse_options: {
39
        }.freeze,
43 40

  
44 41
        # https://github.com/gjtorikian/commonmarker#render-options
45
        commonmarker_render_options: [
46
          :UNSAFE
47
        ],
42
        commonmarker_render_options: {
43
          unsafe: true
44
        },
48 45
      }.freeze
49 46

  
50 47
      if Redmine::Configuration['common_mark_enable_hardbreaks'] == true
51
        PIPELINE_CONFIG[:commonmarker_render_options].push(:HARDBREAKS)
48
        PIPELINE_CONFIG[:commonmarker_render_options].merge!({hardbreaks: true})
52 49
      end
53 50
      PIPELINE_CONFIG[:commonmarker_render_options].freeze
54 51

  
lib/redmine/wiki_formatting/common_mark/markdown_filter.rb
32 32
        end
33 33

  
34 34
        def call
35
          doc = CommonMarker.render_doc(@text, parse_options, extensions)
36
          html = doc.to_html render_options, extensions
35
          html = Commonmarker.to_html(@text, options: {
36
            extension: extensions,
37
            render: render_options,
38
            parse: parse_options
39
          })
40

  
37 41
          html.rstrip!
38 42
          html
39 43
        end
......
41 45
        private
42 46

  
43 47
        def extensions
44
          context.fetch :commonmarker_extensions, []
48
          context.fetch :commonmarker_extensions, {}
45 49
        end
46 50

  
47 51
        def parse_options
48
          context.fetch :commonmarker_parse_options, :DEFAULT
52
          context.fetch :commonmarker_parse_options, {}
49 53
        end
50 54

  
51 55
        def render_options
52
          context.fetch :commonmarker_render_options, :DEFAULT
56
          context.fetch :commonmarker_render_options, {}
53 57
        end
54 58
      end
55 59
    end
test/unit/lib/redmine/wiki_formatting/common_mark/application_helper_test.rb
20 20
require_relative '../../../../../test_helper'
21 21

  
22 22
class Redmine::WikiFormatting::CommonMark::ApplicationHelperTest < Redmine::HelperTest
23
  if Object.const_defined?(:CommonMarker)
23
  if Object.const_defined?(:Commonmarker)
24 24

  
25 25
    include ERB::Util
26 26

  
test/unit/lib/redmine/wiki_formatting/common_mark/external_links_filter_test.rb
19 19

  
20 20
require_relative '../../../../../test_helper'
21 21

  
22
if Object.const_defined?(:CommonMarker)
22
if Object.const_defined?(:Commonmarker)
23 23
  require 'redmine/wiki_formatting/common_mark/external_links_filter'
24 24

  
25 25
  class Redmine::WikiFormatting::CommonMark::ExternalLinksFilterTest < ActiveSupport::TestCase
test/unit/lib/redmine/wiki_formatting/common_mark/fixup_auto_links_filter_test.rb
19 19

  
20 20
require_relative '../../../../../test_helper'
21 21

  
22
if Object.const_defined?(:CommonMarker)
22
if Object.const_defined?(:Commonmarker)
23 23
  require 'redmine/wiki_formatting/common_mark/fixup_auto_links_filter'
24 24

  
25 25
  class Redmine::WikiFormatting::CommonMark::FixupAutoLinksFilterTest < ActiveSupport::TestCase
test/unit/lib/redmine/wiki_formatting/common_mark/formatter_test.rb
20 20
require_relative '../../../../../test_helper'
21 21

  
22 22
class Redmine::WikiFormatting::CommonMark::FormatterTest < ActionView::TestCase
23
  if Object.const_defined?(:CommonMarker)
23
  if Object.const_defined?(:Commonmarker)
24 24

  
25 25
    def setup
26 26
      @formatter = Redmine::WikiFormatting::CommonMark::Formatter
test/unit/lib/redmine/wiki_formatting/common_mark/markdown_filter_test.rb
19 19

  
20 20
require_relative '../../../../../test_helper'
21 21

  
22
if Object.const_defined?(:CommonMarker)
22
if Object.const_defined?(:Commonmarker)
23 23
  require 'redmine/wiki_formatting/common_mark/markdown_filter'
24 24

  
25 25
  class Redmine::WikiFormatting::CommonMark::MarkdownFilterTest < ActiveSupport::TestCase
test/unit/lib/redmine/wiki_formatting/common_mark/sanitization_filter_test.rb
19 19

  
20 20
require_relative '../../../../../test_helper'
21 21

  
22
if Object.const_defined?(:CommonMarker)
22
if Object.const_defined?(:Commonmarker)
23 23
  require 'redmine/wiki_formatting/common_mark/sanitization_filter'
24 24

  
25 25
  class Redmine::WikiFormatting::CommonMark::SanitizationFilterTest < ActiveSupport::TestCase
test/unit/lib/redmine/wiki_formatting/common_mark/syntax_highlight_filter_test.rb
18 18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 19

  
20 20
require_relative '../../../../../test_helper'
21
if Object.const_defined?(:CommonMarker)
21
if Object.const_defined?(:Commonmarker)
22 22
  require 'redmine/wiki_formatting/common_mark/syntax_highlight_filter'
23 23

  
24 24
  class Redmine::WikiFormatting::CommonMark::SyntaxHighlightFilterTest < ActiveSupport::TestCase
(1-1/3)