From 2bac7f434e3f05659dbc5bc53249bf948e93d994 Mon Sep 17 00:00:00 2001 From: Gnarwhal Date: Tue, 24 Sep 2024 23:44:15 +0000 Subject: [PATCH] Don't try and highlight plain text --- .../[...file]/components/types/text.css.ts | 7 +++- src/app/[...file]/components/types/text.tsx | 39 ++++++++++--------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/app/[...file]/components/types/text.css.ts b/src/app/[...file]/components/types/text.css.ts index ccfee53..a414766 100644 --- a/src/app/[...file]/components/types/text.css.ts +++ b/src/app/[...file]/components/types/text.css.ts @@ -21,9 +21,12 @@ export const group = style({ export const line_numbers = style({ margin: '0', - marginRight: '0.5em', - paddingRight: '0.5em', + marginRight: '1em', color: colors.foreground2, textAlign: 'right', userSelect: 'none', }); + +export const plain = style({ + margin: 0, +}); diff --git a/src/app/[...file]/components/types/text.tsx b/src/app/[...file]/components/types/text.tsx index 0755cb6..cf50a2c 100644 --- a/src/app/[...file]/components/types/text.tsx +++ b/src/app/[...file]/components/types/text.tsx @@ -38,7 +38,6 @@ const type_map = { json: 'json', md: 'markdown', markdown: 'markdown', - none: 'none', } export function map_to_type(extension?: string) { @@ -68,24 +67,28 @@ export default function Text({ language, text, line_numbers }: { language: strin }; }); + console.log(language, language in type_map); return
{line_numbers ?

{lines.map((_, index) => `${index}\n`)}

: <>} - - {({ tokens, getLineProps, getTokenProps }) => ( -
- {tokens.map((line, i) => ( -
- {line.map((token, key) => ( - - ))} -
- ))} -
- )} -
+ {language in type_map ? + + {({ tokens, getLineProps, getTokenProps }) => ( +
+ {tokens.map((line, i) => ( +
+ {line.map((token, key) => ( + + ))} +
+ ))} +
+ )} +
: +

{text}

+ }
; }