MCPcopy
hub / github.com/wavedrom/wavedrom / parse

Function parse

wavedrom.js:2173–2222  ·  view source on GitHub ↗
(str)

Source from the content-addressed store, hash-verified

2171}
2172
2173function 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
2224module.exports = parse;
2225/* eslint no-constant-condition: 0 */

Callers 9

reparseFunction · 0.70
renderWaveLaneFunction · 0.50
captextFunction · 0.50
ticktockFunction · 0.50
renderMarksFunction · 0.50
renderGroupsFunction · 0.50
renderArcsFunction · 0.50
insertSVGTemplateFunction · 0.50
insertSVGTemplateAssignFunction · 0.50

Calls 2

dumpFunction · 0.70
updateFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…