FIX: Allow link references following a list

This is an issue that was reported via Discourse. If you follow a list with a link reference, it would not parse the link correctly. 

This patch includes a test and fix for this failing case. It also extracts `create_references` and `extract_attr` as functions for re-use in the fix.