[MOJO-1981] Fixed rendering of new line between groups.
Improve readability by extracting getPrecedingText(...).