lib/banzai/filter/abstract_reference_filter.rb
# Replace references (like `!123` for merge requests) in text with links
# to the referenced object's details page.
#
# text - String text to replace references in.
# pattern - Reference pattern to match against.
# link_text - Original content of the link being replaced.
#
# Returns a String with references replaced with links. All links
# have `gfm` and `gfm-OBJECT_NAME` class names attached for styling.
Replace references (like `!123` for merge requests) in text with links
to the referenced object's details page.

String text to replace references in.
pattern - Reference pattern to match against.
link_text - Original content of the link being replaced.

Returns a String with references replaced with links. All links
have `gfm` and `gfm-OBJECT_NAME` class names attached for styling.
Replace references ( like ` !123 ` for merge requests ) in text with links to the referenced object ' s details page . String text to replace references in . pattern - Reference pattern to match against . link_text - Original content of the link being replaced . Returns a String with references replaced with links . All links have ` gfm ` and ` gfm - OBJECT_NAME ` class names attached for styling .
def object_link_filter(text, pattern, link_text: nil)
        references_in(text, pattern) do |match, id, project_ref, matches|
          project = project_from_ref_cache(project_ref)
          if project && object = find_object_cached(project, id)
            title = object_link_title(object)
            klass = reference_class(object_sym)
            data  = data_attribute(
              original:     link_text || match,
              project:      project.id,
              object_sym => object.id
            )
            if matches.names.include?("url") && matches[:url]
              url = matches[:url]
            else
              url = url_for_object_cached(object, project)
            end
            text = link_text || object_link_text(object, matches)
            %(<a href="#{url}" #{data}
                 title="#{escape_once(title)}"
                 class="#{klass}">#{escape_once(text)}</a>)
          else
            match
          end
        end
      end
def object_link_filter ( text , pattern , link_text : nil ) references_in ( text , pattern ) do | match , id , project_ref , matches | project = project_from_ref_cache ( project_ref ) if project && object = find_object_cached ( project , id ) title = object_link_title ( object ) klass = reference_class ( object_sym ) data = data_attribute ( original : link_text || match , project : project . id , object_sym => object . id ) if matches . names . include? ( "url" ) && matches [ :url ] url = matches [ :url ] else url = url_for_object_cached ( object , project ) end text = link_text || object_link_text ( object , matches ) %(<a href="#{url}" #{data}
                 title="#{escape_once(title)}"
                 class="#{klass}">#{escape_once(text)}</a>) else match end end end
Replace references (like `!123` for merge requests) in text with links
to the referenced object's details page.
Replace references ( like ` !123 ` for merge requests ) in text with links to the referenced object ' s details page .
text
pattern
link_text