Skip to content

Is there a programmatic test for whether a function is supported? #3167

Answered by edemaine
hrbigelow asked this question in General
Discussion options

You must be logged in to vote

I believe the following code will work, e.g. supported('\\foo'):

function supported (command) {
  let rendered;
  try {
    rendered = katex.renderToString(command, {throwOnError: false, errorColor: 'INVALID'});
  } catch {
    return true;
  }
  return !/color:INVALID/.test(rendered);
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@hrbigelow
Comment options

Answer selected by hrbigelow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants