Skip to content

Commit b897b13

Browse files
Render markdown attachments using markdown or common_mark based on the text formatting setting (#32424).
Patch by Marius BĂLTEANU and Martin Cizek. git-svn-id: http://svn.redmine.org/redmine/trunk@21165 e93f8b46-1217-0410-a6f0-8f06a7374b81
1 parent c1b3804 commit b897b13

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

app/helpers/application_helper.rb

+10
Original file line numberDiff line numberDiff line change
@@ -1837,6 +1837,16 @@ def copy_object_url_link(url)
18371837
)
18381838
end
18391839

1840+
# Returns the markdown formatter: markdown or common_mark
1841+
# ToDo: Remove this when markdown will be removed
1842+
def markdown_formatter
1843+
if Setting.text_formatting == "common_mark"
1844+
"common_mark"
1845+
else
1846+
"markdown"
1847+
end
1848+
end
1849+
18401850
private
18411851

18421852
def wiki_helper

app/helpers/attachments_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def render_api_attachment_attributes(attachment, api)
9292

9393
def render_file_content(attachment, content)
9494
if attachment.is_markdown?
95-
render :partial => 'common/markup', :locals => {:markup_text_formatting => 'markdown', :markup_text => content}
95+
render :partial => 'common/markup', :locals => {:markup_text_formatting => markdown_formatter, :markup_text => content}
9696
elsif attachment.is_textile?
9797
render :partial => 'common/markup', :locals => {:markup_text_formatting => 'textile', :markup_text => content}
9898
else

app/views/repositories/entry.html.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<% elsif Redmine::MimeType.of(@path) == 'text/x-textile' %>
1414
<%= render :partial => 'common/markup', :locals => {:markup_text_formatting => 'textile', :markup_text => @content} %>
1515
<% elsif Redmine::MimeType.of(@path) == 'text/markdown' %>
16-
<%= render :partial => 'common/markup', :locals => {:markup_text_formatting => 'markdown', :markup_text => @content} %>
16+
<%= render :partial => 'common/markup', :locals => {:markup_text_formatting => markdown_formatter, :markup_text => @content} %>
1717
<% elsif @content %>
1818
<%= render :partial => 'common/file', :locals => {:filename => @path, :content => @content} %>
1919
<% else %>

0 commit comments

Comments
 (0)