Refactor topic preview trimming functions