Actions
Feature #38372
closedUse Commonmarker instead of Redcarpet by default when rendering Markdown attachments
Start date:
Due date:
% Done:
0%
Estimated time:
Resolution:
Fixed
Description
markdown_formatter returns 'common_mark' only when text_formatting is common_mark, and 'markdown' otherwise.
For example, when you attach an markdown.md file and preview it in an environment where text_formatting is Textile, the contents of the file are converted to HTML by RedCarpet('markdown').
Since RedCarpet('markdown') was deprecated in #36807, why not change markdown_formatter to return 'markdown' only when text_formatting is markdown and 'cmmon_mark' otherwise?
Related issues
Updated by Mizuki ISHIKAWA over 1 year ago
Attached is a patch to change the code.
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 43f32fbc72..3177d0eb7c 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1855,10 +1855,10 @@ module ApplicationHelper
# Returns the markdown formatter: markdown or common_mark
# ToDo: Remove this when markdown will be removed
def markdown_formatter
- if Setting.text_formatting == "common_mark"
- "common_mark"
- else
+ if Setting.text_formatting == "markdown"
"markdown"
+ else
+ "common_mark"
end
end
diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb
index fc0351885f..d5d73282d8 100644
--- a/test/helpers/application_helper_test.rb
+++ b/test/helpers/application_helper_test.rb
@@ -2229,6 +2229,19 @@ class ApplicationHelperTest < Redmine::HelperTest
end
end
+ def test_markdown_formatter
+ [
+ ['markdown', 'markdown'],
+ ['common_mark', 'common_mark'],
+ ['textile', 'common_mark'],
+ ['', 'common_mark']
+ ].each do |text_formatting, expected|
+ with_settings text_formatting: text_formatting do
+ assert_equal expected, markdown_formatter
+ end
+ end
+ end
+
private
def wiki_links_with_special_characters
Updated by Go MAEDA over 1 year ago
- Related to Patch #36807: Remove CommonMark experimental flag and mark as deprecated the RedCarpet Markdown added
Updated by Go MAEDA over 1 year ago
- Subject changed from Change the default for markdown_formatter from markdown to common_mark to Use Commonmarker instead of Redcarpet by default when rendering Markdown attachments
Updated by Go MAEDA over 1 year ago
- Status changed from New to Closed
- Assignee set to Go MAEDA
- Resolution set to Fixed
Committed the change as a part of #36807. Thank you.
Actions