lib/markdown: fix crash of the parser when parsing unfinished refs