How do i match $F$ but not $"F"$ with a show rule?

Hello, my question is basically the title. I have a document where I want to insert a bit of negative space after every F that was specifically in math mode, i.e. after every $F$.

The usual way I would do it would be something like:

#show math.equation: it => {
  show "F": [$F #h(-0.1pt)$]
  it
}

But this also matches strings inside math mode, so also $“F”$. I do not want this second match. For example,

$F "Flavor text" F$

should be converted to

$F #h(-0.1pt) "Flavor text" F #h(-0.1pt)$

Thanks in advance.

I didn’t see a way to detect whether the matched “F” is a string or not. Instead it’s possible to match “F” and leave what’s found alongside the negative width:

#show math.equation: it => {
  show "F": it => {it; h(-0.1pt)}
  it
}

$ F "Flavor text" F $

image