summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Gemfile2
-rw-r--r--lib/redmine.rb2
-rw-r--r--lib/redmine/preparation.rb2
-rw-r--r--lib/redmine/wiki_formatting/common_mark/formatter.rb36
-rw-r--r--lib/redmine/wiki_formatting/common_mark/markdown_filter.rb18
-rw-r--r--test/unit/lib/redmine/wiki_formatting/common_mark/application_helper_test.rb2
-rw-r--r--test/unit/lib/redmine/wiki_formatting/common_mark/external_links_filter_test.rb2
-rw-r--r--test/unit/lib/redmine/wiki_formatting/common_mark/fixup_auto_links_filter_test.rb2
-rw-r--r--test/unit/lib/redmine/wiki_formatting/common_mark/formatter_test.rb2
-rw-r--r--test/unit/lib/redmine/wiki_formatting/common_mark/markdown_filter_test.rb2
-rw-r--r--test/unit/lib/redmine/wiki_formatting/common_mark/sanitization_filter_test.rb2
-rw-r--r--test/unit/lib/redmine/wiki_formatting/common_mark/syntax_highlight_filter_test.rb2
12 files changed, 35 insertions, 39 deletions
diff --git a/Gemfile b/Gemfile
index f8847b789..0dda8f0d3 100644
--- a/Gemfile
+++ b/Gemfile
@@ -46,7 +46,7 @@ end
# Optional CommonMark support, not for JRuby
group :common_mark do
- gem "commonmarker", '~> 1.1.0'
+ gem "commonmarker", '~> 0.23.8'
gem 'deckar01-task_list', '2.3.2'
end
diff --git a/lib/redmine.rb b/lib/redmine.rb
index 95b3b7f3f..2edfa55e9 100644
--- a/lib/redmine.rb
+++ b/lib/redmine.rb
@@ -25,7 +25,7 @@ rescue LoadError
# MiniMagick 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
diff --git a/lib/redmine/preparation.rb b/lib/redmine/preparation.rb
index 822662e11..1aeb81e46 100644
--- a/lib/redmine/preparation.rb
+++ b/lib/redmine/preparation.rb
@@ -408,7 +408,7 @@ module Redmine
WikiFormatting.map do |format|
format.register :textile
- if Object.const_defined?(:Commonmarker)
+ if Object.const_defined?(:CommonMarker)
format.register :common_mark, label: 'CommonMark Markdown (GitHub Flavored)'
end
end
diff --git a/lib/redmine/wiki_formatting/common_mark/formatter.rb b/lib/redmine/wiki_formatting/common_mark/formatter.rb
index 2eee19fa3..42cae4f3a 100644
--- a/lib/redmine/wiki_formatting/common_mark/formatter.rb
+++ b/lib/redmine/wiki_formatting/common_mark/formatter.rb
@@ -26,28 +26,32 @@ module Redmine
# configuration of the rendering pipeline
PIPELINE_CONFIG = {
# https://github.com/gjtorikian/commonmarker#extension-options
- commonmarker_extensions: {
- table: true,
- strikethrough: true,
- tagfilter: true,
- autolink: true,
- footnotes: true,
- }.freeze,
+ commonmarker_extensions: [
+ :table,
+ :strikethrough,
+ :tagfilter,
+ :autolink
+ ].freeze,
# https://github.com/gjtorikian/commonmarker#parse-options
- commonmarker_parse_options: {
- }.freeze,
+ commonmarker_parse_options: [
+ :FOOTNOTES,
+ :STRIKETHROUGH_DOUBLE_TILDE,
+ :UNSAFE,
+ :VALIDATE_UTF8
+ ].freeze,
# https://github.com/gjtorikian/commonmarker#render-options
- commonmarker_render_options: {
- unsafe: true,
- hardbreaks: Redmine::Configuration['common_mark_enable_hardbreaks'] == true ? true : false,
- }.freeze,
- commonmarker_plugins: {
- syntax_highlighter: nil
- }.freeze,
+ commonmarker_render_options: [
+ :UNSAFE
+ ],
}.freeze
+ if Redmine::Configuration['common_mark_enable_hardbreaks'] == true
+ PIPELINE_CONFIG[:commonmarker_render_options].push(:HARDBREAKS)
+ end
+ PIPELINE_CONFIG[:commonmarker_render_options].freeze
+
MarkdownPipeline = HTML::Pipeline.new [
MarkdownFilter,
SanitizationFilter,
diff --git a/lib/redmine/wiki_formatting/common_mark/markdown_filter.rb b/lib/redmine/wiki_formatting/common_mark/markdown_filter.rb
index 0b7f52ea3..916c8883c 100644
--- a/lib/redmine/wiki_formatting/common_mark/markdown_filter.rb
+++ b/lib/redmine/wiki_formatting/common_mark/markdown_filter.rb
@@ -32,12 +32,8 @@ module Redmine
end
def call
- html = Commonmarker.to_html(@text, options: {
- extension: extensions,
- render: render_options,
- parse: parse_options
- }, plugins: plugins )
-
+ doc = CommonMarker.render_doc(@text, parse_options, extensions)
+ html = doc.to_html render_options, extensions
html.rstrip!
html
end
@@ -45,19 +41,15 @@ module Redmine
private
def extensions
- context.fetch :commonmarker_extensions, {}
+ context.fetch :commonmarker_extensions, []
end
def parse_options
- context.fetch :commonmarker_parse_options, {}
+ context.fetch :commonmarker_parse_options, :DEFAULT
end
def render_options
- context.fetch :commonmarker_render_options, {}
- end
-
- def plugins
- context.fetch :commonmarker_plugins, {}
+ context.fetch :commonmarker_render_options, :DEFAULT
end
end
end
diff --git a/test/unit/lib/redmine/wiki_formatting/common_mark/application_helper_test.rb b/test/unit/lib/redmine/wiki_formatting/common_mark/application_helper_test.rb
index 46057f132..7b5915f7d 100644
--- a/test/unit/lib/redmine/wiki_formatting/common_mark/application_helper_test.rb
+++ b/test/unit/lib/redmine/wiki_formatting/common_mark/application_helper_test.rb
@@ -20,7 +20,7 @@
require_relative '../../../../../test_helper'
class Redmine::WikiFormatting::CommonMark::ApplicationHelperTest < Redmine::HelperTest
- if Object.const_defined?(:Commonmarker)
+ if Object.const_defined?(:CommonMarker)
include ERB::Util
diff --git a/test/unit/lib/redmine/wiki_formatting/common_mark/external_links_filter_test.rb b/test/unit/lib/redmine/wiki_formatting/common_mark/external_links_filter_test.rb
index cde6381b8..179ff9bbf 100644
--- a/test/unit/lib/redmine/wiki_formatting/common_mark/external_links_filter_test.rb
+++ b/test/unit/lib/redmine/wiki_formatting/common_mark/external_links_filter_test.rb
@@ -19,7 +19,7 @@
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
diff --git a/test/unit/lib/redmine/wiki_formatting/common_mark/fixup_auto_links_filter_test.rb b/test/unit/lib/redmine/wiki_formatting/common_mark/fixup_auto_links_filter_test.rb
index 1b093d718..2ed04df8f 100644
--- a/test/unit/lib/redmine/wiki_formatting/common_mark/fixup_auto_links_filter_test.rb
+++ b/test/unit/lib/redmine/wiki_formatting/common_mark/fixup_auto_links_filter_test.rb
@@ -19,7 +19,7 @@
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
diff --git a/test/unit/lib/redmine/wiki_formatting/common_mark/formatter_test.rb b/test/unit/lib/redmine/wiki_formatting/common_mark/formatter_test.rb
index 5214a1e00..f7ffb3e97 100644
--- a/test/unit/lib/redmine/wiki_formatting/common_mark/formatter_test.rb
+++ b/test/unit/lib/redmine/wiki_formatting/common_mark/formatter_test.rb
@@ -20,7 +20,7 @@
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
diff --git a/test/unit/lib/redmine/wiki_formatting/common_mark/markdown_filter_test.rb b/test/unit/lib/redmine/wiki_formatting/common_mark/markdown_filter_test.rb
index d5e416d2c..374705423 100644
--- a/test/unit/lib/redmine/wiki_formatting/common_mark/markdown_filter_test.rb
+++ b/test/unit/lib/redmine/wiki_formatting/common_mark/markdown_filter_test.rb
@@ -19,7 +19,7 @@
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
diff --git a/test/unit/lib/redmine/wiki_formatting/common_mark/sanitization_filter_test.rb b/test/unit/lib/redmine/wiki_formatting/common_mark/sanitization_filter_test.rb
index 4c0282f2d..d3956e802 100644
--- a/test/unit/lib/redmine/wiki_formatting/common_mark/sanitization_filter_test.rb
+++ b/test/unit/lib/redmine/wiki_formatting/common_mark/sanitization_filter_test.rb
@@ -19,7 +19,7 @@
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
diff --git a/test/unit/lib/redmine/wiki_formatting/common_mark/syntax_highlight_filter_test.rb b/test/unit/lib/redmine/wiki_formatting/common_mark/syntax_highlight_filter_test.rb
index 70cc95301..630d9a273 100644
--- a/test/unit/lib/redmine/wiki_formatting/common_mark/syntax_highlight_filter_test.rb
+++ b/test/unit/lib/redmine/wiki_formatting/common_mark/syntax_highlight_filter_test.rb
@@ -18,7 +18,7 @@
# 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