KaTeX math does not render when indented

Summary

KaTeX expressions currently are not rendered when they are indented, regardless of whether or not you use a code block or single line format. It's unclear on whether or not this is "supported" with our current implementation but because it results in unexpected behavior I'm considering this a bug.


Take for example:

3. Lorem ipsum dolor sit amet

    $$
    k' := \#\{p_i\ | \ p_i < \alpha_{fdr}\}\ \in \ \{0,...,m\}
    $$

    Lorem ipsum dolor sit ametLorem ipsum dolor sit ametLorem ipsum dolor sit amet

Note the below is not rendered, though we expect it to be.

  1. Lorem ipsum dolor sit amet

    $$ k' := #{p_i\ | \ p_i < \alpha_{fdr}}\ \in \ {0,...,m} $$

    Lorem ipsum dolor sit ametLorem ipsum dolor sit ametLorem ipsum dolor sit amet


If you remove the indents, it will render, but anything else indented after will end up in a strange code block:

  1. Lorem ipsum dolor sit amet
k' := \#\{p_i\ | \ p_i < \alpha_{fdr}\}\ \in \ \{0,...,m\}
Lorem ipsum dolor sit ametLorem ipsum dolor sit ametLorem ipsum dolor sit amet

Steps to reproduce

See the above markdown.

Example Project

What is the current bug behavior?

KaTeX math is not properly rendered when indented.

What is the expected correct behavior?

KaTeX math should be rendered when indented.

Relevant logs and/or screenshots

Output of checks

This bug happens on GitLab.com and was additionally reproduced in GitLab 16.1.

Results of GitLab environment info

Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:env:info`)

(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)

Results of GitLab application Check

Expand for output related to the GitLab application check

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)

(we will only investigate if the tests are passing)

Possible fixes