Commit 3d2b663e authored by Sean McGivern's avatar Sean McGivern

Merge branch 'dm-pull-preserve-into-render-helpers' into 'master'

Pull preserve into render helpers

See merge request !10986
parents bb3870ea 0be3187a
......@@ -74,7 +74,7 @@ module MarkupHelper
context[:project] ||= @project
html = markdown_unsafe(text, context)
banzai_postprocess(html, context)
prepare_for_rendering(html, context)
end
def markdown_field(object, field)
......@@ -82,13 +82,13 @@ module MarkupHelper
return '' unless object.present?
html = Banzai.render_field(object, field)
banzai_postprocess(html, object.banzai_render_context(field))
prepare_for_rendering(html, object.banzai_render_context(field))
end
def markup(file_name, text, context = {})
context[:project] ||= @project
html = context.delete(:rendered) || markup_unsafe(file_name, text, context)
banzai_postprocess(html, context)
prepare_for_rendering(html, context)
end
def render_wiki_content(wiki_page)
......@@ -107,14 +107,14 @@ module MarkupHelper
wiki_page.formatted_content.html_safe
end
banzai_postprocess(html, context)
prepare_for_rendering(html, context)
end
def markup_unsafe(file_name, text, context = {})
return '' unless text.present?
if gitlab_markdown?(file_name)
Hamlit::RailsHelpers.preserve(markdown_unsafe(text, context))
markdown_unsafe(text, context)
elsif asciidoc?(file_name)
asciidoc_unsafe(text)
elsif plain?(file_name)
......@@ -225,8 +225,7 @@ module MarkupHelper
Gitlab::OtherMarkup.render(file_name, text)
end
# Calls Banzai.post_process with some common context options
def banzai_postprocess(html, context = {})
def prepare_for_rendering(html, context = {})
return '' unless html.present?
context.merge!(
......@@ -239,7 +238,9 @@ module MarkupHelper
requested_path: @path
)
Banzai.post_process(html, context)
html = Banzai.post_process(html, context)
Hamlit::RailsHelpers.preserve(html)
end
extend self
......
......@@ -27,7 +27,6 @@
.row
.col-md-8
.documentation-index
= preserve do
= markdown(@help_index)
.col-md-4
.panel.panel-default
......
......@@ -2,7 +2,6 @@
%div{ class: container_class }
.wiki-holder.prepend-top-default.append-bottom-default
.wiki
= preserve do
= render_wiki_content(@wiki_home)
- else
- can_create_wiki = can?(current_user, :create_wiki, @project)
......
......@@ -58,7 +58,6 @@
- if @issue.description.present?
.description{ class: can?(current_user, :update_issue, @issue) ? 'js-task-list-container' : '' }
.wiki
= preserve do
= markdown_field(@issue, :description)
%textarea.hidden.js-task-list-field
= @issue.description
......
......@@ -6,7 +6,6 @@
- if @merge_request.description.present?
.description{ class: can?(current_user, :update_merge_request, @merge_request) ? 'js-task-list-container' : '' }
.wiki
= preserve do
= markdown_field(@merge_request, :description)
%textarea.hidden.js-task-list-field
= @merge_request.description
......
......@@ -43,7 +43,6 @@
- if @milestone.description.present?
.description
.wiki
= preserve do
= markdown_field(@milestone, :description)
- if can?(current_user, :read_issue, @project) && @milestone.total_items_count(current_user).zero?
......
......@@ -75,7 +75,6 @@
= icon('trash-o', class: 'danger-highlight')
.note-body{ class: note_editable ? 'js-task-list-container' : '' }
.note-text.md
= preserve do
= note.redacted_note_html
= edited_time_ago_with_tooltip(note, placement: 'bottom', html_class: 'note_edited_ago', include_author: true)
- if note_editable
......
......@@ -24,7 +24,6 @@
- if release && release.description.present?
.description.prepend-top-default
.wiki
= preserve do
= markdown_field(release, :description)
.row-fixed-content.controls
......
......@@ -38,7 +38,6 @@
- if @release.description.present?
.description
.wiki
= preserve do
= markdown_field(@release, :description)
- else
This tag has no release notes.
......@@ -27,7 +27,6 @@
.wiki-holder.prepend-top-default.append-bottom-default
.wiki
= preserve do
= render_wiki_content(@page)
= render 'sidebar'
......@@ -8,7 +8,6 @@
.pull-right ##{issue.iid}
- if issue.description.present?
.description.term
= preserve do
= search_md_sanitize(issue, :description)
%span.light
#{issue.project.name_with_namespace}
......@@ -9,7 +9,6 @@
.pull-right= merge_request.to_reference
- if merge_request.description.present?
.description.term
= preserve do
= search_md_sanitize(merge_request, :description)
%span.light
#{merge_request.project.name_with_namespace}
......@@ -5,5 +5,4 @@
- if milestone.description.present?
.description.term
= preserve do
= search_md_sanitize(milestone, :description)
......@@ -22,5 +22,4 @@
.note-search-result
.term
= preserve do
= search_md_sanitize(note, :note)
......@@ -4,7 +4,6 @@
= render "projects/services/#{@service.to_param}/help", subject: subject
- elsif @service.help.present?
.well
= preserve do
= markdown @service.help
.service-settings
......
......@@ -21,7 +21,7 @@ class Spinach::Features::ProjectCommits < Spinach::FeatureSteps
expect(response_headers['Content-Type']).to have_content("application/atom+xml")
expect(body).to have_selector("title", text: "#{@project.name}:master commits")
expect(body).to have_selector("author email", text: commit.author_email)
expect(body).to have_selector("entry summary", text: commit.description[0..10].delete("\r"))
expect(body).to have_selector("entry summary", text: commit.description[0..10].delete("\r\n"))
end
step 'I click on tag link' do
......
......@@ -53,7 +53,7 @@ describe "User Feed", feature: true do
end
it 'has XHTML summaries in issue descriptions' do
expect(body).to match /we have a bug!<\/p>\n\n<hr ?\/>\n\n<p dir="auto">I guess/
expect(body).to match /<hr ?\/>/
end
it 'has XHTML summaries in notes' do
......
......@@ -56,7 +56,7 @@ describe EventsHelper do
it 'preserves code color scheme' do
input = "```ruby\ndef test\n 'hello world'\nend\n```"
expected = '<pre class="code highlight js-syntax-highlight ruby">' \
expected = "\n<pre class=\"code highlight js-syntax-highlight ruby\">" \
"<code><span class=\"line\"><span class=\"k\">def</span> <span class=\"nf\">test</span>...</span>\n" \
"</code></pre>"
expect(helper.event_note(input)).to eq(expected)
......
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