I couldn't find a way to I just wrote a component for this with katex
.
// katex.component.ts
export class KatexComponent implements AfterViewInit{
@Input({required: true}) tex?: string
@ViewChild('ptex') texElement?: ElementRef
ngAfterViewInit(){
katex.render(this.tex || "", this.texElement?.nativeElement)
}
}
// katex-label.component.ts
export class KatexLabelComponent {
parts: {math: boolean, value: string}[] = []
@Input({ required: true }) tex: string = "";
ngOnInit() {
const splitContent = this.tex.split(/(\$\$.*?\$\$)/);
this.parts = splitContent.map(part => {
if (part.startsWith('$$')) {
return { math: true, value: part.slice(2, -2) };
} else {
return { math: false, value: part };
}
});
}
Also, sorry for posting this late. I completely forgot about this question.