mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-10-30 14:49:14 +00:00
28 lines
729 B
TypeScript
28 lines
729 B
TypeScript
import type {Token} from 'sentry/views/starfish/utils/sqlish/types';
|
|
|
|
export function simpleMarkup(tokens: Token[]): React.ReactElement[] {
|
|
const accumulator: React.ReactElement[] = [];
|
|
|
|
function contentize(token: Token): void {
|
|
if (Array.isArray(token.content)) {
|
|
token.content.forEach(contentize);
|
|
return;
|
|
}
|
|
|
|
if (typeof token.content === 'string') {
|
|
if (token.type === 'Keyword') {
|
|
accumulator.push(<b>{token.content.toUpperCase()}</b>);
|
|
} else if (token.type === 'Whitespace') {
|
|
accumulator.push(<span> </span>);
|
|
} else {
|
|
accumulator.push(<span>{token.content}</span>);
|
|
}
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
tokens.forEach(contentize);
|
|
return accumulator;
|
|
}
|