this commit contains two refactors: - extract custom link transformations into a function. - separate some trivial markup generation.