File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
src/Elastic.Documentation.Site/Assets Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ const isLazyLoadNavigationEnabled =
2323 * Initialize KaTeX math rendering for elements with class 'math'
2424 */
2525function initMath ( ) {
26- const mathElements = $$ ( '.math' )
26+ const mathElements = $$ ( '.math:not([data-katex-processed]) ' )
2727 mathElements . forEach ( ( element ) => {
2828 try {
2929 const content = element . textContent ?. trim ( )
@@ -56,6 +56,9 @@ function initMath() {
5656 // Add common macros if needed
5757 } ,
5858 } )
59+
60+ // Mark as processed to prevent double processing
61+ element . setAttribute ( 'data-katex-processed' , 'true' )
5962 } catch ( error ) {
6063 console . warn ( 'KaTeX rendering error:' , error )
6164 // Fallback: keep the original content
@@ -64,6 +67,11 @@ function initMath() {
6467 } )
6568}
6669
70+ // Initialize math on initial page load
71+ document . addEventListener ( 'DOMContentLoaded' , function ( ) {
72+ initMath ( )
73+ } )
74+
6775document . addEventListener ( 'htmx:load' , function ( event ) {
6876 initTocNav ( )
6977 initHighlight ( )
You can’t perform that action at this time.
0 commit comments