diff --git a/app/assets/javascripts/behaviors/markdown/render_math.js b/app/assets/javascripts/behaviors/markdown/render_math.js index 12f47255bdf0de8add1a04b036cc4a19e240f773..e29c6e9b0bac27cfb1ca59e985c423c95e3d0aef 100644 --- a/app/assets/javascripts/behaviors/markdown/render_math.js +++ b/app/assets/javascripts/behaviors/markdown/render_math.js @@ -1,6 +1,7 @@ import { spriteIcon } from '~/lib/utils/common_utils'; import { differenceInMilliseconds } from '~/lib/utils/datetime_utility'; import { s__ } from '~/locale'; +import { unrestrictedPages } from './constants'; // Renders math using KaTeX in any element with the // `js-render-math` class @@ -48,6 +49,7 @@ class SafeMathRenderer { this.renderElement = this.renderElement.bind(this); this.render = this.render.bind(this); this.attachEvents = this.attachEvents.bind(this); + this.pageName = document.querySelector('body').dataset.page; } renderElement(chosenEl) { @@ -56,7 +58,7 @@ class SafeMathRenderer { } const el = chosenEl || this.queue.shift(); - const forceRender = Boolean(chosenEl); + const forceRender = Boolean(chosenEl) || unrestrictedPages.includes(this.pageName); const text = el.textContent; el.removeAttribute('style'); diff --git a/spec/features/markdown/math_spec.rb b/spec/features/markdown/math_spec.rb index fa23fac2f96fc1550f0e24bbf972ae6d37c290f0..1f2198868189b0996d8f4b7e9dd67675aa9b4493 100644 --- a/spec/features/markdown/math_spec.rb +++ b/spec/features/markdown/math_spec.rb @@ -67,4 +67,24 @@ expect(page).to have_selector('.js-lazy-render-math') end end + + it 'renders without any limits on wiki page', :js do + description = <<~MATH + ```math + \Huge \sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqr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}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} + ``` + MATH + + wiki_page = build(:wiki_page, { container: project, content: description }) + wiki_page.create message: 'math test commit' # rubocop:disable Rails/SaveBang + wiki_page = project.wiki.find_page(wiki_page.slug) + + visit project_wiki_path(project, wiki_page) + + wait_for_requests + + page.within '.js-wiki-page-content' do + expect(page).not_to have_selector('.js-lazy-render-math') + end + end end