Don't try and highlight plain text

This commit is contained in:
Gnarwhal 2024-09-24 23:44:15 +00:00
parent f1bdfaade9
commit 2bac7f434e
Signed by: Gnarwhal
GPG key ID: 0989A73D8C421174
2 changed files with 26 additions and 20 deletions

View file

@ -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,
});

View file

@ -38,7 +38,6 @@ const type_map = {
json: 'json',
md: 'markdown',
markdown: 'markdown',
none: 'none',
}
export function map_to_type(extension?: string) {
@ -68,8 +67,10 @@ export default function Text({ language, text, line_numbers }: { language: strin
};
});
console.log(language, language in type_map);
return <div className={style.group}>
{line_numbers ? <p className={style.line_numbers}>{lines.map((_, index) => `${index}\n`)}</p> : <></>}
{language in type_map ?
<Highlight
theme={themes[light_theme ? 'nightOwlLight' : 'oneDark']}
code={text}
@ -86,6 +87,8 @@ export default function Text({ language, text, line_numbers }: { language: strin
))}
</div>
)}
</Highlight>
</Highlight> :
<p className={style.plain}>{text}</p>
}
</div>;
}