(str)
| 2171 | } |
| 2172 | |
| 2173 | function parse (str) { |
| 2174 | var state, res, i, m, a; |
| 2175 | |
| 2176 | if (str === undefined) { |
| 2177 | return []; |
| 2178 | } |
| 2179 | |
| 2180 | if (typeof str === 'number') { |
| 2181 | return [str + '']; |
| 2182 | } |
| 2183 | |
| 2184 | if (typeof str !== 'string') { |
| 2185 | return [str]; |
| 2186 | } |
| 2187 | |
| 2188 | res = []; |
| 2189 | |
| 2190 | state = { |
| 2191 | 'text-decoration': {}, |
| 2192 | 'font-weight': {}, |
| 2193 | 'font-style': {}, |
| 2194 | 'baseline-shift': {}, |
| 2195 | 'font-size': {}, |
| 2196 | 'font-family': {} |
| 2197 | }; |
| 2198 | |
| 2199 | while (true) { |
| 2200 | i = str.search(token); |
| 2201 | |
| 2202 | if (i === -1) { |
| 2203 | res.push(['tspan', dump(state), str]); |
| 2204 | return res; |
| 2205 | } |
| 2206 | |
| 2207 | if (i > 0) { |
| 2208 | a = str.slice(0, i); |
| 2209 | res.push(['tspan', dump(state), a]); |
| 2210 | } |
| 2211 | |
| 2212 | m = str.match(token)[0]; |
| 2213 | |
| 2214 | update(state, trans[m]); |
| 2215 | |
| 2216 | str = str.slice(i + m.length); |
| 2217 | |
| 2218 | if (str.length === 0) { |
| 2219 | return res; |
| 2220 | } |
| 2221 | } |
| 2222 | } |
| 2223 | |
| 2224 | module.exports = parse; |
| 2225 | /* eslint no-constant-condition: 0 */ |
no test coverage detected
searching dependent graphs…