Skip to content

Add language param to highlight

Mark Chao requested to merge add-language-param-to-highlight into master

The EE port is at https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/7276

What does this MR do?

highlighting currently takes a repository param. It is only used to read gitlab-language from .gitattribute file in the repository.

This is inflexible since not all highlighting cases are associated with a repository. The concept of finding a repository file's language should really belong to the blob.

By replacing the repository param with language param, we can now

  1. save some CPU cycle for rouge to guess file type if we know that ahead of time.
  2. makes caching more efficient, as forks of the same project can share highlighting the cache.

A BlobPresenter is introduced to handle blob specific highlighting, DRYing repeated logic.

What the reviewer should watch out for

Blob is the wrapper class for Gitlab::Git::Blob, SnippetBlob and Ci::ArtifactBlob.
FoundBlob is acting at the same level as Blob, not being wrapped by it.

What are the relevant issue numbers?

Does this MR meet the acceptance criteria?

Edited by Mark Chao

Merge request reports