Skip to content

Commit 3ac3070

Browse files
Fix word highlights (#2250)
This basically reverts the FF fix from #2126 which fixed FF but broke word highlights. Also divs aren't allowed in `<code>` elements so Shiki's assumption that it really only needs to look inside `<span>`s isn't a terrible one in this case. We'll have to come up with some other solution to work around the FF bug
1 parent ce11c3c commit 3ac3070

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/components/code-example.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { createHighlighter } from "shiki";
1010
import theme from "./syntax-highlighter/theme.json";
1111

1212
import { highlightClasses } from "./highlight-classes";
13-
import linesToDiv from "./lines-to-div";
1413
import atApplyInjection from "./syntax-highlighter/at-apply.json";
1514
import atRulesInjection from "./syntax-highlighter/at-rules.json";
1615
import themeFnInjection from "./syntax-highlighter/theme-fn.json";
@@ -138,7 +137,7 @@ export function HighlightedCode({
138137
example={example}
139138
className={clsx(
140139
"*:flex *:*:shrink-0 *:*:grow *:overflow-auto *:rounded-lg *:bg-white/10! *:p-5 dark:*:bg-white/5!",
141-
"**:[.line]:isolate **:[.line]:not-last:min-h-[1lh]",
140+
"**:[.line]:isolate **:[.line]:block **:[.line]:not-last:min-h-[1lh]",
142141
"*:inset-ring *:inset-ring-white/10 dark:*:inset-ring-white/5",
143142
example.lang === "txt" ? "*:*:max-w-full *:*:whitespace-normal" : "*:*:max-w-none",
144143
className,
@@ -182,7 +181,6 @@ export function RawHighlightedCode({
182181
highlightedClassName:
183182
"highlighted-word relative before:absolute before:-inset-x-0.5 before:-inset-y-0.25 before:-z-10 before:block before:rounded-sm before:bg-[lab(19.93_-1.66_-9.7)] [.highlighted-word_+_&]:before:rounded-l-none",
184183
}),
185-
linesToDiv(),
186184
],
187185
})
188186
.replaceAll("\n", "");

0 commit comments

Comments
 (0)