thp-lang.org/src/lexer/highlighter.ts

14 lines
300 B
TypeScript
Raw Normal View History

2024-04-23 15:16:51 +00:00
import { lex } from "./lexer";
2024-07-05 14:40:10 +00:00
export function thp_highlighter(code: string) {
let tokens = lex(code);
let highlighted_code = "";
for (let token of tokens) {
highlighted_code += `<span class="token ${token.token_type}">${token.v}</span>`;
}
2024-07-05 14:40:10 +00:00
return highlighted_code;
}