Commit 5a7451c2 authored by Brett Walker's avatar Brett Walker

Enable CommonMark for files and wikis

parent bd807fe0
...@@ -107,7 +107,6 @@ module MarkupHelper ...@@ -107,7 +107,6 @@ module MarkupHelper
def markup(file_name, text, context = {}) def markup(file_name, text, context = {})
context[:project] ||= @project context[:project] ||= @project
context[:markdown_engine] ||= :redcarpet
html = context.delete(:rendered) || markup_unsafe(file_name, text, context) html = context.delete(:rendered) || markup_unsafe(file_name, text, context)
prepare_for_rendering(html, context) prepare_for_rendering(html, context)
end end
...@@ -121,8 +120,7 @@ module MarkupHelper ...@@ -121,8 +120,7 @@ module MarkupHelper
project: @project, project: @project,
project_wiki: @project_wiki, project_wiki: @project_wiki,
page_slug: wiki_page.slug, page_slug: wiki_page.slug,
issuable_state_filter_enabled: true, issuable_state_filter_enabled: true
markdown_engine: :redcarpet
} }
html = html =
......
...@@ -580,7 +580,7 @@ class Repository ...@@ -580,7 +580,7 @@ class Repository
end end
def rendered_readme def rendered_readme
MarkupHelper.markup_unsafe(readme.name, readme.data, project: project, markdown_engine: :redcarpet) if readme MarkupHelper.markup_unsafe(readme.name, readme.data, project: project) if readme
end end
cache_method :rendered_readme cache_method :rendered_readme
......
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
- commit_message = commit_message % { page_title: @page.title } - commit_message = commit_message % { page_title: @page.title }
= form_for [@project.namespace.becomes(Namespace), @project, @page], method: @page.persisted? ? :put : :post, = form_for [@project.namespace.becomes(Namespace), @project, @page], method: @page.persisted? ? :put : :post,
html: { class: 'wiki-form common-note-form prepend-top-default js-quick-submit' }, html: { class: 'wiki-form common-note-form prepend-top-default js-quick-submit' } do |f|
data: { markdown_version: CacheMarkdownField::CACHE_REDCARPET_VERSION } do |f|
= form_errors(@page) = form_errors(@page)
- if @page.persisted? - if @page.persisted?
......
...@@ -207,7 +207,7 @@ describe MarkupHelper do ...@@ -207,7 +207,7 @@ describe MarkupHelper do
expect(helper).to receive(:markdown_unsafe).with('wiki content', expect(helper).to receive(:markdown_unsafe).with('wiki content',
pipeline: :wiki, project: project, project_wiki: @wiki, page_slug: "nested/page", pipeline: :wiki, project: project, project_wiki: @wiki, page_slug: "nested/page",
issuable_state_filter_enabled: true, markdown_engine: :redcarpet) issuable_state_filter_enabled: true)
helper.render_wiki_content(@wiki) helper.render_wiki_content(@wiki)
end end
...@@ -259,10 +259,12 @@ describe MarkupHelper do ...@@ -259,10 +259,12 @@ describe MarkupHelper do
expect(helper.markup('foo.md', content, rendered: '<p>NOEL</p>')).to eq('<p>NOEL</p>') expect(helper.markup('foo.md', content, rendered: '<p>NOEL</p>')).to eq('<p>NOEL</p>')
end end
it 'defaults to Redcarpet' do it 'defaults to CommonMark' do
expect(helper).to receive(:markdown_unsafe).with(content, hash_including(markdown_engine: :redcarpet)).and_return('NOEL') expect(helper.markup('foo.md', 'x^2')).to include('x^2')
end
expect(helper.markup('foo.md', content)).to eq('NOEL') it 'honors markdown_engine for RedCarpet' do
expect(helper.markup('foo.md', 'x^2', { markdown_engine: :redcarpet })).to include('x<sup>2</sup>')
end 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