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
# Optional CommonMark support, not for JRuby
group :common_mark do
gem "commonmarker", '~> 0.23.8'
gem "commonmarker", '~> 1.1.0'
gem 'deckar01-task_list', '2.3.2'
end
lib/redmine.rb
# Redcarpet is not available
end
begin
require 'commonmarker' unless Object.const_defined?(:CommonMarker)
require 'commonmarker' unless Object.const_defined?(:Commonmarker)
rescue LoadError
# CommonMarker is not available
end
lib/redmine/preparation.rb
WikiFormatting.map do |format|
format.register :textile
format.register :markdown, label: 'Markdown (deprecated)' if Object.const_defined?(:Redcarpet)
if Object.const_defined?(:CommonMarker)
if Object.const_defined?(:Commonmarker)
format.register :common_mark, label: 'CommonMark Markdown (GitHub Flavored)'
end
end
lib/redmine/wiki_formatting/common_mark/formatter.rb
# configuration of the rendering pipeline
PIPELINE_CONFIG = {
# https://github.com/gjtorikian/commonmarker#extension-options
commonmarker_extensions: [
:table,
:strikethrough,
:tagfilter,
:autolink
].freeze,
commonmarker_extensions: {
table: true,
strikethrough: true,
tagfilter: true,
autolink: true,
footnotes: true,
}.freeze,
# https://github.com/gjtorikian/commonmarker#parse-options
commonmarker_parse_options: [
:FOOTNOTES,
:STRIKETHROUGH_DOUBLE_TILDE,
:UNSAFE,
:VALIDATE_UTF8
].freeze,
commonmarker_parse_options: {
}.freeze,
# https://github.com/gjtorikian/commonmarker#render-options
commonmarker_render_options: [
:UNSAFE
],
commonmarker_render_options: {
unsafe: true
},
}.freeze
if Redmine::Configuration['common_mark_enable_hardbreaks'] == true
PIPELINE_CONFIG[:commonmarker_render_options].push(:HARDBREAKS)
PIPELINE_CONFIG[:commonmarker_render_options].merge!({hardbreaks: true})
end
PIPELINE_CONFIG[:commonmarker_render_options].freeze
lib/redmine/wiki_formatting/common_mark/markdown_filter.rb
end
def call
doc = CommonMarker.render_doc(@text, parse_options, extensions)
html = doc.to_html render_options, extensions
html = Commonmarker.to_html(@text, options: {
extension: extensions,
render: render_options,
parse: parse_options
})
html.rstrip!
html
end
......
private
def extensions
context.fetch :commonmarker_extensions, []
context.fetch :commonmarker_extensions, {}
end
def parse_options
context.fetch :commonmarker_parse_options, :DEFAULT
context.fetch :commonmarker_parse_options, {}
end
def render_options
context.fetch :commonmarker_render_options, :DEFAULT
context.fetch :commonmarker_render_options, {}
end
end
end
test/unit/lib/redmine/wiki_formatting/common_mark/application_helper_test.rb
require_relative '../../../../../test_helper'
class Redmine::WikiFormatting::CommonMark::ApplicationHelperTest < Redmine::HelperTest
if Object.const_defined?(:CommonMarker)
if Object.const_defined?(:Commonmarker)
include ERB::Util
test/unit/lib/redmine/wiki_formatting/common_mark/external_links_filter_test.rb
require_relative '../../../../../test_helper'
if Object.const_defined?(:CommonMarker)
if Object.const_defined?(:Commonmarker)
require 'redmine/wiki_formatting/common_mark/external_links_filter'
class Redmine::WikiFormatting::CommonMark::ExternalLinksFilterTest < ActiveSupport::TestCase
test/unit/lib/redmine/wiki_formatting/common_mark/fixup_auto_links_filter_test.rb
require_relative '../../../../../test_helper'
if Object.const_defined?(:CommonMarker)
if Object.const_defined?(:Commonmarker)
require 'redmine/wiki_formatting/common_mark/fixup_auto_links_filter'
class Redmine::WikiFormatting::CommonMark::FixupAutoLinksFilterTest < ActiveSupport::TestCase
test/unit/lib/redmine/wiki_formatting/common_mark/formatter_test.rb
require_relative '../../../../../test_helper'
class Redmine::WikiFormatting::CommonMark::FormatterTest < ActionView::TestCase
if Object.const_defined?(:CommonMarker)
if Object.const_defined?(:Commonmarker)
def setup
@formatter = Redmine::WikiFormatting::CommonMark::Formatter
test/unit/lib/redmine/wiki_formatting/common_mark/markdown_filter_test.rb
require_relative '../../../../../test_helper'
if Object.const_defined?(:CommonMarker)
if Object.const_defined?(:Commonmarker)
require 'redmine/wiki_formatting/common_mark/markdown_filter'
class Redmine::WikiFormatting::CommonMark::MarkdownFilterTest < ActiveSupport::TestCase
test/unit/lib/redmine/wiki_formatting/common_mark/sanitization_filter_test.rb
require_relative '../../../../../test_helper'
if Object.const_defined?(:CommonMarker)
if Object.const_defined?(:Commonmarker)
require 'redmine/wiki_formatting/common_mark/sanitization_filter'
class Redmine::WikiFormatting::CommonMark::SanitizationFilterTest < ActiveSupport::TestCase
test/unit/lib/redmine/wiki_formatting/common_mark/syntax_highlight_filter_test.rb
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require_relative '../../../../../test_helper'
if Object.const_defined?(:CommonMarker)
if Object.const_defined?(:Commonmarker)
require 'redmine/wiki_formatting/common_mark/syntax_highlight_filter'
class Redmine::WikiFormatting::CommonMark::SyntaxHighlightFilterTest < ActiveSupport::TestCase
(1-1/3)