Improve HTMLGitlab formatter performance

What does this MR do and why?

Problem

HTMLGitlab spends excessive time and memory splitting formatter output with Rouge's regex-based line scanner, especially for large single-line files.

Solution

  • Override token_lines with String#split("\n", -1) and Array#pop.
  • Preserve empty lines, trailing line semantics, token boundaries, and the protected Enumerator interface.
  • Cover line boundaries, multibyte text, encoding errors, and visibility.

How to set up and validate locally

  • bundle exec rspec spec/lib/rouge/formatters/html_gitlab_spec.rb: 19 examples, 0 failures.
  • Targeted RuboCop: 2 files inspected, no offenses detected.
  • git diff --check: passed.

MR acceptance checklist

  • Tests added for the formatter behavior.
  • Focused RSpec checks passed.
  • Targeted RuboCop passed.
  • git diff --check passed.
  • No visual UI changes, so screenshots are not applicable.
  • No database, migration, authentication, authorization, or dependency changes.
  • Performance optimization is covered by the focused tests.

Merge request reports

Loading
Loading