I've written regexes for markdown for emphasis and bold as follows:syntax match PandocEmphasisMarker \v(^|\s+)\zs_[^\n\t_ ]+([^_\n]|(\S_\S)|(\s_\S)|(\s+_\s+))+[^\n\t_ ]+_\ze($|\s+) contains=PandocEmphasissyntax match PandocEmphasis \v\zs[^\n\t_ ]+([^_\n]|(\S_\S)|(\s_\S)|(\s+_\s+))+[^\n\t_ ]+\ze containedsyntax match PandocStrongMarker \v\zs\*[^\n*]+\*\ze contains=PandocStrongsyntax match PandocStrong \v\zs[^\n*]+\ze containedThis yields the following (in my opinion correct) highlighting:However, in Markdown there could be emphasis inside strong and strong inside emphasis as well. Since I already have the regexes so far, I'd like to allow them to mutually include each other.I've tried with clusters as follows:syntax cluster PandocEmphasisCluster contains=PandocEmphasis,PandocStrongMarkersyntax cluster PandocStrongCluster contains=PandocStrong,PandocEmphasisMarkerAnd then referenced those clusters from the Marker expressions using contains, but that did not work, it messed up the strong highlighting in my test file and the strong part inside an emphasized part was not made bold.How can / should I make them contain each other?This is also important for other things like ` inside emphasized or strong. Maybe I should use region somehow?Clarification:emphasis inside strong should still be strong, but also become emphasized.strong inside emphasis should still be emphasized, but also become strongeffects should add up, that's what I want to achieve
How do I make regexes mutually contain each other?
regular expression;syntax highlighting;filetype markdown