I have this code, which is inspired by others, which is now succesfully merging items starting with \'##\' with the previous item in the list. However I have weird behaviour