10
APL (Dyalog Unicode), 57 35 bytesSBCS
–22 thanks to a novel solution by ngn.
Anonymous tacit function taking a character matrix as argument.
{⊃'+-|+'↓⍨2⊥5 4 2⊃¨⊂⍱∘⌽⍨' '≠,⍵}⌺3 3
Try it online!
{…}⌺3 3 on each 3-by-3 neighbourhood, apply the following function:
,⍵ ravel (flatten)
' '≠ B...