bedazzlr 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +9 -5
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
buildReferenceMatcher,
|
|
17
17
|
} from '@bablr/helpers/builders';
|
|
18
18
|
import { buildEmbeddedMatcher } from '@bablr/agast-vm-helpers/builders';
|
|
19
|
+
import { hoistTrivia } from '@bablr/agast-helpers/stream';
|
|
19
20
|
|
|
20
21
|
let anchorStyle =
|
|
21
22
|
'display: inline-block; position: relative; vertical-align: top; pointer-events: none;';
|
|
@@ -69,9 +70,11 @@ const countIndents = (root) => {
|
|
|
69
70
|
let indents = 0;
|
|
70
71
|
while (el) {
|
|
71
72
|
if (el.classList.contains('trivia')) {
|
|
72
|
-
|
|
73
|
+
if (el?.getAttribute('name') !== 'LeftOffset') {
|
|
74
|
+
return Infinity;
|
|
75
|
+
}
|
|
73
76
|
|
|
74
|
-
|
|
77
|
+
let leftOffset = el;
|
|
75
78
|
|
|
76
79
|
el = leftOffset.firstElementChild;
|
|
77
80
|
|
|
@@ -81,6 +84,7 @@ const countIndents = (root) => {
|
|
|
81
84
|
}
|
|
82
85
|
return indents;
|
|
83
86
|
} else {
|
|
87
|
+
if (el.tagName === 'A') debugger;
|
|
84
88
|
el =
|
|
85
89
|
el.previousElementSibling ||
|
|
86
90
|
(el.parentElement.tagName === 'NODE' ? el.parentElement : null);
|
|
@@ -114,9 +118,9 @@ export const removeDocumentListeners = () => {
|
|
|
114
118
|
};
|
|
115
119
|
|
|
116
120
|
export const highlightCode = (el, language, matcher = language.defaultMatcher) => {
|
|
117
|
-
let tags =
|
|
118
|
-
|
|
119
|
-
]();
|
|
121
|
+
let tags = hoistTrivia(
|
|
122
|
+
streamParse(language, matcher, el.innerText, null, { holdShiftedNodes: true }),
|
|
123
|
+
)[Symbol.iterator]();
|
|
120
124
|
|
|
121
125
|
let open;
|
|
122
126
|
let referenceTag = null;
|