Fix #173869 marking active line for code elements too in markdown pre… (#173870)

Fix #173869 marking active line for code elements too in markdown preview
This commit is contained in:
Ely Ronnen
2023-02-08 22:25:54 +02:00
committed by GitHub
parent 646de5e063
commit 5b79b91838
2 changed files with 7 additions and 5 deletions

View File

@@ -11,6 +11,7 @@ const codeLineClass = 'code-line';
export interface CodeLineElement {
element: HTMLElement;
line: number;
codeElement?: HTMLElement;
}
const getCodeLineElements = (() => {
@@ -27,9 +28,9 @@ const getCodeLineElements = (() => {
}
if (element.tagName === 'CODE' && element.parentElement && element.parentElement.tagName === 'PRE') {
// Fenched code blocks are a special case since the `code-line` can only be marked on
// Fenced code blocks are a special case since the `code-line` can only be marked on
// the `<code>` element and not the parent `<pre>` element.
cachedElements.push({ element: element.parentElement as HTMLElement, line });
cachedElements.push({ element: element.parentElement as HTMLElement, line: line, codeElement: element as HTMLElement });
} else if (element.tagName === 'UL' || element.tagName === 'OL') {
// Skip adding list elements since the first child has the same code line (and should be preferred)
} else {