2024-04-23 15:16:51 +00:00
|
|
|
import { lex } from "./lexer";
|
2024-03-26 23:29:52 +00:00
|
|
|
|
2024-07-05 14:40:10 +00:00
|
|
|
export function thp_highlighter(code: string) {
|
2024-03-26 23:29:52 +00:00
|
|
|
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;
|
2024-03-26 23:29:52 +00:00
|
|
|
}
|