Simple replacement maps would probably sufficient, e.g.:
substrings: replace(" " "\t", "␣" "→→→→") prepend("\n", "↵");
replace() function replaces given substrings with other substrings (" " to “␣” and “\t” (tab) to 4 “→” characters in the example), while
prepend() function adds substrings before corresponding substrings (adds “↵” before each line break in the example).
Same mechanism could probably work for other presentation-only text-processing purposes like trimming leading and trailing whitespace inside inline elements or removing substrings or entire text content of an element (e.g. for text-to-image replacement), etc.
While there should be no problem to do replacements, a possible issue with prepending something before line breaks is that it may result in line overflow if the line does not have sufficient empty space at the end for the prepended string. This would probably need some way to enable positioning of the prepended substring relative to the original substring, e.g.:
substrings: prepend("\n", "↵", 0);
0 works somewhat like
left: 0 for absolutely positioned elements, so the prepended substring would be positioned above (by z-axis) original substring and would not affect line length.