Mathpix / mathpix-markdown-it

Markdown rendering + Latex extras (equations, tables, ...), with conversion features, for the scientific community
MIT License
539 stars 45 forks source link

Not displaying parser errors in rendered markdown #316

Open kebr0m opened 8 months ago

kebr0m commented 8 months ago

So I'm currently using nextjs and when something that should cause an error in the users markdown string is typed, it displays an error in the browser console, but doesn't display it in the rendered mathpix md, instead it omits the section causing the error from being rendered,

For example if this is the users md string:

image

we see the following log in the console: image

and this is what is rendered: image

what should be rendered is: image

import * as React from 'react';
import { MathpixMarkdown, MathpixLoader, optionsMathpixMarkdown, ParserErrors, TOutputMath } from 'mathpix-markdown-it';

export default function MathpixRenderer({
  equation,
  onDoubleClick,
}: Readonly<{
  equation: string;
  inline: boolean;
  onDoubleClick: () => void;
}>): JSX.Element {
  const markdownOptions: optionsMathpixMarkdown = {
    alignMathBlock: 'center',
    showTimeLog: true,
    isDisableFancy: false,
    htmlTags: true,
    xhtmlOut: false,
    breaks: true,
    typographer: true,
    linkify: true,
    width: 1200,
    codeHighlight: {
      auto: true,
      code: true,
    },
    parserErrors: ParserErrors.show // Adjusted to use ParserErrors enum
  };

  return (
    <div onDoubleClick={onDoubleClick} style={{ cursor: 'pointer' }}>
      <MathpixLoader>
        <MathpixMarkdown text={`${equation}`} {...markdownOptions} />
      </MathpixLoader>
    </div>
  );
}