Adding tests for # escaping and self-links.
Some refactoring. s:linkrank -> mtdt:_lr_