my $simples = qr{\*\*}; # extensible by user. Same opening and closing. my $ps= qr{(?.*?) (?: (? (?: \[\[\s*(?.*?)\s*\]\] ) # explicit use of brackets | (?: (?(?:http|ftp)s?://\S+) ) # bare (just a start) )(*:link) | ~ (? (?&link)|.|\Z ) (*:escape) | // \s* (?(?: (?&link) | . )*?) \s* (?: //|\Z)(*:italic) # special rules for //, TODO start no problem, skip any links in body. | (?$simples)\s*(?.*?)\s*(?:\k|\Z)(*:simple) | \\\\ (*:break) | \{{3} \s* (?.*?) \s* \}{3} (*:nowiki) # be sure to check for three braces before checking for two. | \{{2} \s* (?[^|]*?) \s* (?: \| (?.*?) \s* )? \}{2} (*:image) | \<{3} \s* (?.*?) \s* \>{3} (*:placeholder) # be sure to check for 3 angles before checking for 2 (extension) | \Z (*:nada) # must be the last branch ) }xs;