How to make boxed math equation align according to its content?

I would like to add box to every mathematical equations (like blackboard) including the inline and display ones ; here is what I have done :

#show math.equation: set text(
  size: .75em, 
  fill: white
)
#show math.equation: box.with(
  baseline: 0%,
  fill: rgb("#000000"),
  inset: (x: .3em, y: 0em),
  outset: (y: .5em),
  stroke: gray + .4pt,
  radius: .5em,
)

and the result is in the attachment screenshot : notice that the baseline of math equation is not accord to the baseline of the sentence ( red box ) .

I tried smash the math equation box like

#show math.equation: it => box(
  height: 0pt, 
  box(
    baseline: 0%,
    fill: rgb("#000000"),
    inset: (x: .3em, y: 0em),
    outset: (y: .5em),
    stroke: gray + .4pt,
    radius: .5em,
    it
  )
)

but it won’t work . Do you have any suggestions ?

Hello, are you by chance rendering the integral in display mode?

blabla $display(integral) f(x) dif x$ blabla vs blabla $integral f(x) dif x$ blabla

I intended to do that , for a test .

I would like to know how to calculate the shifted baseline space . Here is what I have tried :

#show math.equation: set text(
  size: .75em, 
  // fill: white
)
#show math.equation: it => box(
  // height: measure([fgFGH ( ) ]).height,
  // height: measure([Hellofg]).height,
  stroke: black+.4pt,
  align(//horizon,
  box(
  baseline : measure(it).height - measure([fgTH ( )]).height,
  fill: silver.transparentize(90%),
  inset: (x: .3em, y: 0em),
  outset: (y: 1em),
  stroke: gray + .4pt,
  radius: .5em,
  it
)))

There is an interesting discovery :

If I add #set par(leading: 2em) at the top of the code with the following settings

#show math.equation: set text(
  size: .75em, 
  // fill: white
)
#show math.equation: set text(
  size: .75em, 
  // fill: white
)
#show math.equation: it => box(
  baseline : 0pt,
  fill: silver.transparentize(90%),
  // fill: black,
  inset: (x: .3em, y: 0em),
  outset: (y: 1em),
  stroke: gray + .4pt,
  radius: .5em,
  it
)

then the result will look much better :