79140999

Date: 2024-10-30 11:58:33
Score: 0.5
Natty:
Report link

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.

Reasons:
  • RegEx Blacklisted phrase (0.5): sorry for posting
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: thecodingsage