refactor and test markup.notes. fix a few edge cases in markup.citations