Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for unknown languages & style: Update code line for… #306

Merged
merged 5 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/ui/code-highlighter/shiki/Shiki.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}

.line {
@apply block min-h-[1em] px-4;
@apply block min-h-[1em];
}

.highlighted,
Expand Down
9 changes: 4 additions & 5 deletions src/components/ui/code-highlighter/shiki/Shiki.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ export const ShikiHighLighter: FC<Props> = (props) => {
() => import('shiki/langs/vue.mjs'),
() => import('shiki/langs/html.mjs'),
() => import('shiki/langs/asm.mjs'),
() => import('shiki/langs/bash.mjs'),
() => import('shiki/langs/shell.mjs'),
() => import('shiki/langs/ps.mjs'),
() => import('shiki/langs/ps1.mjs'),
],
loadWasm: getWasm,
})
Expand Down Expand Up @@ -103,7 +102,7 @@ export const ShikiHighLighter: FC<Props> = (props) => {
return codeHighlighter(highlighter, {
attrs: attrs || '',
code: value,
lang: language || '',
lang: language ? language.toLowerCase() : '',
})
}, [attrs, language, value, highlighter])

Expand Down Expand Up @@ -132,7 +131,7 @@ export const ShikiHighLighter: FC<Props> = (props) => {
{!filename && !!language && (
<div
aria-hidden
className="pointer-events-none absolute bottom-3 right-3 text-sm opacity-60"
className="pointer-events-none absolute bottom-3 right-3 z-10 text-sm opacity-60"
>
{language.toUpperCase()}
</div>
Expand All @@ -152,7 +151,7 @@ export const ShikiHighLighter: FC<Props> = (props) => {
<div
ref={setCodeBlockRef}
className={clsxm(
'relative max-h-[50vh] w-full overflow-auto scrollbar-none',
'relative max-h-[50vh] w-full overflow-auto px-4 scrollbar-none',
!isCollapsed ? '!max-h-[100%]' : isOverflow ? maskClassName : '',
)}
dangerouslySetInnerHTML={
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/code-highlighter/shiki/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,5 @@ export const isSupportedShikiLang = (lang: string) => {
'plaintext',
'txt',
'plain',
].includes(lang)
].includes(lang.toLowerCase())
}
Loading