(text:string, attribs:any)
| 62 | }); |
| 63 | |
| 64 | const getLineTXT = (text:string, attribs:any) => { |
| 65 | const propVals:(number|boolean)[] = [false, false, false]; |
| 66 | const ENTER = 1; |
| 67 | const STAY = 2; |
| 68 | const LEAVE = 0; |
| 69 | |
| 70 | // Use order of tags (b/i/u) as order of nesting, for simplicity |
| 71 | // and decent nesting. For example, |
| 72 | // <b>Just bold<b> <b><i>Bold and italics</i></b> <i>Just italics</i> |
| 73 | // becomes |
| 74 | // <b>Just bold <i>Bold and italics</i></b> <i>Just italics</i> |
| 75 | const taker = new StringIterator(text); |
| 76 | const assem = new StringAssembler(); |
| 77 | |
| 78 | let idx = 0; |
| 79 | |
| 80 | const processNextChars = (numChars: number) => { |
| 81 | if (numChars <= 0) { |
| 82 | return; |
| 83 | } |
| 84 | |
| 85 | const ops = deserializeOps(subattribution(attribs, idx, idx + numChars)); |
| 86 | idx += numChars; |
| 87 | |
| 88 | for (const o of ops) { |
| 89 | let propChanged = false; |
| 90 | |
| 91 | for (const a of attributes.decodeAttribString(o.attribs)) { |
| 92 | if (a in anumMap) { |
| 93 | const i = anumMap[a] as number; // i = 0 => bold, etc. |
| 94 | |
| 95 | if (!propVals[i]) { |
| 96 | propVals[i] = ENTER; |
| 97 | propChanged = true; |
| 98 | } else { |
| 99 | propVals[i] = STAY; |
| 100 | } |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | for (let i = 0; i < propVals.length; i++) { |
| 105 | if (propVals[i] === true) { |
| 106 | propVals[i] = LEAVE; |
| 107 | propChanged = true; |
| 108 | } else if (propVals[i] === STAY) { |
| 109 | // set it back |
| 110 | propVals[i] = true; |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | // now each member of propVal is in {false,LEAVE,ENTER,true} |
| 115 | // according to what happens at start of span |
| 116 | if (propChanged) { |
| 117 | // leaving bold (e.g.) also leaves italics, etc. |
| 118 | let left = false; |
| 119 | |
| 120 | for (let i = 0; i < propVals.length; i++) { |
| 121 | const v = propVals[i]; |
no test coverage detected