mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 21:28:11 +09:00 
			
		
		
		
	Tweak katex options (#21828)
- Render directly into DOM, skipping string conversion - Add limiting options to prevent excessive size/macros - Remove invalid `display` option previously passed Ref: https://katex.org/docs/options.html Co-authored-by: John Olheiser <john.olheiser@gmail.com>
This commit is contained in:
		| @@ -23,12 +23,14 @@ export async function renderMath() { | |||||||
|  |  | ||||||
|   for (const el of els) { |   for (const el of els) { | ||||||
|     const source = el.textContent; |     const source = el.textContent; | ||||||
|     const options = {display: el.classList.contains('display')}; |     const nodeName = el.classList.contains('display') ? 'p' : 'span'; | ||||||
|  |  | ||||||
|     try { |     try { | ||||||
|       const markup = katex.renderToString(source, options); |       const tempEl = document.createElement(nodeName); | ||||||
|       const tempEl = document.createElement(options.display ? 'p' : 'span'); |       katex.render(source, tempEl, { | ||||||
|       tempEl.innerHTML = markup; |         maxSize: 25, | ||||||
|  |         maxExpand: 50, | ||||||
|  |       }); | ||||||
|       targetElement(el).replaceWith(tempEl); |       targetElement(el).replaceWith(tempEl); | ||||||
|     } catch (error) { |     } catch (error) { | ||||||
|       displayError(el, error); |       displayError(el, error); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user