Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2015-08-27 23:09:01 +0300
committerRobert Speicher <rspeicher@gmail.com>2015-08-28 00:17:26 +0300
commit4340dd3eeb6fdda83b729c16cba29239b8ed9f43 (patch)
treef583b7a81cfbd47a7ec393397d17e37dee759539 /app/helpers/gitlab_markdown_helper.rb
parent10ee826847f956a235952fbb41d5ba589927b862 (diff)
Decouple Gitlab::Markdown from the GitlabMarkdownHelper
This module is now the sole source of knowledge for *how* we render Markdown (and GFM).
Diffstat (limited to 'app/helpers/gitlab_markdown_helper.rb')
-rw-r--r--app/helpers/gitlab_markdown_helper.rb34
1 files changed, 10 insertions, 24 deletions
diff --git a/app/helpers/gitlab_markdown_helper.rb b/app/helpers/gitlab_markdown_helper.rb
index 114730eb948..b7fec9fc1d9 100644
--- a/app/helpers/gitlab_markdown_helper.rb
+++ b/app/helpers/gitlab_markdown_helper.rb
@@ -1,7 +1,6 @@
require 'nokogiri'
module GitlabMarkdownHelper
- include Gitlab::Markdown
include PreferencesHelper
# Use this in places where you would normally use link_to(gfm(...), ...).
@@ -22,7 +21,7 @@ module GitlabMarkdownHelper
escape_once(body)
end
- gfm_body = gfm(escaped_body, {}, html_options)
+ gfm_body = Gitlab::Markdown.gfm(escaped_body, project: @project, current_user: current_user)
fragment = Nokogiri::XML::DocumentFragment.parse(gfm_body)
if fragment.children.size == 1 && fragment.children[0].name == 'a'
@@ -42,29 +41,16 @@ module GitlabMarkdownHelper
fragment.to_html.html_safe
end
- MARKDOWN_OPTIONS = {
- no_intra_emphasis: true,
- tables: true,
- fenced_code_blocks: true,
- strikethrough: true,
- lax_spacing: true,
- space_after_headers: true,
- superscript: true,
- footnotes: true
- }.freeze
-
- def markdown(text, options={})
- unless @markdown && options == @options
- @options = options
-
- # see https://github.com/vmg/redcarpet#darling-i-packed-you-a-couple-renderers-for-lunch
- rend = Redcarpet::Render::GitlabHTML.new(self, options)
-
- # see https://github.com/vmg/redcarpet#and-its-like-really-simple-to-use
- @markdown = Redcarpet::Markdown.new(rend, MARKDOWN_OPTIONS)
- end
+ def markdown(text, context = {})
+ context.merge!(
+ current_user: current_user,
+ project: @project,
+ project_wiki: @project_wiki,
+ ref: @ref,
+ requested_path: @path
+ )
- @markdown.render(text).html_safe
+ Gitlab::Markdown.render(text, context)
end
def asciidoc(text)