sed is a great tool for that:
# substitute ("s/")
sed -e 's/^[[:blank:]]*// ; # parts of lines that start ("^") with a space/tab
s/[[:blank:]]*$//' # or end ("$") with a space/tab
# with nothing (/)
You can use it for your case be either piping in the text, e.g.
cat file |<file sed -e 's/^{{^[[...
or by acting on it 'inline' if your -sed is the GNU one:
sed -i 's/...' file
but changing the source this way is "dangerous" as it may be unrecoverable when it doesn't work right (or even when it does!), so backup first (or use -i.bak which also has the benefit to be portable to some BSD seds)!