The goal is to highlight text inside [...]
with a different color than text inside ![...]!
Also everything should be nestable such that [...]
could contain ![...]!
inside of it or vice versa and the colors should be different as desired.
I tried the following regex to try and match them differently but unfortunately wasn't able to succeed with it.
syn region squareBracketRegex_A start="^\[\|[^!]\[" skip="\[[^\]]*\]" end="\]" keepend oneline contains=squareBracketRegex_B
syn region squareBracketRegex_B start="!\[" skip="!\[[^\]]!*\]!" end="\]!" keepend oneline contains=squareBracketRegex_A
hi def link squareBracketRegex_A ColorGreen
hi def link squareBracketRegex_B ColorRed
Remark: I would like that the brackets themselves should take highlighting of whatever item they're contained in.