@@ -26,6 +26,7 @@ import { computed, onMounted, onUnmounted, ref, watchEffect } from 'vue'
2626import { CLASS_VCLICK_HIDDEN , CLASS_VCLICK_TARGET , CLICKS_MAX } from ' ../constants'
2727import { useSlideContext } from ' ../context'
2828import { makeId } from ' ../logic/utils'
29+ import { collectKatexEquationLines } from ' ./katex-lines'
2930
3031const props = defineProps ({
3132 ranges: {
@@ -77,26 +78,10 @@ onMounted(() => {
7778 if (hide )
7879 rangeStr = props .ranges [index .value + 1 ] ?? finallyRange .value
7980
80- // KaTeX equations have col-align-XXX as parent
81- const equationParents = el .value .querySelectorAll (' .mtable > [class*=col-align]' )
82- if (! equationParents )
83- return
84-
85- // For each row we extract the individual equation rows
86- const equationRowsOfEachParent = Array .from (equationParents )
87- .map (item => Array .from (item .querySelectorAll (' :scope > .vlist-t > .vlist-r > .vlist > span > .mord' )))
8881 // This list maps rows from different parents to line them up
89- const lines: Element [][] = []
90- for (const equationRowParent of equationRowsOfEachParent ) {
91- equationRowParent .forEach ((equationRow , idx ) => {
92- if (! equationRow )
93- return
94- if (Array .isArray (lines [idx ]))
95- lines [idx ].push (equationRow )
96- else
97- lines [idx ] = [equationRow ]
98- })
99- }
82+ const lines = collectKatexEquationLines (el .value )
83+ if (! lines .length )
84+ return
10085
10186 const startLine = props .startLine
10287 const highlights: number [] = parseRangeString (lines .length + startLine - 1 , rangeStr )
0 commit comments