# Distinguishing function calls from multiplication when importing LaTeX via ToExpression and TeXForm

I'm trying to parse a LaTeX representation of a Desmos calculator (like this one) via Mathematica.

Desmos exposes a JSON representation of its calculators, including a LaTeX representation of mathematical expressions.

I'm capturing and parsing the JSON via:

request =
HTTPRequest[
"https://www.desmos.com/calculator/liypnrwjke", <|"Headers" -> {
"Accept" -> "application/json"}|>]
response =


I'm then extracting a particular LaTeX representation from the JSON, e.g.

testLatex = response["state"]["expressions"]["list"][[2]]["latex"];


And then trying to interpret this as an expression, as in,

ToExpression[testLatex, TeXForm]


Unfortunately, there doesn't seem to be a semantic way to distinguish a function call from multiplication from just the LaTeX, so when presented with "f\\left(x\\right)=m\\left(x-a\\right)+b", Mathematica yields f[x] == b + m[-a + x]

How might I avoid this to instead get f[x]==b+m(x-a)? Perhaps using the presence of x in f[x] to identify the parameters?