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
path: root/lib
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-10-02 12:18:40 +0400
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-10-02 12:18:40 +0400
commit6c3ad0dab639203961f8b3b2e59ffe78e9a21581 (patch)
treeec4c05f4948253b852aead1b7a4a1ca662c8de87 /lib
parent51bc636eb34934747f7808b2fc0cd59e9cb8e6b6 (diff)
parent390183a4269684f64e2e290869bee21cf18bf160 (diff)
Merge pull request #7853 from Razer6/feature/html_pipeline
Factor out Emoji parsing using html-pipeline-gitlab
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/markdown.rb36
1 files changed, 13 insertions, 23 deletions
diff --git a/lib/gitlab/markdown.rb b/lib/gitlab/markdown.rb
index 6017a4c86c1..d346acf0d32 100644
--- a/lib/gitlab/markdown.rb
+++ b/lib/gitlab/markdown.rb
@@ -1,3 +1,6 @@
+require 'html/pipeline'
+require 'html/pipeline/gitlab'
+
module Gitlab
# Custom parser for GitLab-flavored Markdown
#
@@ -62,6 +65,16 @@ module Gitlab
insert_piece($1)
end
+ # Context passed to the markdoqwn pipeline
+ markdown_context = {
+ asset_root: File.join(root_url,
+ Gitlab::Application.config.assets.prefix)
+ }
+
+ result = HTML::Pipeline::Gitlab::MarkdownPipeline.call(text,
+ markdown_context)
+ text = result[:output].to_html(save_with: 0)
+
allowed_attributes = ActionView::Base.sanitized_allowed_attributes
allowed_tags = ActionView::Base.sanitized_allowed_tags
@@ -91,7 +104,6 @@ module Gitlab
# Returns parsed text
def parse(text, project = @project)
parse_references(text, project) if project
- parse_emoji(text)
text
end
@@ -136,28 +148,6 @@ module Gitlab
end
end
- EMOJI_PATTERN = %r{(:(\S+):)}.freeze
-
- def parse_emoji(text)
- # parse emoji
- text.gsub!(EMOJI_PATTERN) do |match|
- if valid_emoji?($2)
- image_tag(url_to_image("emoji/#{$2}.png"), class: 'emoji', title: $1, alt: $1, size: "20x20")
- else
- match
- end
- end
- end
-
- # Private: Checks if an emoji icon exists in the image asset directory
- #
- # emoji - Identifier of the emoji as a string (e.g., "+1", "heart")
- #
- # Returns boolean
- def valid_emoji?(emoji)
- Emoji.find_by_name(emoji)
- end
-
# Private: Dispatches to a dedicated processing method based on reference
#
# reference - Object reference ("@1234", "!567", etc.)