Commit 7665b1de authored by Dan Knox's avatar Dan Knox

Use Gitlab Markdown for Markdown files and Gollum to render the rest.

This commit enables the usage of the Gitlab Markdown post processing
on all Markdown formatted files. For file types that do not contain
Markdown, it defaults to the Gollum native renderer to process the
content.
parent f0aa54e0
......@@ -49,4 +49,12 @@ module GitlabMarkdownHelper
@markdown.render(text).html_safe
end
def render_wiki_content(wiki_page)
if wiki_page.format == :markdown
markdown(wiki_page.content)
else
wiki_page.formatted_content.html_safe
end
end
end
......@@ -10,7 +10,7 @@
.file_holder
.file_content.wiki
= preserve do
= @wiki.formatted_content.html_safe
= render_wiki_content(@wiki)
- commit = CommitDecorator.new(@wiki.version)
%p.time Last edited by #{commit.author_link(avatar: true, size: 16)} #{time_ago_in_words @wiki.created_at} ago
......@@ -363,4 +363,28 @@ describe GitlabMarkdownHelper do
markdown(":smile:").should include("src=\"#{url_to_image("emoji/smile")}")
end
end
describe "#render_wiki_content" do
before do
@wiki = stub('WikiPage')
@wiki.stub(:content).and_return('wiki content')
end
it "should use Gitlab Flavored Markdown for markdown files" do
@wiki.stub(:format).and_return(:markdown)
helper.should_receive(:markdown).with('wiki content')
helper.render_wiki_content(@wiki)
end
it "should use the Gollum renderer for all other file types" do
@wiki.stub(:format).and_return(:rdoc)
formatted_content_stub = stub('formatted_content')
formatted_content_stub.should_receive(:html_safe)
@wiki.stub(:formatted_content).and_return(formatted_content_stub)
helper.render_wiki_content(@wiki)
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment