Don't try and highlight plain text
This commit is contained in:
parent
f1bdfaade9
commit
2bac7f434e
2 changed files with 26 additions and 20 deletions
|
@ -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,
|
||||
});
|
||||
|
|
|
@ -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>;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue