(text: string, attribs: string[])
| 131 | }); |
| 132 | |
| 133 | const getLineHTML = (text: string, attribs: string[]) => { |
| 134 | // Use order of tags (b/i/u) as order of nesting, for simplicity |
| 135 | // and decent nesting. For example, |
| 136 | // <b>Just bold<b> <b><i>Bold and italics</i></b> <i>Just italics</i> |
| 137 | // becomes |
| 138 | // <b>Just bold <i>Bold and italics</i></b> <i>Just italics</i> |
| 139 | const taker = new StringIterator(text); |
| 140 | const assem = new StringAssembler(); |
| 141 | const openTags:string[] = []; |
| 142 | |
| 143 | const getSpanClassFor = (i: string) => { |
| 144 | // return if author colors are disabled |
| 145 | if (!authorColors) return false; |
| 146 | |
| 147 | // @ts-ignore |
| 148 | const property = props[i]; |
| 149 | |
| 150 | // we are not insterested on properties in the form of ['color', 'red'], |
| 151 | // see hook exportHtmlAdditionalTagsWithData |
| 152 | if (Array.isArray(property)) { |
| 153 | return false; |
| 154 | } |
| 155 | |
| 156 | if (property.substr(0, 6) === 'author') { |
| 157 | return stripDotFromAuthorID(property); |
| 158 | } |
| 159 | |
| 160 | if (property === 'removed') { |
| 161 | return 'removed'; |
| 162 | } |
| 163 | |
| 164 | return false; |
| 165 | }; |
| 166 | |
| 167 | // tags added by exportHtmlAdditionalTagsWithData will be exported as <span> with |
| 168 | // data attributes |
| 169 | const isSpanWithData = (i: string) => { |
| 170 | // @ts-ignore |
| 171 | const property = props[i]; |
| 172 | return Array.isArray(property); |
| 173 | }; |
| 174 | |
| 175 | const emitOpenTag = (i: string) => { |
| 176 | openTags.unshift(i); |
| 177 | const spanClass = getSpanClassFor(i); |
| 178 | |
| 179 | if (spanClass) { |
| 180 | assem.append('<span class="'); |
| 181 | assem.append(spanClass); |
| 182 | assem.append('">'); |
| 183 | } else { |
| 184 | assem.append('<'); |
| 185 | // @ts-ignore |
| 186 | assem.append(tags[i]); |
| 187 | assem.append('>'); |
| 188 | } |
| 189 | }; |
| 190 |
no test coverage detected