ve tokens and splitting them
        // when a reference word is found inside the merged string.
        function alignRawTokensByRef(rawList, refList) {
            let refIdx = 0;
            let rawIdx = 0;
            const refLen = refList.length;
            const alignedRaw = [];

            // Use a copy to avoid modifying the original list.
            const rawCopy = [...rawList];

            while (rawIdx < rawCopy.length && refIdx < refLen) {
                let mergedSplitDone = false;
      