How can I detect block vs. inline content?

I want to have a function which styles the given text, and, if it is full paragraphs, it also styles the paragraphs. If the given text is a part of a larger paragraph, the paragraph should not be styled because that would break the outer paragraph. A specific example of such function is to make alerting text, which would be red bold, but also, if it is full paragraphs or otherwise block content, with a red border.

So the question is: How can I detect what the given content is, either inline or block?

#let detail(function, compose) = {
  compose
  show function: x => (x,)
  compose}

#detail(math.equation)[
  $ A = pi r^2 $]

#show math.equation: e => {
  if e.block {text(blue, e)}
  else {text(green, e)}}

$A = pi r^2$ $ A = pi r^2 $