From 95d9337dd2ae51b47cd83b5f0fb28edc7de8ff23 Mon Sep 17 00:00:00 2001 From: Marius BALTEANU Date: Sun, 4 Jul 2021 12:49:38 +0300 Subject: [PATCH 11/12] Render markdown attachments using markdown or common_mark based on the text formatting setting (#32424). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Patch by Marius BÄ‚LTEANU and Martin Cizek. --- app/helpers/application_helper.rb | 10 ++++++++++ app/helpers/attachments_helper.rb | 2 +- app/views/repositories/entry.html.erb | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 57f3e488b..c69e2df71 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1825,6 +1825,16 @@ module ApplicationHelper ) end + # 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 + "markdown" + end + end + private def wiki_helper diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb index b59f9446f..f8f90df87 100644 --- a/app/helpers/attachments_helper.rb +++ b/app/helpers/attachments_helper.rb @@ -92,7 +92,7 @@ module AttachmentsHelper def render_file_content(attachment, content) if attachment.is_markdown? - render :partial => 'common/markup', :locals => {:markup_text_formatting => 'markdown', :markup_text => content} + render :partial => 'common/markup', :locals => {:markup_text_formatting => markdown_formatter, :markup_text => content} elsif attachment.is_textile? render :partial => 'common/markup', :locals => {:markup_text_formatting => 'textile', :markup_text => content} else diff --git a/app/views/repositories/entry.html.erb b/app/views/repositories/entry.html.erb index 4f8678bea..831e8044a 100644 --- a/app/views/repositories/entry.html.erb +++ b/app/views/repositories/entry.html.erb @@ -13,7 +13,7 @@ <% elsif Redmine::MimeType.of(@path) == 'text/x-textile' %> <%= render :partial => 'common/markup', :locals => {:markup_text_formatting => 'textile', :markup_text => @content} %> <% elsif Redmine::MimeType.of(@path) == 'text/markdown' %> - <%= render :partial => 'common/markup', :locals => {:markup_text_formatting => 'markdown', :markup_text => @content} %> + <%= render :partial => 'common/markup', :locals => {:markup_text_formatting => markdown_formatter, :markup_text => @content} %> <% elsif @content %> <%= render :partial => 'common/file', :locals => {:filename => @path, :content => @content} %> <% else %> -- 2.22.0