question: Map < Integer , Integer > strippedWhitespaceUpToColumn ( String intro ) { Map < Integer , Integer > stripped = new TreeMap < > ( ) ; boolean countingWhitespace = false ; int col = 0 ; int count = 0 ; for ( char c : intro . toCharArray ( ) ) { if ( c == '\n' && ! countingWhitespace ) { countingWhitespace = true ; } else if ( countingWhitespace ) { if ( Character . isWhitespace ( c ) ) count ++ ; else countingWhitespace = false ; } stripped . put ( col , count ) ; col ++ ; } return stripped ; }
target:  Help count how much newline and margin whitespace we have stripped up to a particular index so we know how to offset anchors