FIX: edge cases with bbcodes looking like reference definitions and empty links

This fixes certain cases, where BBCode-style tags supported by a custom dialect are treated as reference definitions instead, e.g. `[b]label[/b]: description`.

Ported from https://github.com/discourse/discourse/pull/2731.