summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMarius Balteanu <marius.balteanu@zitec.com>2024-11-03 12:02:39 +0000
committerMarius Balteanu <marius.balteanu@zitec.com>2024-11-03 12:02:39 +0000
commitda87320ebc2a62183a7c0e161add813c7a83777c (patch)
tree4dfa046f76856e3c9d4fef6f4c7feb0cd0d8d044 /lib
parent586020045be78f394c09f08b6409864c6804cd21 (diff)
downloadredmine-da87320ebc2a62183a7c0e161add813c7a83777c.tar.gz
redmine-da87320ebc2a62183a7c0e161add813c7a83777c.zip
Updates commonmark gem version to 1.1.5 which switches from libcmark-gfm to comrak/Rust.
git-svn-id: https://svn.redmine.org/redmine/trunk@23188 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r--lib/redmine.rb2
-rw-r--r--lib/redmine/preparation.rb2
-rw-r--r--lib/redmine/wiki_formatting/common_mark/formatter.rb29
-rw-r--r--lib/redmine/wiki_formatting/common_mark/markdown_filter.rb14
4 files changed, 24 insertions, 23 deletions
diff --git a/lib/redmine.rb b/lib/redmine.rb
index 2edfa55e9..95b3b7f3f 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 1aeb81e46..822662e11 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 42cae4f3a..4a0a7ec53 100644
--- a/lib/redmine/wiki_formatting/common_mark/formatter.rb
+++ b/lib/redmine/wiki_formatting/common_mark/formatter.rb
@@ -26,29 +26,26 @@ module Redmine
# 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
diff --git a/lib/redmine/wiki_formatting/common_mark/markdown_filter.rb b/lib/redmine/wiki_formatting/common_mark/markdown_filter.rb
index 916c8883c..abde25443 100644
--- a/lib/redmine/wiki_formatting/common_mark/markdown_filter.rb
+++ b/lib/redmine/wiki_formatting/common_mark/markdown_filter.rb
@@ -32,8 +32,12 @@ module Redmine
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
@@ -41,15 +45,15 @@ module Redmine
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