diff options
Diffstat (limited to 'lib/gitlab/reference_extractor.rb')
-rw-r--r-- | lib/gitlab/reference_extractor.rb | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/lib/gitlab/reference_extractor.rb b/lib/gitlab/reference_extractor.rb index da8df8a3025..69c7a0f4779 100644 --- a/lib/gitlab/reference_extractor.rb +++ b/lib/gitlab/reference_extractor.rb @@ -9,11 +9,12 @@ module Gitlab @project = project @current_user = current_user @load_lazy_references = load_lazy_references + + @texts = [] end - def analyze(text) - references.clear - @text = Gitlab::Markdown.render_without_gfm(text) + def analyze(text, options = {}) + @texts << Gitlab::Markdown.render(text, options.merge(project: project)) end %i(user label issue merge_request snippet commit commit_range).each do |type| @@ -40,28 +41,25 @@ module Gitlab # # Returns the results Array for the requested filter type def pipeline_result(filter_type) - return [] if @text.blank? - klass = "#{filter_type.to_s.camelize}ReferenceFilter" filter = Gitlab::Markdown.const_get(klass) context = { - project: project, + pipeline: :reference_extraction, + + project: project, current_user: current_user, - - # We don't actually care about the links generated - only_path: true, - ignore_blockquotes: true, # ReferenceGathererFilter load_lazy_references: false, reference_filter: filter } - pipeline = HTML::Pipeline.new([filter, Gitlab::Markdown::ReferenceGathererFilter], context) - result = pipeline.call(@text) - - values = result[:references][filter_type].uniq + values = @texts.flat_map do |html| + text_context = context.dup + result = Gitlab::Markdown.render_result(html, text_context) + result[:references][filter_type] + end.uniq if @load_lazy_references values = Gitlab::Markdown::ReferenceFilter::LazyReference.load(values).uniq |