Skip to content

Pass language to the SourceViewer component

Jacques Erasmus requested to merge 348145-highlightjs-language into master

What does this MR do and why?

Passes the language field to the SourceViewer component so that we can pass it to highlight.js explicitly instead of relying on auto-detection. If a language cannot be mapped from Rouge to highlight.js we use the autodetect feature of highlight.js to determine the language.

changes in this MR are behind the :refactor_blob_viewer and :highlight_js feature flags.

Screenshots or screen recordings

language screenshot
Java Screenshot_2022-02-04_at_09.30.16
JavaScript Screenshot_2022-02-04_at_09.31.23
C Screenshot_2022-02-04_at_09.33.04
Vue (autodetected) Screenshot_2022-02-04_at_09.38.13

How to set up and validate locally

  1. Enable the Blob Viewer Refactor feature flag
Feature.enable(:refactor_blob_viewer)
  1. Enable the HighlightJS feature flag
Feature.enable(:highlight_js)
  1. View a source file

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #348145 (closed)

Edited by Jacques Erasmus

Merge request reports

Loading