Fixes link parser to allow only nested link

Allows links to be nested withing links, but no other wiki markup
elements may.
Allows only templates to be nested within template

Adds robustness by disallowing any wiki nodes to be nested within
templates besides other templates. This allow parsing to continue even
if there are format errors within the template.
Allows only refs to be nested within ref

Adds robustness by only allowing references to be nested within
references.