#!/usr/bin/awk -f function s(t,i){while(match($0,t)){if(I[ni]==i)ni-=sub(t,"") else if(sub(t,"<"i">"))I[++ni]=i}}BEGIN{FS="\n"; RS="";ni=0} {$0=(match($0,/^<.*>$/))?$0:"

"$0"

" s("__","strong");s("\\*","em");s("`","code"); print}