(numChars: number)
| 209 | let idx = 0; |
| 210 | |
| 211 | const processNextChars = (numChars: number) => { |
| 212 | if (numChars <= 0) { |
| 213 | return; |
| 214 | } |
| 215 | |
| 216 | // @ts-ignore |
| 217 | const ops = deserializeOps(subattribution(attribs, idx, idx + numChars)); |
| 218 | idx += numChars; |
| 219 | |
| 220 | // this iterates over every op string and decides which tags to open or to close |
| 221 | // based on the attribs used |
| 222 | for (const o of ops) { |
| 223 | const usedAttribs:string[] = []; |
| 224 | |
| 225 | // mark all attribs as used |
| 226 | for (const a of attributes.decodeAttribString(o.attribs)) { |
| 227 | if (a in anumMap) { |
| 228 | usedAttribs.push(String(anumMap[a])); // i = 0 => bold, etc. |
| 229 | } |
| 230 | } |
| 231 | let outermostTag = -1; |
| 232 | // find the outer most open tag that is no longer used |
| 233 | for (let i = openTags.length - 1; i >= 0; i--) { |
| 234 | if (usedAttribs.indexOf(openTags[i]) === -1) { |
| 235 | outermostTag = i; |
| 236 | break; |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | // close all tags upto the outer most |
| 241 | if (outermostTag !== -1) { |
| 242 | while (outermostTag >= 0) { |
| 243 | emitCloseTag(openTags[0]); |
| 244 | outermostTag--; |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | // open all tags that are used but not open |
| 249 | for (let i = 0; i < usedAttribs.length; i++) { |
| 250 | if (openTags.indexOf(usedAttribs[i]) === -1) { |
| 251 | emitOpenTag(usedAttribs[i]); |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | let chars = o.chars; |
| 256 | if (o.lines) { |
| 257 | chars--; // exclude newline at end of line, if present |
| 258 | } |
| 259 | |
| 260 | let s = taker.take(chars); |
| 261 | |
| 262 | // form feed (0x0C) is a legacy control char with no meaning in HTML |
| 263 | s = s.replace(String.fromCharCode(12), ''); |
| 264 | |
| 265 | assem.append(_encodeWhitespace(Security.escapeHTML(s))); |
| 266 | } // end iteration over spans in line |
| 267 | |
| 268 | // close all the tags that are open after the last op |
no test coverage detected